fix: Exit with non-zero status if ping or heartbeat fail unrecoverably#3687
Merged
DrJosh9000 merged 1 commit intomainfrom Jan 28, 2026
Conversation
zhming0
previously requested changes
Jan 28, 2026
Contributor
zhming0
left a comment
There was a problem hiding this comment.
Hmm, the consensus mechanism between ping loop and heart beat loop isn't quite right I think.
9a637e2 to
7a5cd91
Compare
3bd617f to
0fe0c22
Compare
0fe0c22 to
c3e8c31
Compare
c3e8c31 to
1f2dce2
Compare
Merged
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Context: A recent incident at Buildkite caused an issue to occur... wait, where have we heard this before?
It turns out the agent was exiting 0 in cases where the ping or heartbeat are unrecoverable, so this PR changes them to exit 1.
Context
https://linear.app/buildkite/issue/PS-1593/investigate-using-non-zero-exit-code-when-ping-receives-http-401
Changes
runPingLoop.runHeartbeatLoop. Collect both errors and return either nil or one of the non-nil loop errors fromagentWorker.Start. (That error bubbles up to main, which should exit 1.)heartbeatCtx, and instead have the heartbeat loop respond to<-a.stop, so that "ordinary" stopping is not an error.StopUngracefully out ofPingandHeartbeat, instead making them the responsibility ofrunPingLoopandrunHeartbeatLoop`. (Could go either way on this.)errors.Is(err, &errUnrecoverable{})with a slightly nicer lookingisUnrecoverable(err), and remove theIsmethod (note that the method removal could also be achieved witherrors.As(err, new(*errUnrecoverable))).agentWorker.Start, and necessary changes to the fake API server to avoid a deadlockTesting
go test ./...). Buildkite employees may check this if the pipeline has run automatically.go tool gofumpt -extra -w .)Disclosures / Credits
I did not use AI tools at all