diff --git a/modules/mesh-delivery-builder/internal/build/revisionwait.go b/modules/mesh-delivery-builder/internal/build/revisionwait.go index a67613c4b..676d30c56 100644 --- a/modules/mesh-delivery-builder/internal/build/revisionwait.go +++ b/modules/mesh-delivery-builder/internal/build/revisionwait.go @@ -80,8 +80,8 @@ func (b *Builder) holdsRevision(branch string, source int64, entries []meshbuild } // keptRevisionHolds answers no outcome when the catalog keeps the ask's revision (its catalog revision by number) and that -// revision names every entry of the ask (H-A-205, H-A-222); superseded below the picture when it names a newer fingerprint of -// an entry (H-A-508 second addendum); else failed or could not run, with its words. +// revision names every entry of the ask (H-A-205, H-A-222); superseded when it names a newer fingerprint of an entry (H-A-508 +// second addendum); else failed or could not run, with its words. func (b *Builder) keptRevisionHolds(ctx context.Context, run meshbuilds.StepRun, held int64) (outcome, said string) { below := fmt.Sprintf("revision %d of %s is not named by the builder's picture, which holds source revision %d", run.Source, run.Branch, held) if run.Source < held { @@ -101,15 +101,15 @@ func (b *Builder) keptRevisionHolds(ctx context.Context, run meshbuilds.StepRun, b.logf("%s: %s, and the catalog's revision %d is of source revision %d, the ask names %d: the step fails, nothing is built", run.Pipeline, below, run.Revision, source, run.Source) return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s, and the catalog's revision %d is of source revision %d, the ask names %d", below, run.Revision, source, run.Source) } - // A step whose revision the picture has passed, and whose fingerprint the catalog's revision no longer names but names a - // newer one of its module, ends superseded with the superseding fingerprint in its why, never failed (design 47 H2 H-A-508 - // second addendum: one outcome for one fact). Failed stays for any other mismatch. + // A step whose fingerprint the catalog's revision no longer names but names a newer one of its module, found below the + // picture or by the revision's number, ends superseded with the superseding fingerprint in its why, never failed (design + // 47 H2 H-A-508 second addendum: one outcome for one fact, found by either check). Failed stays for any other mismatch. var superseded []string for _, e := range run.Entries { if fps[e.Module] == e.Fingerprint { continue } - if run.Source < held && fps[e.Module] != "" { + if fps[e.Module] != "" { superseded = append(superseded, stepSuperseded(e.Module, e.Fingerprint, fps[e.Module])) continue } @@ -151,9 +151,10 @@ func (b *Builder) awaitRevision(ctx context.Context, run meshbuilds.StepRun) (ou if (run.Revision > 0 && b.KeptRevision != nil) || below { // By its number (H-A-222), whatever the source the picture holds; for an ask naming none, only below the // picture (H-A-205). A kept revision of another source or naming other fingerprints is a mismatch the wait - // cannot mend: it fails at once; only a revision the catalog does not answer is waited for. + // cannot mend: it fails at once, or ends superseded at once when it names a newer fingerprint of the module (H-A-508 + // second addendum); only a revision the catalog does not answer is waited for. outcome, said := b.keptRevisionHolds(ctx, run, held) - if outcome == "" || below || outcome == meshbuilds.StepEndedOutcomeFailed { + if outcome == "" || below || outcome == meshbuilds.StepEndedOutcomeFailed || outcome == meshbuilds.StepEndedOutcomeSuperseded { return outcome, said } } diff --git a/modules/mesh-delivery-builder/internal/build/step_test.go b/modules/mesh-delivery-builder/internal/build/step_test.go index 16bacdae2..ba470fd87 100644 --- a/modules/mesh-delivery-builder/internal/build/step_test.go +++ b/modules/mesh-delivery-builder/internal/build/step_test.go @@ -546,7 +546,7 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) { if end3.Outcome != meshbuilds.StepEndedOutcomePassed || !slices.Equal(read3, []string{"main 48"}) || len(res3.sources) != 1 || res3.sources[0].CatalogRevision != 48 { t.Errorf("end = %+v, kept revisions read %v, reserved %+v; want passed, revision 48 of main read once and reserved at it", end3, read3, res3.sources) } - // H-A-218, H-A-222: a kept revision of another source than the ask names, or naming another fingerprint, is a mismatch: + // H-A-218, H-A-222: a kept revision of another source than the ask names is a mismatch: // the step fails at once naming it, never waiting out its bound (the bound here is long, the ask is not below the picture). for _, c := range []struct { name string @@ -555,7 +555,6 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) { said string }{ {"another source", 45, fp1, "the catalog's revision 48 is of source revision 45, the ask names 46"}, - {"another fingerprint", 46, "src2:other", "names m at \"src2:other\""}, } { rc, resc, _ := revisionRig(t, &held, make(chan struct{}, 1)) rc.b.RevisionWait = time.Hour @@ -568,6 +567,18 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) { t.Errorf("%s: end = %+v, reserved %+v; want failed at once saying %q, nothing reserved", c.name, end, resc.sources, c.said) } } + // H-A-508 second addendum, found by either check: a revision read by its number (H-A-222) whose kept revision names another + // fingerprint of m superseded the ask's: it ends superseded at once naming it, never failed and never waiting its bound. + rs, ress, _ := revisionRig(t, &held, make(chan struct{}, 1)) + rs.b.RevisionWait = time.Hour + rs.b.KeptRevision = func(context.Context, string, int64) (int64, map[string]string, error) { + return 46, map[string]string{"m": "src2:other"}, nil + } + ends := rs.b.BuildStep(t.Context(), "a1", same) + rs.b.Wait() + if ends.Outcome != meshbuilds.StepEndedOutcomeSuperseded || ends.Said != stepSuperseded("m", fp1, "src2:other") || len(ress.sources) != 0 { + t.Errorf("by its number, another fingerprint: end = %+v, reserved %+v; want superseded by src2:other at once, nothing reserved", ends, ress.sources) + } } func aStepAskPastItsRevisionBoundFails(t *testing.T) {