diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go index a0f2bb829..839891b0e 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go @@ -36,6 +36,7 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/ociartifactregistry" sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" runner "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun" + "git.novox.be/novox/mesh-sdk/go/buscalls" "git.novox.be/novox/mesh-sdk/go/buscompose" "git.novox.be/novox/mesh-sdk/go/process" "git.novox.be/novox/mesh-sdk/go/seatdef" @@ -89,6 +90,34 @@ type fakeBuildModules struct { // hang, while it holds a channel, keeps every build step running until the channel is closed: a step that never ends, // so the builder's step bound runs out (design 51's round-2 case). hang atomic.Pointer[chan struct{}] + // big, while set, keeps every passed step's answer as its answer object, as one over what the steps state holds per value + // is kept, handed through the build seat's verb answer in chunks (design 47 H2 H-A-412); answers holds those objects by name. + big atomic.Bool + answers sync.Map +} + +// serveAnswers answers the verb answer of the seat node-build-go on every node as the build module's holder does: the +// answer object the ask's step key names, in chunks (design 47 H2 H-A-412). +func (f *fakeBuildModules) serveAnswers(t *testing.T, nc *nats.Conn) { + sub, err := nc.Subscribe("mesh.seat.node-build-go.call.answer.>", func(m *nats.Msg) { + var in struct{ Ask, Call string } + _ = json.Unmarshal(m.Data, &in) + body, ok := f.answers.Load(sdkstep.AnswerObjectName(in.Ask)) + if !ok { + _ = m.Respond([]byte(`{"error":{"kind":"not-found","message":"no answer of ` + in.Ask + `"}}`)) + return + } + of := (len(body.([]byte)) + buscalls.SeatChunkBytes - 1) / buscalls.SeatChunkBytes + answer, _ := json.Marshal(map[string]any{"result": map[string]any{"ask": in.Ask, "chunks": of}}) + _ = m.Respond(answer) + go func() { + _ = buscalls.SeatChunks{Seat: "node-build-go", Verb: "answer", Call: in.Call}.Send(nc, body.([]byte), buscalls.SeatAckWithin, t.Logf) + }() + }) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = sub.Unsubscribe() }) } // open lets the nodes pull again and wakes their pullers. @@ -173,6 +202,16 @@ func (f *fakeBuildModules) serve(t *testing.T, module string, nodes ...string) { // both forms overlaps the named worker, which a work queue refuses. put := func(key string, value any) (uint64, error) { raw, _ := value.(json.RawMessage) + // big: an ended step's answer is kept as its answer object and the key names it, as the build module's step run keeps + // an answer over what the steps state holds per value (steprun's keepOver; design 47 G A-290, H2 H-A-412). + if step, err := sdkstep.DecodeStep(raw); f.big.Load() && err == nil && step.State == sdkstep.StepPassed && len(step.Result) > 0 { + object := sdkstep.AnswerObjectName(step.ID) + f.answers.Store(object, []byte(step.Result)) + step.Result, step.AnswerObject = nil, object + if raw, err = sdkstep.EncodeStep(step); err != nil { + return 0, err + } + } return kv.Put(f.ctx, key, raw) } call := func(name string) runner.StepFunc { @@ -328,6 +367,7 @@ func startBedWith(t *testing.T, closed bool) *bed { b.fake.serve(t, "mesh-build-go", "n1", "n2") b.fake.serve(t, "mesh-build-node", "n1", "n2") b.fake.serve(t, "mesh-build-image", "n1") // the image build module runs on n1 only + b.fake.serveAnswers(t, ctl) b.report(t, "mesh-build-go", "n1", "go", "go1.27.1", "1") b.report(t, "mesh-build-go", "n2", "go", "go1.27.1", "1") b.report(t, "mesh-build-node", "n1", "typescript", "tsc5", "1") @@ -700,10 +740,13 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7 func TestAnArchiveOnlyModuleAndARootModuleAreBuilt(t *testing.T) { for _, c := range []struct { name, path string - two bool - }{{"no toolchain", "modules/ca-trust", false}, {"root", meshcatalogclient.RootPath, false}, {"two instances together", "modules/ca-trust", true}} { + two, big bool + }{{"no toolchain", "modules/ca-trust", false, false}, {"root", meshcatalogclient.RootPath, false, false}, {"two instances together", "modules/ca-trust", true, false}, + // Design 47 H2 H-A-412: a build step's end over what the steps state holds is read through the seat's verb answer. + {"an answer over the steps state", "modules/ca-trust", false, true}} { t.Run(c.name, func(t *testing.T) { b := startBed(t) + b.fake.big.Store(c.big) b.archive(t, "ca-trust", c.path, commit) b.start(t, "n1", nil) if c.two { @@ -713,7 +756,7 @@ func TestAnArchiveOnlyModuleAndARootModuleAreBuilt(t *testing.T) { if c.name == "no toolchain" && (len(v.Toolchains) != 0 || len(v.Artifacts) != 1 || strings.HasPrefix(v.Step, "one node (")) { t.Errorf("build = %+v, want done naming no toolchain", v) } - if c.two && (len(v.Artifacts) != 1 || v.Artifacts[0].Kind != "archive" || v.Artifacts[0].Digest != digestOf("files")) { + if (c.two || c.big) && (len(v.Artifacts) != 1 || v.Artifacts[0].Kind != "archive" || v.Artifacts[0].Digest != digestOf("files")) { t.Errorf("build = %+v, want the archive's digest", v) } if n := b.fake.count("mesh-build-go.build_go_build"); c.two && n < 1 { // each instance that built, on one node diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go index 6f667f13f..09e4f7623 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go @@ -192,7 +192,10 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro Claimer: build.Claimer{Store: kvStore{buildsKV}, By: cred.Node + "." + cred.Module}, Seats: seats, Asks: buildrun.Asker{Name: meshbuilds.Seat, Seats: seats, Publisher: asks, Waiter: buildrun.LostAskWaiter{Inner: heard, Dead: dead, Hearing: hearing}, Bound: bound, Dropper: buildrun.SeatDrops{Caller: calls}, - Bounds: &stepBounds{bounds: pubBoundsKV.KV, js: js, now: time.Now, logf: logger.Printf}, Expiry: stepExpiry}, + Bounds: &stepBounds{bounds: pubBoundsKV.KV, js: js, now: time.Now, logf: logger.Printf}, Expiry: stepExpiry, + // Design 47 H2 H-A-412: a step's end over what the steps state holds is read through its build seat's verb answer, in + // chunks (process.Conn.CallFile, the chunked-call form), on the node that ran it. + Outputs: calls.CallFile}, Held: heldOnTheBus{js: js, seats: seats}, // An ask that can no longer be answered is asked again (issue 1945), read at the step bound: a context's bound. Gone: heldOnTheBus{js: js, seats: seats}, diff --git a/modules/mesh-delivery-builder/manifest_test.go b/modules/mesh-delivery-builder/manifest_test.go index 9c6fa84ed..a37f030e9 100644 --- a/modules/mesh-delivery-builder/manifest_test.go +++ b/modules/mesh-delivery-builder/manifest_test.go @@ -146,7 +146,7 @@ func TestManifestDeclarations(t *testing.T) { // 1607/AC1 // The watchdogs seat's presence says a node's machine is heard (issue 1966, ADR 0596 §2, ADR 0668 §3). if want := []string{"seat:mesh-catalog.entry", "seat:mesh-catalog.registrations", "seat:mesh-catalog.seat-definitions", "seat:mesh-catalog.revision", "seat:mesh-delivery.source", "seat:container-image-registry.publish", "seat:container-image-registry.remove", "seat:container-image-registry.versions", "seat:git.tag", "seat:git.tags", - "seat:go-package-registry.publish", "seat:go-package-registry.remove", "seat:go-package-registry.versions", "seat:mesh-artifact-sweep.held", "seat:mesh-builds.reserved", "seat:mesh-builds.drop", "seat:mesh-catalog.versions", "seat:mesh-hand-acts.hand-act", "seat:mesh-module-assigner.assignments", "seat:mesh-watchdogs.presence", "seat:node-build-go.drop", "seat:node-build-image.drop", "seat:node-build-node.drop", "seat:node-engine.manifest-reads", "seat:npm-package-registry.publish", "seat:npm-package-registry.remove", + "seat:go-package-registry.publish", "seat:go-package-registry.remove", "seat:go-package-registry.versions", "seat:mesh-artifact-sweep.held", "seat:mesh-builds.reserved", "seat:mesh-builds.drop", "seat:mesh-catalog.versions", "seat:mesh-hand-acts.hand-act", "seat:mesh-module-assigner.assignments", "seat:mesh-watchdogs.presence", "seat:node-build-go.drop", "seat:node-build-image.drop", "seat:node-build-node.drop", "seat:node-build-go.answer", "seat:node-build-image.answer", "seat:node-build-node.answer", "seat:node-engine.manifest-reads", "seat:npm-package-registry.publish", "seat:npm-package-registry.remove", "seat:npm-package-registry.versions", "seat:oci-artifact-registry.publish", "seat:oci-artifact-registry.remove", "seat:oci-artifact-registry.versions", // A-231: the build asks on each build seat's queue delivery (accept.delivery.). "seat:node-build-go.accept.delivery", "seat:node-build-node.accept.delivery", "seat:node-build-image.accept.delivery"}; !reflect.DeepEqual(sorted(m.Invokes), sorted(want)) { diff --git a/modules/mesh-delivery-builder/module.json b/modules/mesh-delivery-builder/module.json index 709ebe62f..68322d55e 100644 --- a/modules/mesh-delivery-builder/module.json +++ b/modules/mesh-delivery-builder/module.json @@ -100,6 +100,9 @@ "seat:node-build-go.drop", "seat:node-build-image.drop", "seat:node-build-node.drop", + "seat:node-build-go.answer", + "seat:node-build-image.answer", + "seat:node-build-node.answer", "seat:node-engine.manifest-reads", "seat:npm-package-registry.remove", "seat:npm-package-registry.versions",