diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionbounds.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionbounds.go index 5fb6f5fc1..83ea8bce3 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionbounds.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionbounds.go @@ -67,6 +67,18 @@ func waitOf(run meshwants.CompositionRun, reader meshwants.CompositionReader) me // sayWaits says, for each reader, its wait held or ended (how: ran, superseded); a wait that cannot be said is journaled. func (r *compositionRuns) sayWaits(run meshwants.CompositionRun, readers []meshwants.CompositionReader, how string) { + r.sayWaitsOf(run, readers, how, "") +} + +// sayWaitsAtPut says, at the put of the run ask of a run whose wait for a package's publish ended, its readers' wait-held for a +// build node again, under their held id with .put added, so the bus's duplicate window does not take it for the first one's +// (design 47 H2 H-A-632). +func (r *compositionRuns) sayWaitsAtPut(run meshwants.CompositionRun) { + r.sayWaitsOf(run, run.Readers, "", ".put") +} + +// sayWaitsOf is sayWaits, each held id with after added. +func (r *compositionRuns) sayWaitsOf(run meshwants.CompositionRun, readers []meshwants.CompositionReader, how, after string) { if r.say == nil { return } @@ -76,6 +88,7 @@ func (r *compositionRuns) sayWaits(run meshwants.CompositionRun, readers []meshw if run.Waits != nil && how == "" { // a wait-held of its own, so the bus's duplicate window does not take it for the first one's id += "." + run.Waits.Package } + id += after if how != "" { w.How, event, id = how, meshwants.EventWaitEnded, strings.TrimSuffix(id, ".held")+".ended" } diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go index d4734d163..f81b50b8f 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go @@ -326,18 +326,24 @@ func (r *compositionRun) start(ctx context.Context, key string, run meshwants.Co end(node + ": " + err.Error()) return } - if _, _, err := r.runs.change(key, func(c *meshwants.CompositionRun) bool { + waited := false + written, _, err := r.runs.change(key, func(c *meshwants.CompositionRun) bool { + waited = false if c.Ask != ask || c.Ended != nil { return false } c.Program = &meshwants.CompositionRunProgram{Repository: program.Repository, Commit: program.Commit, Directory: program.Dir, Fingerprint: engineFp} c.Input = digest - c.Waits = nil // its wait ends as its run ask is put (H-A-629 (1)) + waited, c.Waits = c.Waits != nil, nil // its wait ends as its run ask is put (H-A-629 (1)) return true - }); err != nil { + }) + if err != nil { end(node + ": the run's program and input are not written: " + err.Error()) return } + if waited { // its readers wait for a build node again, no longer for the package's publish (H-A-632) + r.runs.sayWaitsAtPut(written) + } a := buildstep.StepAsk{ID: ask, Kind: buildstep.AskCheck, Language: buildstep.AskGo, Asker: runAsker, At: r.now().UTC(), Run: &buildstep.RunJob{Program: program, Heads: []buildstep.RunHead{}, Input: ref, Reader: "the composition of " + node + " by the node-engine at " + program.Commit}, Packages: pins} // the composer is built against its entry's pins, each empty one filled (H-A-203, H-A-192, H-A-628 (2)) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go index 741d0d4d6..6d4c08a76 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go @@ -323,9 +323,15 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) { u.mu.Unlock() return put(ctx, a) } + lastHeld := map[string]string{} // by machine: what its newest wait-held waits on, and its id u.runs.say = func(event string, body any, id string) error { w := body.(meshwants.Wait) journal.logf("said %s on %s: %s (%s)", event, w.On, w.Words, id) + if event == meshwants.EventWaitHeld { + u.mu.Lock() + lastHeld[w.Node] = w.On + " (" + id + ")" + u.mu.Unlock() + } return nil } phase := &stepPhase{} @@ -452,6 +458,15 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) { t.Errorf("after the publish %s's composer is built against %v, want x/go at v0.1.9", node, a.Packages) } } + // H-A-632: at the put each reader's newest wait-held is for a build node again, under its held id with .put added. + for _, node := range []string{"ace", "g14"} { + u.mu.Lock() + got := lastHeld[node] + u.mu.Unlock() + if !strings.HasPrefix(got, waitOnBuildNode+" (") || !strings.HasSuffix(got, ".held.put)") { + t.Errorf("%s: after the put the newest wait-held of %s waits on %s, want a build node under its held id with .put", how, node, got) + } + } for _, key := range keys { if got := atPut[key]; got != "waits , bound " { t.Errorf("as the run ask of %s was put its wait stood: %s; want waits and the bound gone (ยง720: an ask in the queue has no clock)", key, got) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go index 7b4332588..95166e21a 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go @@ -327,18 +327,24 @@ func (r *compositionRun) startValidate(ctx context.Context, key string, run mesh couldNot(err.Error()) return } - if _, _, err := r.runs.change(key, func(c *meshwants.CompositionRun) bool { + waited := false + written, _, err := r.runs.change(key, func(c *meshwants.CompositionRun) bool { + waited = false if c.Ask != ask || c.Ended != nil { return false } c.Program = &meshwants.CompositionRunProgram{Repository: program.Repository, Commit: program.Commit, Directory: program.Dir, Fingerprint: entry.Fp} c.Input = digest - c.Waits = nil // its wait ends as its run ask is put (H-A-629 (1)) + waited, c.Waits = c.Waits != nil, nil // its wait ends as its run ask is put (H-A-629 (1)) return true - }); err != nil { + }) + if err != nil { couldNot("the run's program and input are not written: " + err.Error()) return } + if waited { // its readers wait for a build node again, no longer for the package's publish (H-A-632) + r.runs.sayWaitsAtPut(written) + } a := buildstep.StepAsk{ID: ask, Kind: buildstep.AskCheck, Language: buildstep.AskGo, Asker: runAsker, At: r.now().UTC(), Run: &buildstep.RunJob{Program: program, Heads: []buildstep.RunHead{}, Input: ref, Reader: "the manifest validator of " + step.Pipeline + " at " + program.Commit}, Packages: pins} // the validator is built against its entry's pins at the step's revision, each empty one filled (H-A-203, H-A-192, H-A-205, H-A-628 (2)) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep_test.go index b18a6531c..5deaaae2f 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep_test.go @@ -119,6 +119,15 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) { var requests []composer.Request keeper := testKeeper(&objectsMem{objs: map[string][]byte{}}, time.Now) runs := newCompositionRuns(newRunsMem(), defaultRunSettings, time.Now, t.Logf) + var held []string // the wait-helds of the reader ask-left said, what each waits on and its id (H-A-630 (5), H-A-632) + runs.say = func(event string, body any, id string) error { + if w := body.(meshwants.Wait); event == meshwants.EventWaitHeld && strings.Contains(id, ".ask-left.") { + mu.Lock() + held = append(held, w.On+" ("+id+")") + mu.Unlock() + } + return nil + } r := &compositionRun{runs: runs, keeper: keeper, reads: &compositionReads{}, call: call, callFile: callFile, own: context.Background(), now: time.Now, logf: t.Logf, put: func(_ context.Context, a buildstep.StepAsk) error { body, err := keeper.body(a.Run.Input.Digest) @@ -271,4 +280,8 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) { if run.Ended == nil || run.Outcome != meshwants.CompositionRunOutcomePassed || len(asks) != 5 || asks[4].Packages["git.novox.be/novox/mesh-sdk/go"] != "v0.1.36" { t.Errorf("the validate run its starting step left ended %v %s %q with %d validator asks, want it put after the publish and passed", run.Ended, run.Outcome, run.Said, len(asks)) } + if len(held) < 2 || !strings.HasPrefix(held[len(held)-2], waitOnPublish+"git.novox.be/novox/mesh-sdk/go (") || + !strings.HasPrefix(held[len(held)-1], waitOnBuildNode+" (") || !strings.HasSuffix(held[len(held)-1], ".held.put)") { + t.Errorf("the validate run's reader was said waiting %v; want mesh-sdk's publish, then a build node again at the put (H-A-632)", held) + } }