Builder: the finding version-unreleased is timed by publish-ack-minutes, the constant UnreleasedBound goes
Builds: design 47 H2 H-A-613 (3), principle 11
This commit is contained in:
@@ -235,6 +235,11 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
// heard (design 47 H2 H-A-552: no fill is waited for).
|
||||
reservedKV := process.AwaitBucket(ctx, js, conn, own.reserved, "no version is reserved: builds are made unreserved", logger.Printf)
|
||||
reserved := newReservations(awaitedReserved{awaitedState{b: reservedKV, bucket: own.reserved}}, calls.Call, pubBoundsKV.KV, found, logger.Printf)
|
||||
publishAck, err := numberFile(getenv("MESH_BUILDER_PUBLISH_ACK_FILE"), defaultPublishAckMinutes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
reserved.setBound(time.Duration(publishAck) * time.Minute) // the finding version-unreleased is timed by the same setting (H-A-613 (3))
|
||||
// The index by digest and by version beside the reservations is written again once the state is bound (H-A-269 (1), H-A-271).
|
||||
reservedKV.Ready(func(jetstream.KeyValue) { reserved.reindex(ctx) })
|
||||
// Each artifact the holder says published at a reserved version is said as the seat mesh-builds' package-published (design 47 G §52).
|
||||
@@ -289,10 +294,6 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
reserved.r.HeldElsewhere = func(ctx context.Context, module string, skipped []string) {
|
||||
reserved.heldElsewhere(ctx, module, "the registries hold "+strings.Join(skipped, ", ")+", so the reserve skipped them")
|
||||
}
|
||||
publishAck, err := numberFile(getenv("MESH_BUILDER_PUBLISH_ACK_FILE"), defaultPublishAckMinutes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
republishMax, err := numberFile(getenv("MESH_BUILDER_REPUBLISH_MAX_FILE"), versions.DefaultRepublishMaxVersions)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -119,7 +119,7 @@ func sayReservedOn(js jetstream.JetStream, cred process.Account) func(context.Co
|
||||
// newReservations makes the reserving over store; the released versions of a module are asked of the seat mesh-catalog's
|
||||
// verb versions through call (design 47 G §348), the only source numbering reads them from.
|
||||
func newReservations(store versions.ReserveStore, call toolCaller, bounds func() jetstream.KeyValue, found *findings, logf func(string, ...any)) *reservations {
|
||||
rv := &reservations{bounds: bounds, found: found, bound: versions.UnreleasedBound, logf: logf}
|
||||
rv := &reservations{bounds: bounds, found: found, bound: defaultPublishAckMinutes * time.Minute, logf: logf}
|
||||
rv.r = &versions.Reserver{Store: store, ReleasedOf: func(_ context.Context, module string) ([]string, error) {
|
||||
raw, err := call("seat:"+meshcatalog.Seat+".versions", meshcatalog.VersionsInput{Module: module})
|
||||
if err != nil {
|
||||
@@ -136,9 +136,17 @@ func newReservations(store versions.ReserveStore, call toolCaller, bounds func()
|
||||
return out, nil
|
||||
}}
|
||||
rv.r.Took, rv.r.Logf, rv.r.Reserved = rv.took, logf, rv.reservedSaid
|
||||
rv.setBound(rv.bound)
|
||||
return rv
|
||||
}
|
||||
|
||||
// setBound sets the publish's bound, the setting publish-ack-minutes (design 47 H2 H-A-613 (3)): past it a built reservation
|
||||
// with an artifact unpublished is the finding version-unreleased, armed and judged by this one value.
|
||||
func (rv *reservations) setBound(d time.Duration) {
|
||||
rv.bound = d
|
||||
rv.r.Bound = d
|
||||
}
|
||||
|
||||
// reindex writes the reservations' index again from the reservations, once at the builder's start (H-A-269 (1), H-A-271), and
|
||||
// says so.
|
||||
func (rv *reservations) reindex(ctx context.Context) {
|
||||
|
||||
@@ -495,13 +495,27 @@ func TestABuiltReservationIsTakenInFromItsState(t *testing.T) {
|
||||
if !slices.Equal(said, []string{"look:a@" + v.Version + " sha256:looka"}) || !slices.Equal(asked, []string{"look " + v.Version}) {
|
||||
t.Errorf("at a look: said %v, publish items asked %v; want look:a's package-published said and its item asked", said, asked)
|
||||
}
|
||||
if ends := boundEnds("look"); !ends.Equal(v.BuiltAt.Add(versions.UnreleasedBound)) {
|
||||
t.Errorf("the bound armed at a look ends %v, want %v: counted from the build's end", ends, v.BuiltAt.Add(versions.UnreleasedBound))
|
||||
if ends := boundEnds("look"); !ends.Equal(v.BuiltAt.Add(defaultPublishAckMinutes*time.Minute)) {
|
||||
t.Errorf("the bound armed at a look ends %v, want %v: counted from the build's end", ends, v.BuiltAt.Add(defaultPublishAckMinutes*time.Minute))
|
||||
}
|
||||
if cur, _, _ := rv.r.Of(ctx, "look", v.Version); len(cur.Kept) != 0 || !cur.Published["look:a"] {
|
||||
t.Errorf("after the look: kept %v, published %v; want the kept published taken in", cur.Kept, cur.Published)
|
||||
}
|
||||
})
|
||||
t.Run("at a look with publish-ack-minutes at 30", func(t *testing.T) {
|
||||
rv.setBound(30 * time.Minute)
|
||||
defer rv.setBound(defaultPublishAckMinutes * time.Minute)
|
||||
v := recordedLost("thirty", now.Add(-5*time.Minute), "a")
|
||||
if err := rv.Built(ctx, "thirty", v.Version, v.Artifacts, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if ends := boundEnds("thirty"); !ends.Equal(v.BuiltAt.Add(30 * time.Minute)) {
|
||||
t.Errorf("the bound armed ends %v, want %v: the setting's 30 minutes, not 10", ends, v.BuiltAt.Add(30*time.Minute))
|
||||
}
|
||||
if unreleased("thirty") != "" {
|
||||
t.Errorf("a build 5 minutes old raised %s with the bound at 30 minutes", unreleased("thirty"))
|
||||
}
|
||||
})
|
||||
t.Run("at the start", func(t *testing.T) {
|
||||
v := recordedLost("start", now.Add(-time.Minute), "a")
|
||||
said = nil
|
||||
@@ -516,7 +530,7 @@ func TestABuiltReservationIsTakenInFromItsState(t *testing.T) {
|
||||
t.Run("past its bound", func(t *testing.T) {
|
||||
for _, when := range []string{"a look", "the start"} {
|
||||
module := map[string]string{"a look": "pastlook", "the start": "paststart"}[when]
|
||||
v := recordedLost(module, now.Add(-versions.UnreleasedBound-time.Minute), "a")
|
||||
v := recordedLost(module, now.Add(-defaultPublishAckMinutes*time.Minute-time.Minute), "a")
|
||||
takeIn := func() {
|
||||
if when == "a look" {
|
||||
if err := rv.Built(ctx, module, v.Version, v.Artifacts, nil); err != nil {
|
||||
@@ -543,7 +557,7 @@ func TestABuiltReservationIsTakenInFromItsState(t *testing.T) {
|
||||
// Note 8's own case: every artifact's published kept on it is taken in before its bound is judged, so nothing is
|
||||
// unpublished and nothing is raised; each is said as package-published.
|
||||
module = map[string]string{"a look": "keptlook", "the start": "keptstart"}[when]
|
||||
v = recordedLost(module, now.Add(-versions.UnreleasedBound-time.Minute), "a", "b")
|
||||
v = recordedLost(module, now.Add(-defaultPublishAckMinutes*time.Minute-time.Minute), "a", "b")
|
||||
said = nil
|
||||
takeIn()
|
||||
if got := unreleased(module); got != "" {
|
||||
|
||||
Reference in New Issue
Block a user