mirror of
https://github.com/docker/compose.git
synced 2026-11-18 14:13:49 +00:00
Copilot review finding on #14290: waitDependency decided whether a DeadlineExceeded on an optional dependency wait was safe to tolerate using a bare boolean -- whether the caller had configured a timeout for this wait at all (exec.waitTimeout > 0, or legacy waitDependencies' timeout > 0). That can't distinguish THIS call's own timeout actually firing from an earlier deadline inherited from the caller's own ctx also firing: context.WithTimeout(parent, waitTimeout) still makes both parent and child report DeadlineExceeded once the parent's earlier deadline elapses, even though this wait's own timer never got there. An unsatisfied optional wait could therefore swallow a real external deadline (the process's own context, a test harness timeout) and report success instead of propagating it. Replaced the bool with an origCtx snapshot -- ctx as it stood right before this call's own conditional context.WithTimeout wrap -- threaded from executor.go's OpWaitCondition dispatch through execWaitCondition down to waitDependency, and from waitDependencies' own wrap in service_containers.go. waitDependency now checks origCtx.Err() == nil at the moment ctx.Done() fires: only when the pre-wrap context hasn't failed on its own is this wait's own timeout the one responsible. TestExecutePlanOptionalWaitDoesNotSwallowInheritedDeadline pins the negative case (inherited deadline must still propagate even though exec.waitTimeout is set and the dependency is optional) and TestExecutePlanOptionalWaitTimeoutIsToleratedWithoutInheritedDeadline pins the positive one (this wait's own timeout, no inherited deadline, still tolerated as before) -- both verified by ablation. Verified: go build, go test ./pkg/compose/... (full suite, not just the new tests) and golangci-lint clean. Local Copilot CLI review confirmed the origCtx threading is correct and race-free across all three call sites; its one actionable finding (missing positive-path coverage for the plan-executor route specifically) is addressed by the second new test above. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com> |
||
|---|---|---|
| .. | ||
| api | ||
| bridge | ||
| compose | ||
| dryrun | ||
| e2e | ||
| mocks | ||
| remote | ||
| utils | ||
| watch | ||