diff --git a/pkg/compose/executor.go b/pkg/compose/executor.go index ba73c5bc3..45a9ab326 100644 --- a/pkg/compose/executor.go +++ b/pkg/compose/executor.go @@ -396,20 +396,16 @@ func (exec *planExecutor) runNode(node *PlanNode, rs *runState, phase *phaseCanc var errWaitTimeout = errors.New("timeout waiting for dependencies") // translateWaitTimeout turns a plan failure caused by a wait node's own -// --wait-timeout window (see errWaitTimeout) into the user-facing message the -// imperative start path always reported, and leaves any other error as is. -// "application not healthy" is specifically a --wait message: without --wait, -// a user who only set --wait-timeout as a hang guard (a legal combination -// nothing rejects) would otherwise see a message implying a health check they -// never asked for, and gets the dependency-timeout message waitDependencies -// has always used instead of a raw "context deadline exceeded". -func translateWaitTimeout(err error, wait bool, timeout time.Duration) error { +// --wait-timeout window (see errWaitTimeout) into the "timeout waiting for +// dependencies" message the imperative start path always reported for a +// depends_on wait timing out, with or without --wait, and leaves any other +// error as is. It is deliberately not the "application not healthy" message: +// that one belongs to the final --wait readiness check that runs after the +// plan, which has its own translation. +func translateWaitTimeout(err error) error { if !errors.Is(err, errWaitTimeout) { return err } - if wait { - return fmt.Errorf("application not healthy after %s", timeout) - } return errors.New("timeout waiting for dependencies") } diff --git a/pkg/compose/executor_start_test.go b/pkg/compose/executor_start_test.go index 91e53fdc4..787dd1292 100644 --- a/pkg/compose/executor_start_test.go +++ b/pkg/compose/executor_start_test.go @@ -680,7 +680,7 @@ func TestExecutePlanRecreateThenStartUsesFinalName(t *testing.T) { Cause: "start", Service: &service, CreateNodeID: create.ID, - }, "start:web:1", rename) + }, "start:web:1", rename).Phase = PhaseStart err := svc.executePlan(t.Context(), project, emptyObservedState("test"), plan) assert.NilError(t, err) @@ -1222,6 +1222,9 @@ func TestExecutePlanWaitTimeoutSurvivesDependentSkip(t *testing.T) { Name: "db", Condition: types.ServiceConditionHealthy, }, "") + // both in the Start phase, like the reconciler plans them: the skipped + // dependent only exists if the wait that fails is in its own phase + wait.Phase = PhaseStart plan.addNode(Operation{ Type: OpStartContainer, ResourceID: "service:app:1", @@ -1240,14 +1243,14 @@ func TestTranslateWaitTimeout(t *testing.T) { marked := fmt.Errorf("%w: %w", errWaitTimeout, context.DeadlineExceeded) other := errors.New("boom") - assert.ErrorContains(t, translateWaitTimeout(marked, true, 3*time.Second), "application not healthy after 3s") - assert.Error(t, translateWaitTimeout(marked, false, 3*time.Second), "timeout waiting for dependencies") + // a depends_on wait timing out is a dependency timeout, whether or not + // --wait was given: "application not healthy" is the final readiness + // check's message, not this one's + assert.Error(t, translateWaitTimeout(marked), "timeout waiting for dependencies") - // anything that is not a wait's own timeout comes back untouched, with or - // without --wait: a bare DeadlineExceeded included - for _, wait := range []bool{true, false} { - assert.Equal(t, translateWaitTimeout(other, wait, time.Second), other) - assert.Equal(t, translateWaitTimeout(context.DeadlineExceeded, wait, time.Second), context.DeadlineExceeded) - } - assert.NilError(t, translateWaitTimeout(nil, true, time.Second)) + // anything that is not a wait's own timeout comes back untouched: a bare + // DeadlineExceeded included + assert.Equal(t, translateWaitTimeout(other), other) + assert.Equal(t, translateWaitTimeout(context.DeadlineExceeded), context.DeadlineExceeded) + assert.NilError(t, translateWaitTimeout(nil)) } diff --git a/pkg/compose/up.go b/pkg/compose/up.go index 5582e7e64..613edcb56 100644 --- a/pkg/compose/up.go +++ b/pkg/compose/up.go @@ -97,7 +97,7 @@ func (s *composeService) upDetached(ctx context.Context, project *types.Project, exec.waitTimeout = options.Start.WaitTimeout if err := exec.run(ctx, plan); err != nil { - return translateWaitTimeout(err, options.Start.Wait, options.Start.WaitTimeout) + return translateWaitTimeout(err) } if !options.Start.Wait {