Skip to content

chore(compose): orphan semantics stated where up and down diverge - #14142

Open
ndeloof wants to merge 1 commit into
docker:mainfrom
ndeloof:legible-orphans
Open

chore(compose): orphan semantics stated where up and down diverge#14142
ndeloof wants to merge 1 commit into
docker:mainfrom
ndeloof:legible-orphans

Conversation

@ndeloof

@ndeloof ndeloof commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

What I did

Epic #14074, item C.4. The orphan-container asymmetry between up and down is intentional but was stated nowhere — this PR writes it down and pins it with tests, with no behavior change:

  • a container is orphaned when it is a one-off (compose run) that finished its task, or when it carries the project labels but its service is not defined by the compose model (the typical leftover after the compose file was edited);
  • a still-running one-off is somebody's live session: up --remove-orphans cleans up leftovers and never kills it (it is deliberately absent from the observed state);
  • down --remove-orphans is the explicit stop-the-application action: it does take running one-offs down, through the per-service removal loop — now said explicitly in down.go instead of being an unexplained side effect of the container listing.

Tests pin the predicate matrix, the observed-state classification (a running one-off is neither a service replica nor an orphan) and down's single stop+remove path for a running one-off of a declared service.

Related issue
Item C.4 of #14074

🤖 Generated with Claude Code

@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.

🟢 No issues found — LGTM! View logs.

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ndeloof ndeloof changed the title fix(compose): one orphan definition, stated and enforced everywhere chore(compose): orphan semantics stated where up and down diverge Aug 27, 2026
A container is orphaned when it is a one-off (compose run) that FINISHED
its task, or when it carries the project labels but its service is not
defined by the compose model — the typical leftover after the compose
file was edited. A still-RUNNING one-off is somebody's live session:
'up --remove-orphans' cleans up leftovers and must never kill it.
'down --remove-orphans' is the explicit stop-the-application action, so
it DOES take running one-offs down — through the per-service removal
loop, not the orphan branch.

That asymmetry was implemented but stated nowhere: isOrphaned's comment
only mentioned the model-absent half, down.go removed running one-offs
as an unexplained side effect of including one-offs in the listing, and
the observed-state collection silently dropped running one-offs with no
hint it was deliberate. No behavior change — the semantics are now
written at all three sites and pinned by tests: the predicate matrix,
the observed-state classification (a running one-off is neither a
service replica nor an orphan), and down's single stop+remove path for
a running one-off of a declared service.

Closes item C.4 of docker#14074.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>

@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

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