Repository navigation
fix: COMPOSE_REMOVE_ORPHANS resolves identically for every command carrying the flag - #14139
Conversation
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
Lower-confidence findings (not posted inline)
- [medium→low] cmd/compose/compose.go:757 — Remote-config exclusion guard in
setEnvWithDotEnvonly works whenConfigPathsis pre-populated; silently skipped when paths are discovered dynamically (confidence: weak 52/100) - [medium→low] cmd/compose/create.go:100 — Asymmetric env sources:
removeOrphansreads fromos.Getenv(process env) whileignoreOrphansreads fromproject.Environment(loader-resolved); conflict guard may behave differently for remote configs (confidence: weak 52/100)
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
On the lower-confidence finding about the remote-config guard in |
|
Follow-up on the second lower-confidence finding (asymmetric env sources for |
0aa14bd to
e6e5979
Compare
glours
left a comment
There was a problem hiding this comment.
Changes requested, no blocker. The resolution logic is right; what's missing is a test pinning the per-command wiring (inline), and the guard + rationale comment is now pasted three times (inline, one helper fixes it). One inline comment is doc accuracy on the remote exclusion.
Behaviour changes to call out in the PR description / release notes, none are mentioned today:
COMPOSE_REMOVE_ORPHANS=truein a local.envnow takes effect fordownandkill, which only honoured a shell-exported value before (the default was read at flag-registration time, beforesetEnvWithDotEnv). With the flag set,downalso stops and removes running one-off containers (pkg/compose/down.go:72-84) andkillkills them (kill.go:51). A setting meant forupnow takes down livecompose runsessions.runandcreatenow honourCOMPOSE_REMOVE_ORPHANStoo.runandcreatenow fail onCOMPOSE_IGNORE_ORPHANS=true+ remove-orphans.runaccepted the combination silently before, andcreateignoredCOMPOSE_IGNORE_ORPHANSaltogether.COMPOSE_REMOVE_ORPHANSisn't documented anywhere underdocs/(onlyCOMPOSE_IGNORE_ORPHANSis,docs/reference/compose.md:239); worth a line next to it.
c0690c0 to
ee274a9
Compare
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
…rrying the flag The variable had three resolution mechanisms: up read it in PreRunE after the project's .env was injected into the process environment; down and kill read it at cobra-tree construction time — before that injection, so a value declared in the project's .env worked for up but not for them; create and run never read it at all. All five commands now resolve it through one helper, from PreRunE: explicit flag wins, then the process environment as completed by setEnvWithDotEnv from the local .env. create also gains the COMPOSE_IGNORE_ORPHANS handling (its ignoreOrphans field was sent to the API without ever being assigned) with the same conflict guard as up. setEnvWithDotEnv's remote-config exclusion is now documented as a product decision, not a technical constraint: COMPOSE_* variables exist so a local user doesn't repeat flags — they are the local user's choice, and a remote model must not steer the CLI consuming it. Unit tests pin the .env → process env → flag resolution order and the remote exclusion (epic docker#14074, D.1 and G.3). Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
run resolved both COMPOSE_REMOVE_ORPHANS and COMPOSE_IGNORE_ORPHANS but was the only command accepting the contradictory combination silently; it now rejects it exactly like up and create. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
COMPOSE_REMOVE_ORPHANS and COMPOSE_IGNORE_ORPHANS resolve through different sources by design, not by accident: the destructive variable goes through the process environment, completed from the local .env only — a remote model cannot enable container removal — while the benign one reads project.Environment, remote configs included, where the worst a remote model can do is suppress a warning. Stated once, on the resolveIgnoreOrphans helper shared by up, create and run, so future reviewers don't have to rediscover the decision. The helper is covered by a test, and another one runs the real up/down/kill/run/create commands to pin that each of them resolves COMPOSE_REMOVE_ORPHANS. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
ee274a9 to
bb3b397
Compare
Epic #14074, D.1 (and G.3).
COMPOSE_REMOVE_ORPHANShad three resolution mechanisms:upread it after the project's.envwas injected into the process environment;down/killread it at cobra-tree construction time — before that injection, so a value in the project's.envworked forupbut not for them;create/runnever read it.All five commands now resolve it identically from
PreRunEthrough one helper: explicit flag > process env > local.env.createalso gainsCOMPOSE_IGNORE_ORPHANShandling (itsignoreOrphansfield was sent to the API without ever being assigned), withup's conflict guard.Behavioral notes:
down/killnow honor the variable from the project's.env; the shell-exported case behaves as before (the--helpoutput no longer reflects it as the flag default, since resolution moved out of the flag definition).setEnvWithDotEnv: COMPOSE_* variables are the local user's choice; a remote model must not steer the CLI consuming it..env→ process env → flag resolution order and the remote exclusion.🤖 Generated with Claude Code