Skip to content

fix(up): honor -t when an attached up stops the application - #14395

Merged
ndeloof merged 1 commit into
docker:mainfrom
htoyoda18:fix/up-timeout-attached-stop
Oct 27, 2026
Merged

ndeloof merged 1 commit into
docker:mainfrom
htoyoda18:fix/up-timeout-attached-stop

Conversation

@htoyoda18

@htoyoda18 htoyoda18 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

When an attached docker compose up stops the application itself, on Ctrl+C or on --abort-on-container-exit / --exit-code-from, it ignored -t/--timeout and waited for each service's stop_grace_period (or the engine default). The flag is documented as the shutdown timeout "when attached", so this PR passes the -t value to those stops. Without -t, nothing changes.

Related issue

Fixes #14394

Changes made

  • pkg/compose/up.go: stopApplication (Ctrl+C and abort on container exit) and stopLateStarter (a service that starts after termination began) now set Timeout: u.options.Create.Timeout in their api.StopOptions. This is the value -t already fills. It is nil when -t is not given, so the current behavior is unchanged in that case.
  • pkg/compose/up_test.go: add TestUpSessionStopsWithUpTimeout, which checks that both stops pass the -t value to ContainerStop. Before the fix, both subtests failed with an empty Timeout.
  • pkg/e2e/cascade_test.go, pkg/e2e/testdata/TestCascadeStopHonorsTimeout/compose.yaml: add a regression scenario. up -t 1 --abort-on-container-exit --exit-code-from tests must end with exit code 3 within 60s while another service ignores SIGTERM and has stop_grace_period: 2m. Before the fix it hit the 60s bound; now it finishes in ~3.5s. The Ctrl+C path goes through the same stopApplication, but the Scenario DSL cannot send signals, so it is covered by the unit test only.

Testing done

  • Unit tests pass: make test
  • E2E tests pass: make e2e-compose or make e2e-compose-standalone
  • Linting passes: make lint
  • Code formatted: make fmt
  • Manually tested (describe):

AI tool used (if applicable)

AI Tool:

Additional context

(not mandatory) A picture of a cute animal, if possible in relation to what you did

image

Signed-off-by: hiroto.toyoda <hiroto.toyoda@dena.com>
@htoyoda18
htoyoda18 marked this pull request as ready for review October 26, 2026 19:51
@htoyoda18
htoyoda18 requested review from a team as code owners October 26, 2026 19:51
@htoyoda18
htoyoda18 requested review from glours and ndeloof October 26, 2026 19:51
@ndeloof
ndeloof enabled auto-merge (rebase) October 27, 2026 07:45

@ndeloof ndeloof 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, thanks.

@ndeloof
ndeloof merged commit 4d61d5a into docker:main Oct 27, 2026
61 of 63 checks passed
@codecov

codecov Bot commented Oct 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

[BUG] up -t/--timeout is ignored when an attached up is stopped by Ctrl+C or --abort-on-container-exit

2 participants