Skip to content

fix(up): drop benign context.Canceled noise from the final report - #14227

Merged
glours merged 1 commit into
docker:mainfrom
ndeloof:13985-followup-benign-cancel-errors
Sep 16, 2026
Merged

glours merged 1 commit into
docker:mainfrom
ndeloof:13985-followup-benign-cancel-errors

Conversation

@ndeloof

@ndeloof ndeloof commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

This is a direct follow-up to #13990.

Context

CI flaked right after #13990 merged: TestUpAttachedTerminatesOnExternalStop failed on the standalone job variants with up exiting 1 instead of 0, and this in the captured output:

Get "http://%2Fvar%2Frun%2Fdocker.sock/.../logs?follow=1&...": context canceled

Once the monitor detects the container's restart backoff was canceled by an external stop/down and returns, up cancels globalCtx to unwind its goroutines. The container's log-streaming goroutine (still blocked on logs?follow=1 waiting for output that will never come) gets a context.Canceled error from that cancellation, and appendErr collected it unfiltered into the final errors.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 up hung forever and never reached this code path, so the race was unreachable.

What this PR brings

appendErr now drops an error that is nothing more than fallout from up's own shutdown (errors.Is(err, context.Canceled) once u.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

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>
@ndeloof
ndeloof requested review from a team as code owners September 16, 2026 06:45
@ndeloof
ndeloof requested a review from glours September 16, 2026 06:45

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@glours glours left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@glours
glours merged commit 01a60a5 into docker:main Sep 16, 2026
92 of 95 checks passed
@ndeloof
ndeloof deleted the 13985-followup-benign-cancel-errors branch September 16, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants