H-A-326 (2): a pipeline waiting only on packages is named stalled

A step held on a package's publish counted as open, so a pipeline whose
only movers waited on publishes that had come before their wait was
never named by runner_health (main.137, twenty minutes).

Builds: design 47 H H-A-326 (2), H-A-311 (3)
This commit is contained in:
2026-11-21 21:18:32 +01:00
parent 05d9f90bdb
commit 438c8740a6
2 changed files with 21 additions and 4 deletions
@@ -26,7 +26,7 @@ const BehindAfter = 5 * time.Minute
const StalledAfter = 5 * time.Minute
// Stalled is the key of each running pipeline, as show reads it, that has had nothing open (no step asked and not ended,
// no required step waiting) and nothing newly placed, started or ended for StalledAfter at now (H-A-311 (3)), each with
// no required step waiting but on a package's publish) and nothing newly placed, started or ended for StalledAfter at now (H-A-311 (3)), each with
// how long, in key order.
func Stalled(pipelines Kept, now time.Time) ([]string, error) {
all, err := Reads{Pipelines: pipelines}.pipelines()
@@ -40,9 +40,10 @@ func Stalled(pipelines Kept, now time.Time) ([]string, error) {
}
last, busy := startedOf(p), false
for _, st := range p.Steps {
// A required step waiting (an approval on the operator, a pin-held step, a composition on its validate) is open,
// as the end's judgement holds it; an optional one waiting holds nothing (A-104).
if open(st) || (st.Outcome == seat.StepResultOutcomeWaiting && st.Status == seat.StepResultStatusRequired) {
// A required step waiting (an approval, a composition on its validate) is open, as the end's judgement holds it;
// an optional one waiting holds nothing (A-104), and neither does one waiting on a package's publish, as a mover
// with no steps waiting on one does not (H-A-326 (2)).
if open(st) || (st.Outcome == seat.StepResultOutcomeWaiting && st.Status == seat.StepResultStatusRequired && !strings.HasPrefix(st.Why, PinWait)) {
busy = true
break
}
@@ -61,6 +61,9 @@ func TestHealth(t *testing.T) {
"main.131 (nothing open and nothing placed for 6m0s)"},
// A required step waiting (an approval on the operator) is open, as the end's judgement holds it.
{"a pipeline whose approval waits is not", piped(now, "main.137", -20*time.Minute, seat.StepResultOutcomeWaiting), age("n_runner", 0), true, ""},
// H-A-326 (2): a pipeline whose only movers wait on packages (a step held on a publish, a mover with no steps) is named.
{"a pipeline waiting only on packages is named", heldOnPublish(piped(now, "main.137", -20*time.Minute, seat.StepResultOutcomeWaiting), "main.137"), age("n_runner", 0), false,
"main.137 (nothing open and nothing placed for 20m0s)"},
}
for _, r := range rows {
a := Health(r.pipelines, r.consumers, now)
@@ -94,3 +97,16 @@ func kept(m mapKept, key string) mapKept {
m[key] = raw
return m
}
// heldOnPublish is m with key's one step held on a package's publish (H-A-206) and a second mover with no steps, waiting on one.
func heldOnPublish(m mapKept, key string) mapKept {
var p seat.Pipeline
if err := json.Unmarshal(m[key], &p); err != nil {
panic(err)
}
p.Steps[0].Step, p.Steps[0].On, p.Steps[0].Why = seat.StepResultStepBuild, "", PinWait+"mesh-grants:busgrants"
p.Movers = append(p.Movers, seat.Mover{Module: "nats"})
raw, _ := json.Marshal(p)
m[key] = raw
return m
}