Based on our recent observations, github creates refs/pull/%s/head asynchronously and sometimes these creations queue up enough that the ref will not be there by the time buildkite receives the webhook and proceeds.
Unfortunately if the provider is github and we're building the PR, buildkite agent completely fails the job if it is unable to fetch the refs/pull/%s/head even the refspec is not even guaranteed to match the commit we're building (I can update between the time original webhook is issued and when the job runs, for example when retrying old job, or even when developer pushes new commit and the build is not configured to cancel)
The main fetch:
|
refspec := fmt.Sprintf("refs/pull/%s/head", e.PullRequest) |
Mirror update logic:
|
cmd := e.shell.Command("git", "--git-dir", mirrorDir, "fetch", "origin", refspec) |
Proposed solution: allow this fetch to fail and proceed as long as we still can fetch the specific refspec here:
|
if err := gitFetch(ctx, e.shell, gitFetchFlags, "origin", refspec); err != nil { |
Note that mirror logic does not mirror the same dual-fetch, but it also can fail the build if the refs/pull/%s/head is not there yet, so it needs to be expecting this corner case too.
Based on our recent observations, github creates
refs/pull/%s/headasynchronously and sometimes these creations queue up enough that the ref will not be there by the time buildkite receives the webhook and proceeds.Unfortunately if the provider is github and we're building the PR, buildkite agent completely fails the job if it is unable to fetch the
refs/pull/%s/headeven the refspec is not even guaranteed to match the commit we're building (I can update between the time original webhook is issued and when the job runs, for example when retrying old job, or even when developer pushes new commit and the build is not configured to cancel)The main fetch:
agent/internal/job/checkout.go
Line 578 in e55e764
Mirror update logic:
agent/internal/job/checkout.go
Line 386 in e55e764
Proposed solution: allow this fetch to fail and proceed as long as we still can fetch the specific refspec here:
agent/internal/job/checkout.go
Line 580 in e55e764
Note that mirror logic does not mirror the same dual-fetch, but it also can fail the build if the
refs/pull/%s/headis not there yet, so it needs to be expecting this corner case too.