diff --git a/pkg/compose/executor_ops.go b/pkg/compose/executor_ops.go index d08748935..764ce7a05 100644 --- a/pkg/compose/executor_ops.go +++ b/pkg/compose/executor_ops.go @@ -220,16 +220,14 @@ func (exec *planExecutor) resolveContainerSummary(op Operation) (container.Summa // warning, not a plan failure — matching waitDependencies' own // optional-dependency handling. // -// Unlike waitDependencies, this has no timeout of its own to apply here -- -// ctx is used exactly as given, already wrapped (or not) by executeNode's -// OpWaitCondition dispatch in executor.go. origCtx is ctx as it stood right -// before that wrap, passed through unchanged to waitDependency, which needs -// it to tell its own wait timeout apart from an inherited deadline (see its -// doc comment). upDetached (up.go) is the caller that needs a timeout here -// at all: planExecutor.waitTimeout gives this node its own fresh per-wait -// window, the same thing start()'s own WaitTimeout already threads through -// every waitDependencies call -- without also bounding unrelated Create or -// Start work the way wrapping the whole plan's ctx would. +// This applies no timeout of its own -- ctx is used exactly as given, +// already wrapped (or not) by executeNode's OpWaitCondition dispatch in +// executor.go. origCtx is ctx as it stood right before that wrap, passed +// through unchanged to waitDependency, which needs it to tell its own wait +// timeout apart from an inherited deadline (see its doc comment). +// planExecutor.waitTimeout (set by upDetached and start) is what gives this +// node its own fresh per-wait window, without also bounding unrelated Create +// or Start work the way wrapping the whole plan's ctx would. func (exec *planExecutor) execWaitCondition(ctx, origCtx context.Context, op Operation) error { s := exec.compose exec.containersMu.Lock() diff --git a/pkg/compose/service_containers_test.go b/pkg/compose/service_containers_test.go index 86746ee25..bf8641398 100644 --- a/pkg/compose/service_containers_test.go +++ b/pkg/compose/service_containers_test.go @@ -927,7 +927,10 @@ func TestWaitDependencyDeadline(t *testing.T) { unsupportedDeps := types.DependsOnConfig{ "db": {Condition: "some_future_condition", Required: true}, } - err := tested.(*composeService).waitDependencies(t.Context(), &project, "app", unsupportedDeps, containers) + // the bound makes a regression that waits fail instead of hanging + ctx, cancel := context.WithTimeout(t.Context(), 2*time.Second) + defer cancel() + err := tested.(*composeService).waitDependencies(ctx, &project, "app", unsupportedDeps, containers) assert.NilError(t, err) var messages []string @@ -1147,6 +1150,7 @@ func TestOptionalDependencyInspectFailure(t *testing.T) { // the same end, whatever the instant the timeout expired at assert.Equal(t, duringInspect == nil, betweenPolls == nil) assert.Equal(t, errors.Is(duringInspect, errWaitTimeout), errors.Is(betweenPolls, errWaitTimeout)) + assert.Equal(t, errors.Is(duringInspect, context.DeadlineExceeded), errors.Is(betweenPolls, context.DeadlineExceeded)) if required { assert.Assert(t, errors.Is(duringInspect, errWaitTimeout), "got %v", duringInspect) assert.ErrorIs(t, duringInspect, context.DeadlineExceeded)