From 1a924f2ca72676b39af05183345280b41958ef22 Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 17 Nov 2026 11:58:25 +0100 Subject: [PATCH] runner: a seat with no holder ends its pipeline failed at once, its other steps not asked (A-470g, A-470h) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A pipeline with a step whose seat the seat-holders view names no holder for was failed only once its other steps ended, after their asks ran for nothing; it now ends failed at placing, naming the seat, with every other step not asked and said, and none of its steps asked. Builds: design 47 G §32, §535, §647 (as A-466y and A-466z amend them); A-470g, A-470h --- .../cmd/mesh-delivery-pipeline/main.go | 2 +- .../internal/pipeline/place_test.go | 38 +++++++-- .../internal/pipeline/run.go | 6 +- .../internal/pipeline/start.go | 83 ++++++++++++++----- .../internal/pipeline/steps.go | 19 +++++ 5 files changed, 118 insertions(+), 30 deletions(-) diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/main.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/main.go index 1551038a..9d7187c9 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/main.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/main.go @@ -152,7 +152,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro starter := &pipeline.Starter{Pipelines: createdKV{ctx: ctx, kv: pipelines}, Logf: logger.Printf, Say: say, Registration: rv.Registrations.Registration, Steps: busStepAsker{ctx: ctx, js: js, cred: cred}, Name: cred.Module, Kept: keptReader(ctx, kept), Toolchain: toolchainReader(ctx, toolchains), - Fills: fills, Recovered: kvRecoveries{ctx, recovered}.Has, Holders: rv.Holders.Holders} + Fills: fills, Recovered: kvRecoveries{ctx, recovered}.Has, Holders: rv.Holders.Holders, Ended: hearer.EndedAtPlacing} placeHalf := func(ev catalog.CatalogRevisionEvent, half pipeline.Half) error { n, err := starter.PlaceRun(ev, half, rv.Catalog.View) logger.Printf("the candidate %s's revision %d placed %d pipelines of its run", ev.Group, ev.Revision, n) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go index eb49aa9a..5c933433 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go @@ -450,9 +450,10 @@ func TestATestRunIsAskedOncePerCandidateLevelAndDigest(t *testing.T) { } // A seat with no holder is read only from the seat-holders view (design 47 G §535, §647 as A-466y and A-466z amend them): -// once that view's first view is read, a build step whose seat it names no holder for ends could not run naming the seat -// and is asked of no one; before it is read, or with a holder named, the step is asked and waits with no bound of the -// runner's own; the claimant of the view is the one module the catalog halves name. +// once that view's first view is read, a build step whose seat it names no holder for ends could not run naming the seat, +// and the pipeline ends failed at once naming it, every other step `not asked`, each said, none asked (A-470g, A-470h); +// before it is read, or with a holder named, the step is asked and waits with no bound of the runner's own; the claimant of +// the view is the one module the catalog halves name. func TestASeatWithNoHolderIsReadFromTheSeatHoldersView(t *testing.T) { reg, entries := placeFixture() for _, c := range []struct { @@ -463,9 +464,11 @@ func TestASeatWithNoHolderIsReadFromTheSeatHoldersView(t *testing.T) { }{{"the view not read yet", nil, false, true}, {"a holder named", []string{"mesh-build-go"}, true, true}, {"no holder named", nil, true, false}} { t.Run(c.name, func(t *testing.T) { store, asks := memStore{}, &stepAsks{} + var said []int s := &Starter{Pipelines: memCreated{store}, Say: func(string, any) error { return nil }, Steps: asks, Name: "the-runner", Registration: func(string) (catalog.Registration, bool) { return reg, true }, - Holders: func(string) ([]string, bool) { return c.holders, c.read }} + Holders: func(string) ([]string, bool) { return c.holders, c.read }, + Ended: func(_ seat.Pipeline, steps []int) error { said = steps; return nil }} if ok, err := s.Start(Begin{Branch: "main", Source: 4, Module: "app", Commit: "c1", Fp: "src2:aa", Entries: entries}); !ok || err != nil { t.Fatalf("start = %v, %v", ok, err) } @@ -478,8 +481,31 @@ func TestASeatWithNoHolderIsReadFromTheSeatHoldersView(t *testing.T) { if c.asked && (lint.Outcome != seat.StepResultOutcomeRunning || !asked) { t.Errorf("the lint step = %+v, asked %v; want it running and asked", lint, asked) } - if !c.asked && (lint.Outcome != seat.StepResultOutcomeCouldNotRun || !strings.Contains(lint.Why, "node-build-go has no holder") || len(asks.ids) != 2) { - t.Errorf("the lint step = %+v, %d asked; want could not run naming the seat, only the build and composition asked", lint, len(asks.ids)) + if c.asked { + if p.Outcome != seat.PipelineOutcomeRunning || said != nil { + t.Errorf("the pipeline = %s (%s), ended steps said %v; want it running", p.Outcome, p.Why, said) + } + return + } + if lint.Outcome != seat.StepResultOutcomeCouldNotRun || !strings.Contains(lint.Why, "node-build-go has no holder") || len(asks.ids) != 0 { + t.Errorf("the lint step = %+v, %d asked; want could not run naming the seat, nothing asked", lint, len(asks.ids)) + } + if want := "the seat node-build-go has no holder: the seat-holders view names none"; p.Outcome != seat.PipelineOutcomeFailed || p.Why != want || p.Ended == nil || p.EndCount != 1 { + t.Errorf("the pipeline = %s (%q), ended %v, count %d; want failed at once, %q", p.Outcome, p.Why, p.Ended, p.EndCount, want) + } + ended := 0 + for _, st := range p.Steps { + switch { + case st.Seat == "node-build-go", st.Outcome == seat.StepResultOutcomeNotAsked: + ended++ + case st.Outcome == seat.StepResultOutcomeBypassed, st.Outcome == seat.StepResultOutcomeCouldNotRun && st.Seat == "": + // ended by Place itself: a bypass, or a language no build seat names + default: + t.Errorf("the step %s %s = %s; want not asked", st.Artifact, st.Step, st.Outcome) + } + } + if ended < 3 || len(said) != ended { + t.Errorf("%d steps ended at placing, %d said; want each said", ended, len(said)) } }) } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/run.go b/modules/mesh-delivery-pipeline/internal/pipeline/run.go index becc1be8..5063e81c 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/run.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/run.go @@ -229,10 +229,11 @@ func (s *Starter) placeRunPipeline(key, id string, revision int64, half Half) (b } p.Fingerprint, p.Repository, p.Revision = e.Fp, e.Repository, revision var asks []Asked + var ended []int if s.Registration != nil { if reg, ok := s.Registration(p.Module); ok { p.Steps, asks = Place(p, reg, half.Entries, now, s.Name) - asks = s.holderless(p.Steps, asks, now) + asks, ended = s.holderless(&p, asks, now) } else { s.logf("%s has no registration yet: its pipeline is placed with no step", key) } @@ -247,6 +248,9 @@ func (s *Starter) placeRunPipeline(key, id string, revision int64, half Half) (b if err := s.Say(runnerclient.Subject(seat.EventPipelineStarted, p.Module, p.Branch, p.Commit), ev); err != nil { s.logf("pipeline-started of %s is not said: %v", key, err) } + if len(ended) > 0 { + return true, s.endedAtPlacing(p, ended) + } if s.Steps != nil && len(asks) > 0 { if err := s.askSteps(key, p.Commit, asks); err != nil { return true, err diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/start.go b/modules/mesh-delivery-pipeline/internal/pipeline/start.go index 7a6617df..dcc1ab14 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/start.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/start.go @@ -4,8 +4,10 @@ import ( "encoding/json" "errors" "fmt" + "slices" "sort" "strconv" + "strings" "time" runnerclient "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient" @@ -76,6 +78,9 @@ type Starter struct { // Holders are the modules the seat mesh-module-assigner's view seat-holders names for a seat, and whether that view's // first view is read (§535, §647 as A-466y, A-466z amend them); nil, or a view not read yet, judges no seat holderless. Holders func(seat string) ([]string, bool) + // Ended says a pipeline that ended at its placing (holderless): the step-ended of each step of steps, then its end + // (Hearer.EndedAtPlacing); nil says it in the journal alone. + Ended func(p seat.Pipeline, steps []int) error // Fills refuses a start while a store of the runner is full (§366); nil refuses none. Fills *Fills // Recovered says whether a commit is named a recovery (§81, §86): its steps are asked on the build seats' stream delivery. @@ -95,36 +100,60 @@ type Starter struct { EndReaders func(run string, readers []seat.TestRunReader, r seat.TestRun) error } -// holderless ends, as it is placed, each build step whose seat the seat mesh-module-assigner's view seat-holders names no holder -// for, `could not run` naming the seat, and asks it of no one (design 47 G §535, §647 as A-466y and A-466z amend them): judged -// only once that view's first view is read, never from the picture before it. It answers the asks still to put. -func (s *Starter) holderless(steps []seat.StepResult, asks []Asked, now time.Time) []Asked { +// holderless ends at once, as it is placed, a pipeline with a build step whose seat the seat mesh-module-assigner's view +// seat-holders names no holder for (design 47 G §32, §535, §647 as A-466y and A-466z amend them; A-470g, A-470h): judged only +// once that view's first view is read, never from the picture before it. Each such step ends `could not run` naming the seat, +// every other step not ended ends `not asked`, each with its step log entry, and the pipeline ends `failed` naming the seat; +// none of its steps is asked. It answers the asks still to put and the steps it ended, none when no seat is holderless. +func (s *Starter) holderless(p *seat.Pipeline, asks []Asked, now time.Time) ([]Asked, []int) { if s.Holders == nil { - return asks + return asks, nil } - none := map[string]bool{} - for i := range steps { - st := &steps[i] - if !open(*st) || !BoundSeat(st.Seat) { + var none []string + for _, st := range p.Steps { + if !open(st) || !BoundSeat(st.Seat) || slices.Contains(none, st.Seat) { continue } - if holders, read := s.Holders(st.Seat); !read || len(holders) > 0 { - continue + if holders, read := s.Holders(st.Seat); read && len(holders) == 0 { + none = append(none, st.Seat) } - st.Outcome, st.Ended, st.Ask, st.Shared = seat.StepResultOutcomeCouldNotRun, &now, "", nil - st.Why = fmt.Sprintf("the seat %s has no holder: the seat-holders view names none", st.Seat) - none[st.Seat] = true } if len(none) == 0 { - return asks + return asks, nil } - out := asks[:0:0] - for _, a := range asks { - if !none[a.Seat] { - out = append(out, a) + sort.Strings(none) + whys := make([]string, 0, len(none)) + for _, n := range none { + whys = append(whys, fmt.Sprintf("the seat %s has no holder: the seat-holders view names none", n)) + } + var ended []int + for i := range p.Steps { + st := &p.Steps[i] + if !open(*st) && st.Outcome != seat.StepResultOutcomeWaiting { + continue } + st.Ended, st.Ask, st.Shared = &now, "", nil + if slices.Contains(none, st.Seat) { + st.Outcome, st.Why = seat.StepResultOutcomeCouldNotRun, fmt.Sprintf("the seat %s has no holder: the seat-holders view names none", st.Seat) + } else { + st.Outcome, st.Why = seat.StepResultOutcomeNotAsked, "the pipeline failed at once: "+strings.Join(whys, "; ") + } + p.Unlogged = append(p.Unlogged, endEntry(p.Pipeline, *st, now)) + ended = append(ended, i) } - return out + p.Outcome, p.Why, p.Ended = seat.PipelineOutcomeFailed, strings.Join(whys, "; "), &now + p.EndCount++ + return nil, ended +} + +// endedAtPlacing says a pipeline holderless ended at placing (A-470h): each step it ended in its step-ended, then the +// pipeline's end, through Ended; with none given it is said in the journal alone. +func (s *Starter) endedAtPlacing(p seat.Pipeline, steps []int) error { + s.logf("%s ended failed at once: %s (A-470g)", p.Pipeline, p.Why) + if s.Ended == nil { + return nil + } + return s.Ended(p, steps) } // askSteps puts a placed pipeline's asks (§22, §24): a test run another step asked is read, not asked again (share), then @@ -202,12 +231,13 @@ func (s *Starter) Start(b Begin) (bool, error) { } p := newPipeline(b, key, now) var asks []Asked + var ended []int if b.unheld { s.logf("%s starts with no step: the catalog half of %s is not held yet, and its steps are placed once it is (A-336)", key, b.Branch) } else if s.Registration != nil { if reg, ok := s.Registration(b.Module); ok { p.Steps, asks = Place(p, reg, b.Entries, now, s.Name) - asks = s.holderless(p.Steps, asks, now) + asks, ended = s.holderless(&p, asks, now) } else { s.logf("%s has no registration yet: its pipeline starts with no step and waits on the registration of %s, which places them (A-327)", key, b.Module) } @@ -231,6 +261,9 @@ func (s *Starter) Start(b Begin) (bool, error) { if s.Supersede != nil { s.Supersede(p) } + if len(ended) > 0 { + return true, s.endedAtPlacing(p, ended) + } if s.Steps != nil && len(asks) > 0 { if err := s.askSteps(key, b.Commit, asks); err != nil { return true, err @@ -379,7 +412,7 @@ func (s *Starter) placeWaiting(store Updater, pattern string, reg func(seat.Pipe } var asks []Asked p.Steps, asks = Place(p, r, half.Entries, now, s.Name) - asks = s.holderless(p.Steps, asks, now) + asks, ended := s.holderless(&p, asks, now) if _, err := store.Update(key, p, rev); err != nil { s.logf("%s is written meanwhile, so nothing is placed in it now: %v", key, err) continue @@ -395,6 +428,12 @@ func (s *Starter) placeWaiting(store Updater, pattern string, reg func(seat.Pipe s.logf("pipeline-started of %s is not said: %v", key, err) } } + if len(ended) > 0 { + if err := s.endedAtPlacing(p, ended); err != nil { + note(err) + } + continue + } if s.Steps != nil && len(asks) > 0 { if err := s.askSteps(key, p.Commit, asks); err != nil { note(err) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go index 7f2989ee..718e322b 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go @@ -571,3 +571,22 @@ func endPipeline(p *seat.Pipeline, now time.Time) bool { } return true } + +// EndedAtPlacing says a pipeline its starter ended at placing, a seat with no holder (A-470g, A-470h): the step-ended of each +// step of steps, its step log entries appended, the head's finding pipeline-failed (§33), then its pipeline-ended. +func (h *Hearer) EndedAtPlacing(p seat.Pipeline, steps []int) error { + var first error + for _, i := range steps { + if err := h.say(seat.EventStepEnded, p, &p.Steps[i]); err != nil && first == nil { + first = fmt.Errorf("pipeline %s's %s is written but not said: %w", p.Pipeline, seat.EventStepEnded, err) + } + } + h.appendUnlogged(p.Pipeline) + if len(steps) > 0 { + h.Failures.StepEnded(h.Store, p, p.Steps[steps[0]]) + } + if err := h.said(p, false, true); err != nil && first == nil { + first = err + } + return first +}