fix(up): drop benign context.Canceled noise from the final report - #14227
Merged
Merged
Conversation
The new TestUpAttachedTerminatesOnExternalStop (docker#13990) occasionally observed `up` exit 1 instead of 0 after an external stop/down cancels a service's restart backoff. The cause: once the monitor detects termination and cancels globalCtx, a log-streaming goroutine still blocked on logs?follow=1 for the backoff container gets a context.Canceled error, which appendErr collected unfiltered into the final errors.Join. That race could only surface once docker#13990 made the monitor loop actually return in this scenario -- before that fix, up hung forever and never reached this code path. appendErr now drops an error that is nothing more than fallout from our own shutdown (errors.Is(err, context.Canceled) once u.globalCtx.Err() is set), the same way a SIGINT-triggered teardown's residual goroutine errors are already expected to be harmless. A genuine error is still reported regardless of shutdown state. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
This is a direct follow-up to #13990.
Context
CI flaked right after #13990 merged:
TestUpAttachedTerminatesOnExternalStopfailed on thestandalonejob variants withupexiting 1 instead of 0, and this in the captured output:Once the monitor detects the container's restart backoff was canceled by an external
stop/downand returns,upcancelsglobalCtxto unwind its goroutines. The container's log-streaming goroutine (still blocked onlogs?follow=1waiting for output that will never come) gets acontext.Cancelederror from that cancellation, andappendErrcollected it unfiltered into the finalerrors.Join, turning what should be a clean, expected termination into a reported failure.This could only surface once #13990 made the monitor loop actually return in this scenario — before that fix
uphung forever and never reached this code path, so the race was unreachable.What this PR brings
appendErrnow drops an error that is nothing more than fallout fromup's own shutdown (errors.Is(err, context.Canceled)onceu.globalCtx.Err()is set) — the same treatment a SIGINT-triggered teardown's residual goroutine errors already get elsewhere. A genuine, unrelated error occurring after shutdown is still reported.🤖 Generated with Claude Code