fix9b2-1b: FollowAssignmentsIn takes the bucket; FollowAssignments keeps the fixed one for the checker, which another change owns

Builds: design 47 G A-119
This commit is contained in:
2026-11-12 01:32:40 +01:00
parent f299a1a8b9
commit 9757688f56
4 changed files with 12 additions and 5 deletions
@@ -125,11 +125,18 @@ func (g *ToolchainGate) placedTold() {
}
}
// FollowAssignments reads the seat mesh-module-assigner's assignments, in bucket (the seat's holder found at run time, `<holder>_assignments`; design 47 G A-119), with its history into gate, says it settled, and follows it; changed
// FollowAssignments reads the seat mesh-module-assigner's assignments with its history into gate, says it settled, and follows it; changed
// is told whenever what the gate passes on changed. Where the state cannot be read or watched (not there, or this part
// may not read it) it says so and the gate passes every report on: not fatal, since an indexer, builder or checker that
// stops for it stops every delivery (issue 1945). An error of the watch after that ends on the channel.
func FollowAssignments(ctx context.Context, js process.BucketOpener, bucket string, gate assignmentsFollowed, changed func(context.Context), logf func(string, ...any)) (<-chan error, error) {
func FollowAssignments(ctx context.Context, js process.BucketOpener, gate assignmentsFollowed, changed func(context.Context), logf func(string, ...any)) (<-chan error, error) {
return FollowAssignmentsIn(ctx, js, AssignmentsBucket, gate, changed, logf)
}
// FollowAssignmentsIn is FollowAssignments for the state in bucket, the holder's `<holder>_assignments` where the holder is found at
// run time (design 47 G A-119): the builder follows it so; FollowAssignments, with the fixed bucket, is the checker's until its own
// change finds the holder.
func FollowAssignmentsIn(ctx context.Context, js process.BucketOpener, bucket string, gate assignmentsFollowed, changed func(context.Context), logf func(string, ...any)) (<-chan error, error) {
errs := make(chan error, 1)
kv, err := js.KeyValue(ctx, bucket)
if err != nil {
@@ -86,7 +86,7 @@ func TestPlacedNodes(t *testing.T) {
refused := errors.New("nats: permissions violation for publish to $JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments")
gate := NewPlacedNodes(logger.Printf)
for _, bus := range []refusingBus{{err: refused}, {refuseOpen: true, err: refused}} {
if _, err := FollowAssignments(context.Background(), bus, AssignmentsBucket, gate, func(context.Context) {}, logger.Printf); err != nil {
if _, err := FollowAssignments(context.Background(), bus, gate, func(context.Context) {}, logger.Printf); err != nil {
t.Errorf("a refused assignments stopped the start: %v", err)
}
}
@@ -249,7 +249,7 @@ func TestToolchainGate(t *testing.T) {
refused := errors.New("nats: permissions violation for publish to $JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments")
gate, _, _ := start(t, false)
for _, bus := range []refusingBus{{err: refused}, {refuseOpen: true, err: refused}} {
if _, err := FollowAssignments(context.Background(), bus, AssignmentsBucket, gate, func(context.Context) {}, logger.Printf); err != nil {
if _, err := FollowAssignments(context.Background(), bus, gate, func(context.Context) {}, logger.Printf); err != nil {
t.Errorf("a refused assignments stopped the start: %v", err)
}
}
@@ -362,7 +362,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
return
case <-assignments.Follower().Ready():
}
pe, err := buildrun.FollowAssignments(ctx, reader, names.Bucket, gate, b.NodesChanged, logger.Printf)
pe, err := buildrun.FollowAssignmentsIn(ctx, reader, names.Bucket, gate, b.NodesChanged, logger.Printf)
if err != nil {
assignmentsErrs <- err
return