diff --git a/modules/mesh-delivery-builder/internal/build/revisionwait.go b/modules/mesh-delivery-builder/internal/build/revisionwait.go index 651d6f303..f3c98287b 100644 --- a/modules/mesh-delivery-builder/internal/build/revisionwait.go +++ b/modules/mesh-delivery-builder/internal/build/revisionwait.go @@ -107,7 +107,9 @@ func (b *Builder) keptRevisionHolds(ctx context.Context, run meshbuilds.StepRun, } } // Each asked fingerprint is recorded as the branch's, so its build reserves its version (H-A-155) as one the picture - // took in does; what the picture heard stays as it is, so the newer fingerprint's build is not superseded. + // took in does; what the picture heard stays as it is, so the newer fingerprint's build is not superseded. Once the picture + // heard a newer entry of the module on the first branch, H-A-489 overrides H-A-205: the older fingerprint is refused + // superseded (buildEntry), never built or reserved. b.mu.Lock() for _, e := range run.Entries { key, err := builds.BuilderBuildKey(e.Module, e.Fingerprint) diff --git a/modules/mesh-delivery-builder/internal/build/run_test.go b/modules/mesh-delivery-builder/internal/build/run_test.go index 60c84d914..383bca35b 100644 --- a/modules/mesh-delivery-builder/internal/build/run_test.go +++ b/modules/mesh-delivery-builder/internal/build/run_test.go @@ -369,6 +369,29 @@ func TestAWithdrawnBuildEndsWithdrawn(t *testing.T) { } } +// H-A-489 (review round 1): a newer entry of the first branch heard between the older build's claim and its reservation is +// not taken over: the older key ends failed withdrawn with no reservation, and the newer reserves. +func TestANewerEntryHeardBeforeTheReservationIsNotTakenOver(t *testing.T) { + r := newRig(t, goBundle) + r.mf.byDigest[mdigest('a')] = catalogue.Manifest{Module: "m", Version: "0.1", Build: &catalogue.Build{Artifacts: []catalogue.Artifact{goBundle}}} + res := &fakeReservations{filled: true} + r.b.Reserved = res + newer, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20", + Fp2: fp2, Manifest: mdigest('a'), Path: "modules/m", Toolchains: CatalogToolchains(agreedToolchains)}) + if err != nil { + t.Fatal(err) + } + r.st.before = func() { r.b.Module(context.Background(), "m", newer) } // at the older key's claim + r.b.Module(context.Background(), "m", moduleValue(t, "modules/m")) + r.b.Wait() + if v := valueOf(t, r.st, r.key); v.State != builds.BuildFailed || !strings.HasPrefix(v.Error, "withdrawn: ") || !strings.Contains(v.Error, "superseded by the fingerprint "+fp2) { + t.Errorf("the older key = %+v, want failed withdrawn, superseded by %s", v, fp2) + } + if len(res.sources) != 1 || res.sources[0].Fingerprint != fp2 { + t.Errorf("reserved %+v, want one reservation, the newer's", res.sources) + } +} + // H-A-489: a fingerprint of the first branch that is no longer its newest entry heard is neither reserved for nor built, and // said once; the again loop that looks at it later builds nothing. func TestAnOlderFingerprintAskedAfterANewerEntryIsRefused(t *testing.T) { diff --git a/modules/mesh-delivery-builder/internal/build/step_test.go b/modules/mesh-delivery-builder/internal/build/step_test.go index 63ef38218..69abfe82d 100644 --- a/modules/mesh-delivery-builder/internal/build/step_test.go +++ b/modules/mesh-delivery-builder/internal/build/step_test.go @@ -74,6 +74,21 @@ func TestABuildStepAnswersItsEnd(t *testing.T) { if end := ask(entries...); end.Outcome != meshbuilds.StepEndedOutcomePassed || end.Step != meshbuilds.StepEndedStepBuild || len(end.Entries) != 1 || end.Entries[0].Commit != "c1" || end.Pipeline != "main.1.m" { t.Errorf("a done build: %+v", end) } + // H-A-489 (review round 1): a withdrawn key whose fingerprint is still the newest entry is answered failed at once, naming + // withdrawn: no look builds it again, so its end is never waited for. + rw := newRig(t, catalogue.Artifact{Name: "files", Kind: "archive"}) + rw.b.StepEntry = r.b.StepEntry + withdrawn, _ := builds.EncodeBuilderBuild(builds.BuilderBuild{State: builds.BuildFailed, Manifest: mdigest('a'), Error: withdrawnPrefix + "its reservation 0.1.3 was taken over"}) + if _, err := rw.st.Create(t.Context(), rw.key, withdrawn); err != nil { + t.Fatal(err) + } + rw.b.Module(t.Context(), "m", moduleValue(t, "modules/m")) // the newest entry heard is fp1 + rw.b.Wait() + bounded, cancel := context.WithTimeout(t.Context(), 2*time.Second) + defer cancel() + if end := rw.b.BuildStep(bounded, "ask1", meshbuilds.StepRun{Pipeline: "main.1.m", Step: meshbuilds.StepRunStepBuild, Entries: entries}); end.Outcome != meshbuilds.StepEndedOutcomeFailed || !strings.Contains(end.Said, "withdrawn: ") { + t.Errorf("a withdrawn key asked: %+v, want failed at once naming withdrawn", end) + } } // A step ask waits for the end of its build without a timer: the log entry of that end wakes it (design 47 G A-97). @@ -434,9 +449,10 @@ func aStepAskWaitsForItsRevision(t *testing.T) { } -// H-A-205: two pipelines of consecutive revisions run at once; the picture holds source revision 46, whose entry of m moved -// on, while the older pipeline asks the build of revision 45. Its kept catalog revision is read by number and the build runs; -// a kept revision naming another fingerprint fails the step, naming it. +// H-A-205: two pipelines of consecutive revisions run at once; the picture holds source revision 46, while the older pipeline +// asks the build of revision 45. Its kept catalog revision is read by number and the build runs while the picture never heard +// a newer entry of m (a restart); once it heard one on the first branch, H-A-489 overrides H-A-205 and the older ask is refused +// superseded. A kept revision naming another fingerprint fails the step, naming it. func anOlderKeptRevisionIsReadByNumber(t *testing.T) { var held atomic.Int64 held.Store(46)