Read a module's version through the registry seats' list
H2's registry seat definitions fold the version read into list, filtered by module, so the validator refused the engine's manifest for invoking versions. The engine reads a version as a tag in list: oci-artifact-registry by the module, every page while it says next, the blob a manifest keeps; container-image-registry, whose list takes no module, by the repository's name. The manifest invokes list, and the node grant the tests run under follows it. Builds: design 47 H2 §779, §813 (7); H-A-350 DMC-10, H-A-415 (2)
This commit is contained in:
+2
-2
@@ -117,14 +117,14 @@
|
|||||||
"mesh.control.NODE.>",
|
"mesh.control.NODE.>",
|
||||||
"mesh.seat.mesh-catalog.call.entry.node~NODE",
|
"mesh.seat.mesh-catalog.call.entry.node~NODE",
|
||||||
"mesh.seat.mesh-catalog.call.module.node~NODE",
|
"mesh.seat.mesh-catalog.call.module.node~NODE",
|
||||||
"mesh.seat.container-image-registry.call.versions.node~NODE",
|
"mesh.seat.container-image-registry.call.list.node~NODE",
|
||||||
"mesh.seat.mesh-catalog.call.revision.node~NODE",
|
"mesh.seat.mesh-catalog.call.revision.node~NODE",
|
||||||
"mesh.seat.mesh-grants.call.withheld.node~NODE",
|
"mesh.seat.mesh-grants.call.withheld.node~NODE",
|
||||||
"mesh.seat.mesh-module-assigner.call.assignments.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.kept-points.node~NODE",
|
||||||
"mesh.seat.mesh-recovery.call.restore-kept.node~NODE",
|
"mesh.seat.mesh-recovery.call.restore-kept.node~NODE",
|
||||||
"mesh.seat.mesh-recovery.call.snapshot-kept.node~NODE",
|
"mesh.seat.mesh-recovery.call.snapshot-kept.node~NODE",
|
||||||
"mesh.seat.oci-artifact-registry.call.versions.node~NODE",
|
"mesh.seat.oci-artifact-registry.call.list.node~NODE",
|
||||||
"mesh.seat.mesh-catalog.call.seat-definitions.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.backed-up.NODE.node~NODE",
|
||||||
"mesh.seat.node-backup.call.now.NODE.node~NODE",
|
"mesh.seat.node-backup.call.now.NODE.node~NODE",
|
||||||
|
|||||||
@@ -470,8 +470,8 @@ func testTheNodeComposesItsWantsFromTheBus(t *testing.T) {
|
|||||||
// resolves the digests).
|
// resolves the digests).
|
||||||
e.Registry = EntryCall(func(_ context.Context, seat, _ string, args any) (json.RawMessage, error) {
|
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" {
|
if seat == "container-image-registry" && args.(map[string]string)["name"] == "de-spiegel/site" {
|
||||||
return json.RawMessage(`{"name":"de-spiegel/site","versions":[{"name":"de-spiegel/site","kind":"image","digest":"sha256:` +
|
return json.RawMessage(`{"repositories":[{"name":"de-spiegel/site","manifests":[{"digest":"sha256:` +
|
||||||
strings.Repeat("6", 64) + `","version":"1"}]}`), nil
|
strings.Repeat("6", 64) + `","tags":["1"]}]}]}`), nil
|
||||||
}
|
}
|
||||||
return nil, errors.New("not held")
|
return nil, errors.New("not held")
|
||||||
})
|
})
|
||||||
@@ -1119,9 +1119,9 @@ func testTheNodeComposesItsWantsFromTheBus(t *testing.T) {
|
|||||||
catalogEntries[artFp] = artEntry
|
catalogEntries[artFp] = artEntry
|
||||||
// art's files archive at version 1, which the candidate "art-with" names (the candidate's version, never a digest).
|
// 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) {
|
senv.Registry = EntryCall(func(_ context.Context, seat, _ string, args any) (json.RawMessage, error) {
|
||||||
if seat == "oci-artifact-registry" && args.(map[string]string)["name"] == "art/files" {
|
if seat == "oci-artifact-registry" && args.(map[string]string)["module"] == "art" {
|
||||||
return json.RawMessage(`{"name":"art/files","versions":[{"name":"art/files","kind":"archive","digest":"sha256:` +
|
return json.RawMessage(`{"repositories":[{"name":"art/files","manifests":[{"digest":"sha256:` + strings.Repeat("8", 64) +
|
||||||
strings.Repeat("9", 64) + `","version":"1"}]}`), nil
|
`","artifact":"sha256:` + strings.Repeat("9", 64) + `","tags":["1"]}]}]}`), nil
|
||||||
}
|
}
|
||||||
return nil, errors.New("not held")
|
return nil, errors.New("not held")
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -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 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
|
// 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 `versions` of the registry seat of its kind (oci-artifact-registry for a bundle or an archive,
|
// version through the verb `list` 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: `<module>/<artifact>`, or the entry's
|
// container-image-registry for an image), under the name the builder numbered it by: `<module>/<artifact>`, 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
|
// 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
|
// 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,8 +37,12 @@ func (c *Composer) resolveAgain() time.Duration {
|
|||||||
return DefaultResolveAgain
|
return DefaultResolveAgain
|
||||||
}
|
}
|
||||||
|
|
||||||
// versionsVerb is the verb a lookup asks.
|
// listVerb is the verb a lookup asks: the registry seats read a version through `list`, filtered by module on
|
||||||
const versionsVerb = "versions"
|
// 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
|
||||||
|
|
||||||
// resolvedKey names one resolution: a module's build at a version.
|
// resolvedKey names one resolution: a module's build at a version.
|
||||||
type resolvedKey struct{ module, fp, version string }
|
type resolvedKey struct{ module, fp, version string }
|
||||||
@@ -53,13 +57,21 @@ type versionParts struct {
|
|||||||
forgotten bool
|
forgotten bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// registryVersions is the answer of either seat's verb `versions`: the two seats answer the same shape.
|
// registryList is the answer of either seat's verb `list` (form 2): each repository with the manifests it holds, each
|
||||||
type registryVersions struct {
|
// 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
|
||||||
Versions []struct {
|
// is on another page.
|
||||||
Digest string `json:"digest"`
|
type registryList struct {
|
||||||
Tag string `json:"tag,omitempty"`
|
Repositories []struct {
|
||||||
Version string `json:"version,omitempty"`
|
Name string `json:"name"`
|
||||||
} `json:"versions"`
|
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"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// seatOfKind is the registry seat an artifact of kind is numbered in, and whether one is (design 51 *The seats*).
|
// seatOfKind is the registry seat an artifact of kind is numbered in, and whether one is (design 51 *The seats*).
|
||||||
@@ -218,7 +230,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)
|
fail("(none)", a.Ref, "no registry seat the node-engine reads numbers an artifact of kind "+a.Kind)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
digest, why := c.versionDigest(seat, registryName(module, a), w)
|
digest, why := c.versionDigest(seat, module, registryName(module, a), w)
|
||||||
if why != "" {
|
if why != "" {
|
||||||
fail(seat, a.Ref, why)
|
fail(seat, a.Ref, why)
|
||||||
continue
|
continue
|
||||||
@@ -232,30 +244,52 @@ func (c *Composer) lookUp(module string, e meshcatalog.CatalogEntry, w meshwants
|
|||||||
return parts, ""
|
return parts, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// versionDigest is the digest the seat's verb versions answers for name at w's version (its version or its tag), the newest
|
// versionDigest is the digest the seat's verb list answers for the repository name at w's version, a tag naming it: a
|
||||||
// first: a version names one build (A-430a), so the version alone is matched.
|
// version names one build (A-430a). oci-artifact-registry is asked for the module's repositories (`list {module}`) and
|
||||||
func (c *Composer) versionDigest(seat, name string, w meshwants.WantsByWantNodeModuleValue) (string, string) {
|
// 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) {
|
||||||
if c.env.Registry == nil {
|
if c.env.Registry == nil {
|
||||||
return "", "this node-engine reads no registry seat"
|
return "", "this node-engine reads no registry seat"
|
||||||
}
|
}
|
||||||
raw, err := c.env.Registry("seat:"+seat+"."+versionsVerb, map[string]string{"name": name})
|
in := map[string]string{"name": name}
|
||||||
if err != nil {
|
if seat == ociartifactregistry.Seat {
|
||||||
return "", fmt.Sprintf("the call for %s failed: %v", name, err)
|
in = map[string]string{"module": module}
|
||||||
}
|
}
|
||||||
answer, said, ok := buscalls.Unwrap(raw)
|
for page := 0; page < listPagesMost; page++ {
|
||||||
if !ok {
|
raw, err := c.env.Registry("seat:"+seat+"."+listVerb, in)
|
||||||
return "", fmt.Sprintf("the seat refused %s: %s", name, said)
|
if err != nil {
|
||||||
}
|
return "", fmt.Sprintf("the call for %s failed: %v", name, err)
|
||||||
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, ""
|
|
||||||
}
|
}
|
||||||
|
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
|
||||||
}
|
}
|
||||||
return "", fmt.Sprintf("it holds no version %s of %s", w.Version, name)
|
return "", fmt.Sprintf("its list of %s did not end within %d pages", module, listPagesMost)
|
||||||
}
|
}
|
||||||
|
|
||||||
// pinnedDigest is the digest the manifest's upstream artifact pins in its from (`<image>@sha256:<hex>`); "" when none.
|
// pinnedDigest is the digest the manifest's upstream artifact pins in its from (`<image>@sha256:<hex>`); "" when none.
|
||||||
|
|||||||
@@ -36,11 +36,13 @@ func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) {
|
|||||||
}}}
|
}}}
|
||||||
entry := meshcatalog.CatalogEntry{Module: "mail", Fp: fp, Manifest: manifest, Artifacts: []meshcatalog.Artifact{
|
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"}}}
|
{Ref: "mail:server", Kind: "upstream"}, {Ref: "mail:files", Kind: "archive"}, {Ref: "mail:web", Kind: "image"}}}
|
||||||
// The seats hold mail/files and mail/web; versions newest first.
|
// 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).
|
||||||
held := map[string]string{
|
held := map[string]string{
|
||||||
"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"}]}`,
|
"oci-artifact-registry.mail/files": `{"name":"mail/files","manifests":[{"digest":"` + d("8") + `","artifact":"` + d("2") +
|
||||||
"container-image-registry.mail/web": `{"name":"mail/web","versions":[{"name":"mail/web","kind":"image","digest":"` + d("3") + `","version":"1.2.3"}]}`,
|
`","tags":["1.3.0"]},{"digest":"` + d("7") + `","artifact":"` + d("1") + `","tags":["1.2.3"]}]}`,
|
||||||
"container-image-registry.mail/other": `{"name":"mail/other","versions":[]}`,
|
"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":[]}`,
|
||||||
}
|
}
|
||||||
for name, row := range map[string]struct {
|
for name, row := range map[string]struct {
|
||||||
want meshwants.WantsByWantNodeModuleValue
|
want meshwants.WantsByWantNodeModuleValue
|
||||||
@@ -62,17 +64,25 @@ func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) {
|
|||||||
calls := 0
|
calls := 0
|
||||||
env.Registry = EntryCall(func(_ context.Context, seat, verb string, args any) (json.RawMessage, error) {
|
env.Registry = EntryCall(func(_ context.Context, seat, verb string, args any) (json.RawMessage, error) {
|
||||||
calls++
|
calls++
|
||||||
if verb != "versions" {
|
in := args.(map[string]string)
|
||||||
t.Errorf("%s: asked %s.%s", name, seat, verb)
|
// 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 seat == row.down {
|
if seat == row.down {
|
||||||
return nil, errors.New("no responders")
|
return nil, errors.New("no responders")
|
||||||
}
|
}
|
||||||
answer, ok := held[seat+"."+args.(map[string]string)["name"]]
|
var repos []string
|
||||||
if !ok {
|
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 {
|
||||||
return nil, errors.New("not held")
|
return nil, errors.New("not held")
|
||||||
}
|
}
|
||||||
return json.RawMessage(answer), nil
|
return json.RawMessage(`{"repositories":[` + strings.Join(repos, ",") + `]}`), nil
|
||||||
})
|
})
|
||||||
env.Entry = EntryCall(func(context.Context, string, string, any) (json.RawMessage, error) {
|
env.Entry = EntryCall(func(context.Context, string, string, any) (json.RawMessage, error) {
|
||||||
return nil, errors.New("not asked")
|
return nil, errors.New("not asked")
|
||||||
@@ -311,7 +321,8 @@ func aResolutionWhoseFetchFailedIsForgotten(t *testing.T) {
|
|||||||
calls := 0
|
calls := 0
|
||||||
env.Registry = EntryCall(func(context.Context, string, string, any) (json.RawMessage, error) {
|
env.Registry = EntryCall(func(context.Context, string, string, any) (json.RawMessage, error) {
|
||||||
calls++
|
calls++
|
||||||
return json.RawMessage(`{"versions":[{"digest":"` + row.answer + `","version":"1.2.3"}]}`), nil
|
return json.RawMessage(`{"repositories":[{"name":"mail/files","manifests":[{"digest":"sha256:` + strings.Repeat("e", 64) +
|
||||||
|
`","artifact":"` + row.answer + `","tags":["1.2.3"]}]}]}`), nil
|
||||||
})
|
})
|
||||||
env.Fetch = func(context.Context, string) ([]byte, error) { return body, row.fetch }
|
env.Fetch = func(context.Context, string) ([]byte, error) { return body, row.fetch }
|
||||||
env.Entry = EntryCall(func(context.Context, string, string, any) (json.RawMessage, error) {
|
env.Entry = EntryCall(func(context.Context, string, string, any) (json.RawMessage, error) {
|
||||||
|
|||||||
+3
-3
@@ -45,7 +45,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"invokes": [
|
"invokes": [
|
||||||
"seat:container-image-registry.versions",
|
"seat:container-image-registry.list",
|
||||||
"seat:mesh-catalog.entry",
|
"seat:mesh-catalog.entry",
|
||||||
"seat:mesh-catalog.module",
|
"seat:mesh-catalog.module",
|
||||||
{"verb": "seat:mesh-catalog.revision", "fields": ["none-yet"]},
|
{"verb": "seat:mesh-catalog.revision", "fields": ["none-yet"]},
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
"seat:mesh-recovery.restore-kept",
|
"seat:mesh-recovery.restore-kept",
|
||||||
"seat:mesh-recovery.snapshot-kept",
|
"seat:mesh-recovery.snapshot-kept",
|
||||||
"seat:node-packet-filter.allowed",
|
"seat:node-packet-filter.allowed",
|
||||||
"seat:oci-artifact-registry.versions"
|
"seat:oci-artifact-registry.list"
|
||||||
],
|
],
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"mesh-catalog.catalog-revision",
|
"mesh-catalog.catalog-revision",
|
||||||
@@ -125,7 +125,7 @@
|
|||||||
},
|
},
|
||||||
"resolve-again-minutes": {
|
"resolve-again-minutes": {
|
||||||
"type": "number",
|
"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 versions 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 list again, in minutes (design 47 H, H-A-146).",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 60,
|
"maximum": 60,
|
||||||
"default": 1
|
"default": 1
|
||||||
|
|||||||
Reference in New Issue
Block a user