From 438c8740a6b862bb67055a591b8d8d5a64fc4729 Mon Sep 17 00:00:00 2001 From: jochen Date: Sat, 21 Nov 2026 21:18:32 +0100 Subject: [PATCH] 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) --- .../internal/pipeline/consumers.go | 9 +++++---- .../internal/pipeline/consumers_test.go | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/consumers.go b/modules/mesh-delivery-pipeline/internal/pipeline/consumers.go index 98cd96729..c0c2b04b4 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/consumers.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/consumers.go @@ -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 } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/consumers_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/consumers_test.go index 459be4a3c..de47a48cc 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/consumers_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/consumers_test.go @@ -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 +}