fix(up): report a depends_on wait timeout as a dependency timeout, with --wait too

Copilot review finding on #14296: a wait node's own timeout is a
depends_on condition that did not become satisfied during the plan, not
the final --wait readiness check, which runs after the plan and has its
own "application not healthy" translation. The imperative path reported
"timeout waiting for dependencies" for the former regardless of --wait,
but translateWaitTimeout rewrote it as "application not healthy" when
--wait was set. It now always reports the dependency timeout.

Also mark the test nodes that stand for the Start phase as PhaseStart
(the recreate-then-start plan and the wait whose timeout survives a
skipped dependent), so they exercise the Create->Start barrier the way
the reconciler's plans do instead of running everything in one phase.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2026-10-08 12:17:09 +02:00 • committed by Guillaume Lours
parent 9a4983a34a
commit 23d3081f55
3 changed files with 21 additions and 22 deletions

View file

@ -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")
}

View file

@ -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))
}

View file

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