From b305a5f08cf045ff2340a5f3e1f6aaed7ee9614e Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 01:13:44 +0100 Subject: [PATCH] Revert: the registry seats still hold versions; the engine asks it again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The resolved definitions of oci-artifact-registry and container-image-registry on mesh-delivery feat/47-H2 (42788501) both still hold versions, from the registry part they include; D4a (ac99946f) only gave list a module filter and a cursor. The validator's refusal came from a request that did not resolve the includes, so nothing the definitions hold is changed: this reverts 845de026. Builds: design 47 H2 §813 (7); H-A-415 (2) and its addendum --- internal/nodegrant/testdata/node.json | 4 +- internal/selfcompose/selfcompose_test.go | 10 +-- internal/selfcompose/versions.go | 94 ++++++++---------------- internal/selfcompose/versions_test.go | 31 +++----- module.json | 6 +- 5 files changed, 50 insertions(+), 95 deletions(-) diff --git a/internal/nodegrant/testdata/node.json b/internal/nodegrant/testdata/node.json index 8ef3e900..e31dcc1c 100644 --- a/internal/nodegrant/testdata/node.json +++ b/internal/nodegrant/testdata/node.json @@ -117,14 +117,14 @@ "mesh.control.NODE.>", "mesh.seat.mesh-catalog.call.entry.node~NODE", "mesh.seat.mesh-catalog.call.module.node~NODE", - "mesh.seat.container-image-registry.call.list.node~NODE", + "mesh.seat.container-image-registry.call.versions.node~NODE", "mesh.seat.mesh-catalog.call.revision.node~NODE", "mesh.seat.mesh-grants.call.withheld.node~NODE", "mesh.seat.mesh-module-assigner.call.assignments.node~NODE", "mesh.seat.mesh-recovery.call.kept-points.node~NODE", "mesh.seat.mesh-recovery.call.restore-kept.node~NODE", "mesh.seat.mesh-recovery.call.snapshot-kept.node~NODE", - "mesh.seat.oci-artifact-registry.call.list.node~NODE", + "mesh.seat.oci-artifact-registry.call.versions.node~NODE", "mesh.seat.mesh-catalog.call.seat-definitions.node~NODE", "mesh.seat.node-backup.call.backed-up.NODE.node~NODE", "mesh.seat.node-backup.call.now.NODE.node~NODE", diff --git a/internal/selfcompose/selfcompose_test.go b/internal/selfcompose/selfcompose_test.go index 4126f872..69d67094 100644 --- a/internal/selfcompose/selfcompose_test.go +++ b/internal/selfcompose/selfcompose_test.go @@ -470,8 +470,8 @@ func testTheNodeComposesItsWantsFromTheBus(t *testing.T) { // resolves the digests). e.Registry = EntryCall(func(_ context.Context, seat, _ string, args any) (json.RawMessage, error) { if seat == "container-image-registry" && args.(map[string]string)["name"] == "de-spiegel/site" { - return json.RawMessage(`{"repositories":[{"name":"de-spiegel/site","manifests":[{"digest":"sha256:` + - strings.Repeat("6", 64) + `","tags":["1"]}]}]}`), nil + return json.RawMessage(`{"name":"de-spiegel/site","versions":[{"name":"de-spiegel/site","kind":"image","digest":"sha256:` + + strings.Repeat("6", 64) + `","version":"1"}]}`), nil } return nil, errors.New("not held") }) @@ -1119,9 +1119,9 @@ func testTheNodeComposesItsWantsFromTheBus(t *testing.T) { catalogEntries[artFp] = artEntry // art's files archive at version 1, which the candidate "art-with" names (the candidate's version, never a digest). senv.Registry = EntryCall(func(_ context.Context, seat, _ string, args any) (json.RawMessage, error) { - if seat == "oci-artifact-registry" && args.(map[string]string)["module"] == "art" { - return json.RawMessage(`{"repositories":[{"name":"art/files","manifests":[{"digest":"sha256:` + strings.Repeat("8", 64) + - `","artifact":"sha256:` + strings.Repeat("9", 64) + `","tags":["1"]}]}]}`), nil + if seat == "oci-artifact-registry" && args.(map[string]string)["name"] == "art/files" { + return json.RawMessage(`{"name":"art/files","versions":[{"name":"art/files","kind":"archive","digest":"sha256:` + + strings.Repeat("9", 64) + `","version":"1"}]}`), nil } return nil, errors.New("not held") }) diff --git a/internal/selfcompose/versions.go b/internal/selfcompose/versions.go index 610f6601..0e4ddae3 100644 --- a/internal/selfcompose/versions.go +++ b/internal/selfcompose/versions.go @@ -19,7 +19,7 @@ import ( // **A want names its version; the node-engine resolves the digests** (design 47 G A-430, A-430a, the lead's answer A-430b). // A want of a released build names the module's version and no parts: each artifact of the build's entry is looked up at that -// version through the verb `list` of the registry seat of its kind (oci-artifact-registry for a bundle or an archive, +// version through the verb `versions` of the registry seat of its kind (oci-artifact-registry for a bundle or an archive, // container-image-registry for an image), under the name the builder numbered it by: `/`, or the entry's // package name for a package. An upstream copy is not numbered (it is mirrored by its pinned digest): its digest is the one its // manifest's `from` pins. A want that names parts (a build no version is known of) is read by its parts as before. A lookup that @@ -37,12 +37,8 @@ func (c *Composer) resolveAgain() time.Duration { return DefaultResolveAgain } -// listVerb is the verb a lookup asks: the registry seats read a version through `list`, filtered by module on -// oci-artifact-registry (design 47 H2 §813 (7), DMC-10, H-A-415 (2)). -const listVerb = "list" - -// listPagesMost bounds the pages one lookup reads of a seat's list. -const listPagesMost = 64 +// versionsVerb is the verb a lookup asks. +const versionsVerb = "versions" // resolvedKey names one resolution: a module's build at a version. type resolvedKey struct{ module, fp, version string } @@ -57,21 +53,13 @@ type versionParts struct { forgotten bool } -// registryList is the answer of either seat's verb `list` (form 2): each repository with the manifests it holds, each -// manifest's digest, the blob it keeps (a bundle's or an archive's) and the tags naming it; capped with next when the rest -// is on another page. -type registryList struct { - Repositories []struct { - Name string `json:"name"` - Manifests []struct { - Digest string `json:"digest"` - Artifact string `json:"artifact,omitempty"` - Tags []string `json:"tags,omitempty"` - } `json:"manifests"` - } `json:"repositories"` - Capped bool `json:"capped,omitempty"` - Total int64 `json:"total,omitempty"` - Next string `json:"next,omitempty"` +// registryVersions is the answer of either seat's verb `versions`: the two seats answer the same shape. +type registryVersions struct { + Versions []struct { + Digest string `json:"digest"` + Tag string `json:"tag,omitempty"` + Version string `json:"version,omitempty"` + } `json:"versions"` } // seatOfKind is the registry seat an artifact of kind is numbered in, and whether one is (design 51 *The seats*). @@ -230,7 +218,7 @@ func (c *Composer) lookUp(module string, e meshcatalog.CatalogEntry, w meshwants fail("(none)", a.Ref, "no registry seat the node-engine reads numbers an artifact of kind "+a.Kind) continue } - digest, why := c.versionDigest(seat, module, registryName(module, a), w) + digest, why := c.versionDigest(seat, registryName(module, a), w) if why != "" { fail(seat, a.Ref, why) continue @@ -244,52 +232,30 @@ func (c *Composer) lookUp(module string, e meshcatalog.CatalogEntry, w meshwants return parts, "" } -// versionDigest is the digest the seat's verb list answers for the repository name at w's version, a tag naming it: a -// version names one build (A-430a). oci-artifact-registry is asked for the module's repositories (`list {module}`) and -// answers the blob a manifest keeps, the digest a bundle or an archive is fetched by; container-image-registry, whose list -// takes no module, is asked for the repository by its name and answers the image manifest's digest. Every page is read -// while the answer says next (design 47 H2 §779, §813 (7), H-A-415 (2)). -func (c *Composer) versionDigest(seat, module, name string, w meshwants.WantsByWantNodeModuleValue) (string, string) { +// versionDigest is the digest the seat's verb versions answers for name at w's version (its version or its tag), the newest +// first: a version names one build (A-430a), so the version alone is matched. +func (c *Composer) versionDigest(seat, name string, w meshwants.WantsByWantNodeModuleValue) (string, string) { if c.env.Registry == nil { return "", "this node-engine reads no registry seat" } - in := map[string]string{"name": name} - if seat == ociartifactregistry.Seat { - in = map[string]string{"module": module} + raw, err := c.env.Registry("seat:"+seat+"."+versionsVerb, map[string]string{"name": name}) + if err != nil { + return "", fmt.Sprintf("the call for %s failed: %v", name, err) } - for page := 0; page < listPagesMost; page++ { - raw, err := c.env.Registry("seat:"+seat+"."+listVerb, in) - if err != nil { - return "", fmt.Sprintf("the call for %s failed: %v", name, err) - } - answer, said, ok := buscalls.Unwrap(raw) - if !ok { - return "", fmt.Sprintf("the seat refused %s: %s", name, said) - } - var l registryList - if err := json.Unmarshal(answer, &l); err != nil { - return "", fmt.Sprintf("its answer for %s cannot be read: %v", name, err) - } - for _, r := range l.Repositories { - if r.Name != name { - continue - } - for _, m := range r.Manifests { - if !slices.Contains(m.Tags, w.Version) || m.Digest == "" { - continue - } - if seat == ociartifactregistry.Seat && m.Artifact != "" { - return m.Artifact, "" - } - return m.Digest, "" - } - } - if l.Next == "" { - return "", fmt.Sprintf("it holds no version %s of %s", w.Version, name) - } - in["next"] = l.Next + answer, said, ok := buscalls.Unwrap(raw) + if !ok { + return "", fmt.Sprintf("the seat refused %s: %s", name, said) } - return "", fmt.Sprintf("its list of %s did not end within %d pages", module, listPagesMost) + var v registryVersions + if err := json.Unmarshal(answer, &v); err != nil { + return "", fmt.Sprintf("its answer for %s cannot be read: %v", name, err) + } + for _, a := range v.Versions { + if (a.Version == w.Version || a.Tag == w.Version) && a.Digest != "" { + return a.Digest, "" + } + } + return "", fmt.Sprintf("it holds no version %s of %s", w.Version, name) } // pinnedDigest is the digest the manifest's upstream artifact pins in its from (`@sha256:`); "" when none. diff --git a/internal/selfcompose/versions_test.go b/internal/selfcompose/versions_test.go index 1c22e10a..9b2fa862 100644 --- a/internal/selfcompose/versions_test.go +++ b/internal/selfcompose/versions_test.go @@ -36,13 +36,11 @@ func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) { }}} entry := meshcatalog.CatalogEntry{Module: "mail", Fp: fp, Manifest: manifest, Artifacts: []meshcatalog.Artifact{ {Ref: "mail:server", Kind: "upstream"}, {Ref: "mail:files", Kind: "archive"}, {Ref: "mail:web", Kind: "image"}}} - // The seats hold mail/files and mail/web, each version a tag of its manifest; an archive's blob is what it is fetched - // by (design 47 H2 §813 (7), H-A-415 (2): the version is read through list). + // The seats hold mail/files and mail/web; versions newest first. held := map[string]string{ - "oci-artifact-registry.mail/files": `{"name":"mail/files","manifests":[{"digest":"` + d("8") + `","artifact":"` + d("2") + - `","tags":["1.3.0"]},{"digest":"` + d("7") + `","artifact":"` + d("1") + `","tags":["1.2.3"]}]}`, - "container-image-registry.mail/web": `{"name":"mail/web","manifests":[{"digest":"` + d("3") + `","tags":["1.2.3"]}]}`, - "container-image-registry.mail/other": `{"name":"mail/other","manifests":[]}`, + "oci-artifact-registry.mail/files": `{"name":"mail/files","versions":[{"name":"mail/files","kind":"archive","digest":"` + d("2") + `","version":"1.3.0"},{"name":"mail/files","kind":"archive","digest":"` + d("1") + `","version":"1.2.3"}]}`, + "container-image-registry.mail/web": `{"name":"mail/web","versions":[{"name":"mail/web","kind":"image","digest":"` + d("3") + `","version":"1.2.3"}]}`, + "container-image-registry.mail/other": `{"name":"mail/other","versions":[]}`, } for name, row := range map[string]struct { want meshwants.WantsByWantNodeModuleValue @@ -64,25 +62,17 @@ func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) { calls := 0 env.Registry = EntryCall(func(_ context.Context, seat, verb string, args any) (json.RawMessage, error) { calls++ - in := args.(map[string]string) - // oci-artifact-registry is asked by the module, container-image-registry by the repository's name. - if verb != "list" || (seat == "oci-artifact-registry") != (in["module"] == "mail" && in["name"] == "") { - t.Errorf("%s: asked %s.%s %v", name, seat, verb, in) + if verb != "versions" { + t.Errorf("%s: asked %s.%s", name, seat, verb) } if seat == row.down { return nil, errors.New("no responders") } - var repos []string - for key, repo := range held { - r, ok := strings.CutPrefix(key, seat+".") - if ok && (r == in["name"] || (in["module"] != "" && strings.HasPrefix(r, in["module"]+"/"))) { - repos = append(repos, repo) - } - } - if len(repos) == 0 { + answer, ok := held[seat+"."+args.(map[string]string)["name"]] + if !ok { return nil, errors.New("not held") } - return json.RawMessage(`{"repositories":[` + strings.Join(repos, ",") + `]}`), nil + return json.RawMessage(answer), nil }) env.Entry = EntryCall(func(context.Context, string, string, any) (json.RawMessage, error) { return nil, errors.New("not asked") @@ -321,8 +311,7 @@ func aResolutionWhoseFetchFailedIsForgotten(t *testing.T) { calls := 0 env.Registry = EntryCall(func(context.Context, string, string, any) (json.RawMessage, error) { calls++ - return json.RawMessage(`{"repositories":[{"name":"mail/files","manifests":[{"digest":"sha256:` + strings.Repeat("e", 64) + - `","artifact":"` + row.answer + `","tags":["1.2.3"]}]}]}`), nil + return json.RawMessage(`{"versions":[{"digest":"` + row.answer + `","version":"1.2.3"}]}`), nil }) env.Fetch = func(context.Context, string) ([]byte, error) { return body, row.fetch } env.Entry = EntryCall(func(context.Context, string, string, any) (json.RawMessage, error) { diff --git a/module.json b/module.json index ee50160c..4db1dbac 100644 --- a/module.json +++ b/module.json @@ -46,7 +46,7 @@ } ], "invokes": [ - "seat:container-image-registry.list", + "seat:container-image-registry.versions", "seat:mesh-catalog.entry", "seat:mesh-catalog.module", {"verb": "seat:mesh-catalog.revision", "fields": ["none-yet"]}, @@ -57,7 +57,7 @@ "seat:mesh-recovery.restore-kept", "seat:mesh-recovery.snapshot-kept", "seat:node-packet-filter.allowed", - "seat:oci-artifact-registry.list" + "seat:oci-artifact-registry.versions" ], "consumes": [ "mesh-catalog.catalog-revision", @@ -126,7 +126,7 @@ }, "resolve-again-minutes": { "type": "number", - "description": "How long the node-engine holds a module whose want's version it could not resolve to its artifacts' digests, or whose resolution it forgot after a failed fetch, before it asks the registry seats' verb list again, in minutes (design 47 H, H-A-146).", + "description": "How long the node-engine holds a module whose want's version it could not resolve to its artifacts' digests, or whose resolution it forgot after a failed fetch, before it asks the registry seats' verb versions again, in minutes (design 47 H, H-A-146).", "minimum": 1, "maximum": 60, "default": 1