diff --git a/internal/compose/render.go b/internal/compose/render.go index 09d9b7be..194c3da2 100644 --- a/internal/compose/render.go +++ b/internal/compose/render.go @@ -125,6 +125,16 @@ func (c *composer) render(nodeName string, mode Mode) (Rendered, error) { } } + // A module that fetches from an artifact store with no known address waits for it; the machine composes the rest (A-461). + for module, why := range placed.storeHeld { + if r.NotPlaced == nil { + r.NotPlaced = map[string]string{} + } + if _, said := r.NotPlaced[module]; !said { + r.NotPlaced[module] = why + } + } + // And a certificate for this machine's name inside the mesh, when anything on it asks. for _, m := range plan.Modules { if m.Certificate == nil { diff --git a/internal/compose/rendering.go b/internal/compose/rendering.go index 4bdd41c5..a4cf400e 100644 --- a/internal/compose/rendering.go +++ b/internal/compose/rendering.go @@ -10,6 +10,7 @@ import ( "git.novox.be/novox/mesh-networking/modules/mesh-wireguard/go/overlay" "git.novox.be/novox/mesh-sdk/go/catalogue" "github.com/novox/mesh-host/internal/compose/resolution" + "github.com/novox/mesh-host/internal/registryforms" ) // The contracts of the node-engine's statement that gate what a machine is sent, as the controller's link package names them @@ -41,6 +42,8 @@ type Placed struct { // manifest's own number as the Reading mode composes them, and never invented. The controller's adapter allocates and // composes again. ForeseenPorts []string + // storeHeld are the modules left out of the declaration because the artifact store has no known address, and why (A-461). + storeHeld map[string]string } // Places composes the place half of the rendering for a node (the controller's renderingFor in the Reading and Foreseeing modes, @@ -92,9 +95,12 @@ func (c *composer) places(nodeName string, resolved Resolved) (Placed, error) { r.MeshRange = c.overlayRange() // The artifact store as this node reaches it now, with what the mesh has built. + // Where no address is known (the holder opens no listen to the mesh, or two), only the modules that fetch from the store + // wait, with the words of an unanswered requirement; the node composes the rest (design 47 G A-461, A-452). store, err := c.artifactStoreAddress(nodeName) if err != nil { - return out, err + out.storeHeld = modulesNeedingTheStore(plan.Modules, err) + store = "" } r.ArtifactStore = store r.Built = make(map[string]bool, len(c.in.Built)) @@ -327,6 +333,29 @@ func (c *composer) namesInTheMesh() map[string]string { return out } +// modulesNeedingTheStore are the modules with a resource whose image or source is a kept reference into the artifact store, each +// with why it waits: nothing provides the store's address (A-461). +func modulesNeedingTheStore(modules []catalogue.Manifest, why error) map[string]string { + out := map[string]string{} + for _, m := range modules { + for _, res := range m.Resources { + needs := false + for _, key := range []string{"image", "source"} { + if written, ok := res[key].(string); ok { + if _, kept := registryforms.Forms.InArtifactStore(written); kept { + needs = true + } + } + } + if needs { + out[m.Module] = fmt.Sprintf("nothing provides %q, wanted by %s: %v", "the artifact store's address", m.Module, why) + break + } + } + } + return out +} + // StoreSeat is the seat whose holder is the artifact store (novox/hq ADR 0632 ยง1): the store's address is that holder's // listen open to the mesh, on the machine assignment puts it on. The provision artifact-store it was found by before is // retired; no module serves it. diff --git a/internal/compose/rendering_test.go b/internal/compose/rendering_test.go index 78d7a793..806c8c7f 100644 --- a/internal/compose/rendering_test.go +++ b/internal/compose/rendering_test.go @@ -351,8 +351,22 @@ func TestTheStoreIsFoundByTheImageSeatsHolderAndItsListen(t *testing.T) { m := in.Catalogue["registry"] m.Listens = append(m.Listens, catalogue.Listening{Name: "other", Port: 5300, From: catalogue.FromMesh}) in.Catalogue["registry"] = m - if _, err := Places(in, "laptop"); err == nil || !strings.Contains(err.Error(), "opens registry (5000), other (5300) to the mesh") { - t.Errorf("a holder opening two listens to the mesh: %v", err) + // A-461: a store with no known address (two listens open to the mesh, so none is a guess) costs the modules that fetch from + // it, not the node: those wait with the words of an unanswered requirement, and the node composes the rest. + in.Catalogue["app"] = catalogue.Manifest{Module: "app", Version: "1", + Resources: []map[string]any{{"id": "c", "type": "container", "name": "app", "image": "artifact-store://app/c@sha256:" + strings.Repeat("a", 64)}}} + in.Catalogue["plain"] = catalogue.Manifest{Module: "plain", Version: "1"} + laptop := nodeOf(t, &in, "laptop") + laptop.Assigned = append(laptop.Assigned, "app", "plain") + got, err := Render(in, "laptop", Reading) + if err != nil { + t.Fatalf("a holder opening two listens to the mesh refuses the whole node: %v", err) + } + if why := got.Rendering.NotPlaced["app"]; !strings.Contains(why, "nothing provides") || !strings.Contains(why, "opens registry (5000), other (5300) to the mesh") { + t.Errorf("the module that fetches from the store waits with %q", why) + } + if why, held := got.Rendering.NotPlaced["plain"]; held { + t.Errorf("a module that fetches nothing from the store waits: %q", why) } }