Skip to content

Retry once if updating Bitbucket PR fails due to outdated version

Administrator requested to merge mrn/retry-updating-bbs-prs into main

Created by: mrnugget

This fixes #28962 (closed) by changing the BitbucketServerSource to retry the UpdatePullRequest if it failed because the local copy of the Sourcegraph pull request is outdated.

If we don't do that, we're trapped in a deadlock between the reconciler and the syncer: the reconciler tries to update the PR and keeps failing because the local copy is outdated and the syncer won't update the local copy because the reconciler never sets the changeset to completed.

What the change here does is to "force" the update by using the newest version that the server returns with its error and sending that along with the update request.

That might sound questionable, but it's what we do for other code hosts as well and is, essentially, how Batch Changes are supposed to work: users describe the desired state in their batch spec and Sourcegraph tries its best to make that happen. This is no different than how we already overwrite commits that someone has pushed to a branch if a spec is applied again.

Merge request reports

Loading