Builder: a build again reserves above the catalog's highest alone, its own standing number no floor (A-490b)
Reserver.Reserve takes Source.Rebuild: this fingerprint's standing reservation is replaced (Took told) and is no floor; another fingerprint's stays one. Tested against the real reserver, standing below and above the catalog's highest. Builds: design 47 G A-490b, §369 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
@@ -193,12 +193,12 @@ func (b *Builder) waitFill(module string, m meshcatalog.ModulesByModuleValue) bo
|
||||
|
||||
// reserve reserves the version of the build that starts; a reservation that cannot be made is said and the build goes on
|
||||
// unreserved: the caller fails the key, which a look takes again (A-490).
|
||||
func (b *Builder) reserve(ctx context.Context, module string, m meshcatalog.ModulesByModuleValue, plan Plan, o Origin) (versions.ReservedVersion, bool) {
|
||||
func (b *Builder) reserve(ctx context.Context, module string, m meshcatalog.ModulesByModuleValue, plan Plan, o Origin, rebuild bool) (versions.ReservedVersion, bool) {
|
||||
refs := make([]string, 0, len(plan.Tasks))
|
||||
for _, t := range plan.Tasks {
|
||||
refs = append(refs, module+":"+t.Artifact)
|
||||
}
|
||||
src := versions.Source{Repository: m.Repository, Commit: m.Commit, Fingerprint: m.Fp2, Branch: o.Branch, Revision: o.Source}
|
||||
src := versions.Source{Repository: m.Repository, Commit: m.Commit, Fingerprint: m.Fp2, Branch: o.Branch, Revision: o.Source, Rebuild: rebuild}
|
||||
for _, t := range plan.Tasks {
|
||||
src.GoPackage = src.GoPackage || (t.Kind == catalogue.ArtifactPackage && t.Language == "go")
|
||||
}
|
||||
@@ -260,7 +260,7 @@ func (b *Builder) ReserveDone(ctx context.Context, module, fp string) (versions.
|
||||
if !b.Reserved.Filled() {
|
||||
return versions.ReservedVersion{}, versions.ErrNotFilled
|
||||
}
|
||||
res, ok := b.reserve(ctx, module, m, plan, b.originOf(key))
|
||||
res, ok := b.reserve(ctx, module, m, plan, b.originOf(key), false)
|
||||
if !ok {
|
||||
return versions.ReservedVersion{}, fmt.Errorf("no version could be reserved for %s at %s (the builder's journal says why)", module, fp)
|
||||
}
|
||||
|
||||
@@ -617,7 +617,7 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB
|
||||
}
|
||||
// A key built again by hand is taken over as it stands too: one left building by a look that ended without its write
|
||||
// (issue 1966) is the hand tool's to finish.
|
||||
// A done key a person builds again whose reserved version is not released is built whole, under that version (A-490).
|
||||
// A done key a person builds again whose reserved version is not released is built whole, under a version reserved afresh (A-490b).
|
||||
rebuild := byHand && trunk && planErr == nil && !nothing && b.Reserved != nil && b.doneDigests(ctx, module, m.Fp2) != nil &&
|
||||
b.rebuildRefused(ctx, module, m.Fp2) == "" && b.reservesVersion(plan)
|
||||
cl, err := b.Claimer.Claim(ctx, module, m.Fp2, m.Manifest, ClaimOptions{Rebuild: rebuild, TakeOver: first || byHand, ByHand: byHand, ByEvent: byEvent, ImageBuilder: imageSeat, Seats: b.Seats, Trunk: trunk, Published: b.isPublished,
|
||||
@@ -662,11 +662,11 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB
|
||||
// Reserved afresh, above the highest the catalog's versions answers, taking over the older unreleased reservation of this
|
||||
// fingerprint (A-455), never its standing number kept (A-490b); the build's own publish then runs.
|
||||
if b.Reserved.Filled() {
|
||||
reserved, hasReserved = b.reserve(ctx, module, m, plan, b.originOf(key))
|
||||
reserved, hasReserved = b.reserve(ctx, module, m, plan, b.originOf(key), false)
|
||||
}
|
||||
reserving = true
|
||||
} else if reserving && cl.Build.State != builds.BuildDone {
|
||||
reserved, hasReserved = b.reserve(ctx, module, m, plan, b.originOf(key))
|
||||
reserved, hasReserved = b.reserve(ctx, module, m, plan, b.originOf(key), false)
|
||||
}
|
||||
var result builds.BuilderBuild
|
||||
if reserving && !hasReserved && cl.Build.State != builds.BuildDone {
|
||||
|
||||
@@ -91,6 +91,9 @@ type Source struct {
|
||||
// that catalog revision (design 47 G §371, A-57), kept on the reservation for the publication.
|
||||
Branch string
|
||||
Revision int64
|
||||
// Rebuild marks a build again of a done key whose version is not released: the standing reservation of Fingerprint is replaced
|
||||
// and is no floor, so the number is the next above the catalog's highest alone (design 47 G A-490b).
|
||||
Rebuild bool
|
||||
}
|
||||
|
||||
// ReservedKey is the key of module's reservation of series (MAJOR.MINOR).
|
||||
@@ -168,7 +171,7 @@ func (r *Reserver) Reserve(ctx context.Context, module, series string, artifacts
|
||||
return ReservedVersion{}, err
|
||||
}
|
||||
next := high
|
||||
if found {
|
||||
if found && !(src.Rebuild && cur.Fingerprint == src.Fingerprint) {
|
||||
if _, p, err := SplitVersion(cur.Version); err == nil && p > next {
|
||||
next = p
|
||||
}
|
||||
|
||||
@@ -220,3 +220,36 @@ func TestAReleaseIsRecordedByFingerprintBeforeItsReservationGoes(t *testing.T) {
|
||||
t.Error("the newest release is not kept")
|
||||
}
|
||||
}
|
||||
|
||||
// TestARebuildReservesAboveTheCatalogsHighestWhateverItsStandingNumberWas: design 47 G A-490b — a build again of a done key replaces
|
||||
// its fingerprint's standing reservation (and tells Took) and numbers above the catalog's highest alone, whether the standing number
|
||||
// is below it or above it; another fingerprint's standing reservation stays a floor.
|
||||
func TestARebuildReservesAboveTheCatalogsHighestWhateverItsStandingNumberWas(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
for _, c := range []struct {
|
||||
name, standing, standingFp string
|
||||
want string
|
||||
}{
|
||||
{name: "standing below the catalog's highest", standing: "0.1.0", standingFp: "fp", want: "0.1.17"},
|
||||
{name: "standing above the catalog's highest", standing: "0.1.30", standingFp: "fp", want: "0.1.17"},
|
||||
{name: "another fingerprint's standing number stays a floor", standing: "0.1.30", standingFp: "other", want: "0.1.31"},
|
||||
} {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
store := &reserveMem{mem: newMem()}
|
||||
r := &Reserver{Store: store, Filled: func() bool { return true },
|
||||
ReleasedOf: func(context.Context, string) ([]string, error) { return []string{"0.1.16"}, nil }}
|
||||
raw, _ := json.Marshal(ReservedVersion{V: 1, Module: "m", Series: "0.1", Version: c.standing, Fingerprint: c.standingFp, Artifacts: map[string]string{"m:a": "d"}})
|
||||
if _, err := store.Create(ctx, ReservedKey("m", "0.1"), raw); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var took []string
|
||||
r.Took = func(_ context.Context, older, newer ReservedVersion) {
|
||||
took = append(took, older.Version+">"+newer.Version)
|
||||
}
|
||||
got, err := r.Reserve(ctx, "m", "0.1", []string{"m:a"}, Source{Fingerprint: "fp", Rebuild: true})
|
||||
if err != nil || got.Version != c.want || len(took) != 1 || took[0] != c.standing+">"+c.want {
|
||||
t.Fatalf("reserved %q (%v), took %v; want %s replacing %s", got.Version, err, took, c.want, c.standing)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user