diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/candidateadded.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/candidateadded.go index bdcf7e8c..61748b49 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/candidateadded.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/candidateadded.go @@ -42,7 +42,11 @@ func (p *passer) addedOf(node string, laid *mma.Assignments, current map[string] if out == nil { out = map[string]mma.AddedModule{} } - out[module] = mma.AddedModule{Version: k.Version, Parts: k.Parts} + added := mma.AddedModule{Version: k.Version, Parts: k.Parts} + if k.Version != "" { + added.Parts = nil // a released build is named by its version alone (design 47 G A-430, A-430a) + } + out[module] = added } return out } diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/candidateadded_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/candidateadded_test.go index 547280fc..e2f49be4 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/candidateadded_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/candidateadded_test.go @@ -34,7 +34,7 @@ func TestACandidateThatAddsAModuleCarriesItsParts(t *testing.T) { current := map[string]mma.Assignments{"ace": {Node: "ace", Modules: []mma.PlacedModule{{Module: "old"}}}} c := p.candidateOf("p1", "ace", laid, current) want := map[string]mma.AddedModule{ - "mail": {Version: "1.2.3", Parts: map[string]string{"mail:image": "sha256:9"}}, + "mail": {Version: "1.2.3"}, // a released build is named by its version alone (A-430a) "db": {Parts: map[string]string{"db:program": "sha256:3"}}, } if c.Proposal != "p1" || c.Assignments != laid || !reflect.DeepEqual(c.Added, want) { diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/graphkept.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/graphkept.go index 3538242b..5c01fcd7 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/graphkept.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/graphkept.go @@ -186,7 +186,11 @@ func (p *passer) namedBuild(module, trunkFP string, fpSrc int64) func(fp string) if k, ok := p.w.ends.partsOf(module, fp); ok { return k, true } - if fp != trunkFP || p.graph == nil || !p.graph.ok { + if fp != trunkFP { + return assign.KeptBuild{}, false + } + if p.graph == nil || !p.graph.ok { + p.unheardRelease(module, fp, "no assignment graph revision is kept yet, so no release is looked up") return assign.KeptBuild{}, false } if fpSrc == 0 { diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go index d921088d..f8be2cd9 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go @@ -1561,7 +1561,7 @@ func (p *passer) sayParts(name string, m assign.Module, n assign.Nodes, out assi if !ok { w, ok = before[node] // kept as it stands this pass } - if !ok || w.Removed || w.Fp == "" || len(w.Parts) > 0 { + if !ok || w.Removed || w.Fp == "" || len(w.Parts) > 0 || w.Version != "" { continue } reads := n.ReadsParts(node) @@ -1582,6 +1582,6 @@ func (p *passer) sayParts(name string, m assign.Module, n assign.Nodes, out assi p.skipped = map[string]bool{} } p.skipped[key] = true - p.logf("the want of %s on %s names no parts: %s", name, node, why) + p.logf("the want of %s on %s names no version and no parts: %s", name, node, why) } } diff --git a/modules/mesh-delivery-assigner/internal/assign/wants.go b/modules/mesh-delivery-assigner/internal/assign/wants.go index 61023367..4dd8558e 100644 --- a/modules/mesh-delivery-assigner/internal/assign/wants.go +++ b/modules/mesh-delivery-assigner/internal/assign/wants.go @@ -159,10 +159,23 @@ func (n Nodes) withKept(m Module, node string, w mwc.Want) mwc.Want { return w } k, ok := m.KeptBuilds(w.Fp) - if !ok || !n.ReadsParts(node) { + if !ok { return w } - w.Parts, w.KeptOn, w.Version = k.Parts, k.KeptOn, k.Version + if k.Version != "" { + // A want names the module and its version, never its artifacts' digests (design 47 G A-430, A-430a): the node-engine + // resolves each artifact at that version through its kind's registry seat. + w.Version, w.Parts = k.Version, nil + if k.KeptOn != "" { + w.KeptOn = k.KeptOn + } + return w + } + // A build with no version known to the assigner (another watched branch's, a kept one: build.ended names none) is named by its + // parts and keeping node as before, for a node that reads them, until the builder says the version it numbered it under. + if n.ReadsParts(node) { + w.Parts, w.KeptOn = k.Parts, k.KeptOn + } return w } @@ -703,6 +716,11 @@ func Wants(m Module, n Nodes, wants map[string]mwc.Want, lastHealthy map[string] if !write { continue } + // Every want that names a build names its version (A-430a), whichever rule made or kept it: a want held at its fingerprint + // by the rules, a node's own (self) want too. + if !next.Removed && next.Fp != "" && next.Version == "" { + next = n.withKept(m, node, next) + } if !had || !mwc.SameWant(normal(before), normal(next)) { out.Wants[node] = next } diff --git a/modules/mesh-delivery-assigner/internal/assign/wants_test.go b/modules/mesh-delivery-assigner/internal/assign/wants_test.go index f20cd6fc..dbe4453c 100644 --- a/modules/mesh-delivery-assigner/internal/assign/wants_test.go +++ b/modules/mesh-delivery-assigner/internal/assign/wants_test.go @@ -1599,30 +1599,32 @@ func TestAProviderRunsHealthyByItsRunning(t *testing.T) { } } -// Design 47 G §525, §526: a want at a kept build names its parts and the node that keeps it, only for a node whose engine states -// the capability want-parts. +// Design 47 G A-430, A-430a (over §525, §526): a want names the module's version, never its artifacts' digests, whichever node it +// is for; a build the assigner knows no version of (another branch's, a kept one) is named by its parts and keeping node, as +// before, for a node whose engine reads them (its record's capabilities or its manifest reads). func TestAWantNamesAKeptBuildsPartsAndNodeForANodeThatReadsThem(t *testing.T) { - kept := KeptBuild{Parts: map[string]string{"mail:image": "sha256:1"}, KeptOn: "g14", Version: "1.2.3"} + released := KeptBuild{Parts: map[string]string{"mail:image": "sha256:1"}, KeptOn: "g14", Version: "1.2.3"} + unversioned := KeptBuild{Parts: map[string]string{"mail:image": "sha256:1"}, KeptOn: "g14"} for name, row := range map[string]struct { - reads []string - kept func(string) (KeptBuild, bool) - wanted bool - capable []string + reads, capable []string + kept func(string) (KeptBuild, bool) + version string + parts bool }{ - "states it": {[]string{WantParts}, func(fp string) (KeptBuild, bool) { return kept, fp == fNew }, true, nil}, - // §525: a node-engine of G states it among its record's capabilities, not its manifest reads. - "states it as a capability": {[]string{"form:oci"}, func(fp string) (KeptBuild, bool) { return kept, fp == fNew }, true, []string{WantParts}}, - "does not state": {[]string{"form:oci"}, func(fp string) (KeptBuild, bool) { return kept, fp == fNew }, false, nil}, - "build not kept": {[]string{WantParts}, func(string) (KeptBuild, bool) { return KeptBuild{}, false }, false, nil}, - "no kept builds": {[]string{WantParts}, nil, false, nil}, - "another fingerp": {[]string{WantParts}, func(fp string) (KeptBuild, bool) { return kept, fp == fOld }, false, nil}, + "released, reads parts": {[]string{WantParts}, nil, func(fp string) (KeptBuild, bool) { return released, fp == fNew }, "1.2.3", false}, + "released, reads none": {[]string{"form:oci"}, nil, func(fp string) (KeptBuild, bool) { return released, fp == fNew }, "1.2.3", false}, + "unversioned, capability": {[]string{"form:oci"}, []string{WantParts}, func(fp string) (KeptBuild, bool) { return unversioned, fp == fNew }, "", true}, + "unversioned, reads none": {[]string{"form:oci"}, nil, func(fp string) (KeptBuild, bool) { return unversioned, fp == fNew }, "", false}, + "build not kept": {[]string{WantParts}, nil, func(string) (KeptBuild, bool) { return KeptBuild{}, false }, "", false}, + "no kept builds": {[]string{WantParts}, nil, nil, "", false}, + "another fingerprint's release": {[]string{WantParts}, nil, func(fp string) (KeptBuild, bool) { return released, fp == fOld }, "", false}, } { m, n := ready() n.Reads = map[string][]string{"ace": row.reads, "g14": row.reads} n.Capable = map[string][]string{"ace": row.capable} m.KeptBuilds = row.kept w := Wants(m, heardOfHaves(n), wantedOld(), nil).Wants["ace"] - if w.Fp != fNew || (w.KeptOn == "g14") != row.wanted || (w.Version == "1.2.3") != row.wanted || (len(w.Parts) == 1) != row.wanted { + if w.Fp != fNew || w.Version != row.version || (len(w.Parts) == 1) != row.parts { t.Errorf("%s: ace's want = %+v", name, w) } }