Drop withdrawn versions the catalog released past; a dropped number stays a gap (H-A-226)
The series key's Withdrawn grew at every take-over and was never pruned. At each write it now keeps only the withdrawn versions above the catalog's highest released (those at or below it are refused by the plain rule anyway), carried across a renumbering of the same fingerprint too; a dropped number is never reused (H-A-226 withdraws H-A-225's freeing). The comment of the rebuild's reservation now states A-490b as H-A-225 amends it. Builds: design 47 H H-A-225, H-A-226
This commit is contained in:
@@ -724,8 +724,9 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB
|
|||||||
var reserved versions.ReservedVersion
|
var reserved versions.ReservedVersion
|
||||||
hasReserved := false
|
hasReserved := false
|
||||||
if rebuild && cl.Build.State == builds.BuildBuilding {
|
if rebuild && cl.Build.State == builds.BuildBuilding {
|
||||||
// Reserved afresh, above the highest the catalog's versions answers, taking over the older unreleased reservation of this
|
// Reserved as A-490b amended by H-A-225 has it: this fingerprint's standing reservation is kept while it is unreleased
|
||||||
// fingerprint (A-455), never its standing number kept (A-490b); the build's own publish then runs.
|
// and above the highest the catalog's versions answers, else the next above that highest is taken (A-455); the build's
|
||||||
|
// own publish then runs.
|
||||||
if b.Reserved.Filled() {
|
if b.Reserved.Filled() {
|
||||||
reserved, hasReserved = b.reserve(ctx, module, m, plan, b.originOf(key), true)
|
reserved, hasReserved = b.reserve(ctx, module, m, plan, b.originOf(key), true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,12 +202,22 @@ func (r *Reserver) Reserve(ctx context.Context, module, series string, artifacts
|
|||||||
for _, a := range artifacts {
|
for _, a := range artifacts {
|
||||||
out.Artifacts[a] = ""
|
out.Artifacts[a] = ""
|
||||||
}
|
}
|
||||||
if found && cur.Fingerprint != src.Fingerprint {
|
if found {
|
||||||
out.Withdrawn = maps.Clone(cur.Withdrawn)
|
out.Withdrawn = maps.Clone(cur.Withdrawn)
|
||||||
if out.Withdrawn == nil {
|
if cur.Fingerprint != src.Fingerprint {
|
||||||
out.Withdrawn = map[string]string{}
|
if out.Withdrawn == nil {
|
||||||
|
out.Withdrawn = map[string]string{}
|
||||||
|
}
|
||||||
|
out.Withdrawn[cur.Version] = cur.Fingerprint // a dropped number stays a gap (H-A-226)
|
||||||
|
}
|
||||||
|
// One at or below the catalog's highest released is refused by the plain rule anyway: the map never grows without end.
|
||||||
|
maps.DeleteFunc(out.Withdrawn, func(v, _ string) bool {
|
||||||
|
_, p, err := SplitVersion(v)
|
||||||
|
return err != nil || p <= high
|
||||||
|
})
|
||||||
|
if len(out.Withdrawn) == 0 {
|
||||||
|
out.Withdrawn = nil
|
||||||
}
|
}
|
||||||
out.Withdrawn[cur.Version] = cur.Fingerprint
|
|
||||||
}
|
}
|
||||||
raw, _ := json.Marshal(out)
|
raw, _ := json.Marshal(out)
|
||||||
if found {
|
if found {
|
||||||
|
|||||||
@@ -221,6 +221,31 @@ func TestAReleaseIsRecordedByFingerprintBeforeItsReservationGoes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestTheWithdrawnVersionsAreDroppedOnceReleasedPast: design 47 H H-A-225, H-A-226 — a dropped number stays a gap, kept in
|
||||||
|
// the series key's Withdrawn while it is above the catalog's highest released; at each write those at or below it go, so the
|
||||||
|
// map never grows without end.
|
||||||
|
func TestTheWithdrawnVersionsAreDroppedOnceReleasedPast(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
store := &reserveMem{mem: newMem()}
|
||||||
|
highest := "0.1.3"
|
||||||
|
r := &Reserver{Store: store, Filled: func() bool { return true },
|
||||||
|
ReleasedOf: func(context.Context, string) ([]string, error) { return []string{highest}, nil }}
|
||||||
|
for _, fp := range []string{"src2:a", "src2:b", "src2:c"} {
|
||||||
|
if _, err := r.Reserve(ctx, "m", "0.1", []string{"m:a"}, Source{Fingerprint: fp}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cur, _, _, _ := r.get(ctx, ReservedKey("m", "0.1"))
|
||||||
|
if cur.Version != "0.1.6" || len(cur.Withdrawn) != 2 || cur.Withdrawn["0.1.4"] != "src2:a" || cur.Withdrawn["0.1.5"] != "src2:b" {
|
||||||
|
t.Fatalf("reservation %+v; want 0.1.6 with 0.1.4 and 0.1.5 withdrawn", cur)
|
||||||
|
}
|
||||||
|
highest = "0.1.5" // the catalog released past both withdrawn numbers but the newest
|
||||||
|
got, err := r.Reserve(ctx, "m", "0.1", []string{"m:a"}, Source{Fingerprint: "src2:d"})
|
||||||
|
if err != nil || got.Version != "0.1.7" || len(got.Withdrawn) != 1 || got.Withdrawn["0.1.6"] != "src2:c" {
|
||||||
|
t.Errorf("reserved %+v (%v); want 0.1.7 keeping only 0.1.6 withdrawn", got, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TestARebuildReservesAboveTheCatalogsHighestWhateverItsStandingNumberWas: design 47 G A-490b as H-A-225 amends it — a build again
|
// TestARebuildReservesAboveTheCatalogsHighestWhateverItsStandingNumberWas: design 47 G A-490b as H-A-225 amends it — a build again
|
||||||
// of a done key, or a re-run after a restart, keeps its fingerprint's standing reservation while it is unreleased and above the
|
// of a done key, or a re-run after a restart, keeps its fingerprint's standing reservation while it is unreleased and above the
|
||||||
// catalog's highest; one at or below it is replaced (Took told) by the next above the catalog's highest alone; another
|
// catalog's highest; one at or below it is replaced (Took told) by the next above the catalog's highest alone; another
|
||||||
|
|||||||
Reference in New Issue
Block a user