assigner: read want-parts from a node record's capabilities
The want of mesh-delivery-pipeline on novox named no version and no part digests, so novox's node-engine of G composed nothing: the assigner looked for want-parts among a node's manifest reads, while a node-engine of G states it among its record's capabilities (design 47 G §525), so no node ever read as able to take parts. Both are read now. Builds: design 47 G §525, §526, §379
This commit is contained in:
@@ -407,7 +407,7 @@ func (w *world) wantsOf() map[string]map[string]mwc.Want {
|
|||||||
// nodes is what the six rules read of the nodes: presence, haves, and every provision's providers with their nodes.
|
// nodes is what the six rules read of the nodes: presence, haves, and every provision's providers with their nodes.
|
||||||
func (w *world) nodes(manifests map[string]catalogue.Manifest, assigned map[string][]string) assign.Nodes {
|
func (w *world) nodes(manifests map[string]catalogue.Manifest, assigned map[string][]string) assign.Nodes {
|
||||||
n := assign.Nodes{Online: map[string]bool{}, Running: w.runningNow(), Haves: map[string]map[string]nodeengine.HaveByNodeModuleValue{}, Providers: map[string]map[string][]string{},
|
n := assign.Nodes{Online: map[string]bool{}, Running: w.runningNow(), Haves: map[string]map[string]nodeengine.HaveByNodeModuleValue{}, Providers: map[string]map[string][]string{},
|
||||||
Reads: map[string][]string{}}
|
Reads: map[string][]string{}, Capable: map[string][]string{}}
|
||||||
n.Online = w.online()
|
n.Online = w.online()
|
||||||
// The build a running statement names serves an acting edge's seat when its manifest claims it (design 47 G A-426).
|
// The build a running statement names serves an acting edge's seat when its manifest claims it (design 47 G A-426).
|
||||||
n.Serves = func(r nodeengine.Running, seat string) (bool, bool) {
|
n.Serves = func(r nodeengine.Running, seat string) (bool, bool) {
|
||||||
@@ -429,6 +429,7 @@ func (w *world) nodes(manifests map[string]catalogue.Manifest, assigned map[stri
|
|||||||
// What the node's engine reads (ADR 0614 §4); a record that states none is read as the baseline.
|
// What the node's engine reads (ADR 0614 §4); a record that states none is read as the baseline.
|
||||||
if h, err := nodeengineclient.DecodeHaveNode(value); err == nil && h.Record != nil {
|
if h, err := nodeengineclient.DecodeHaveNode(value); err == nil && h.Record != nil {
|
||||||
n.Reads[node] = h.Record.ManifestReads
|
n.Reads[node] = h.Record.ManifestReads
|
||||||
|
n.Capable[node] = h.Record.Capabilities // where a node-engine of G states want-parts (§525)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,6 +133,12 @@ func (m Module) actingWaiting(node string, n Nodes) (string, bool) {
|
|||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadsParts says whether node's node-engine reads a want's version, parts and kept-on: it states WantParts among its record's
|
||||||
|
// capabilities, where a node-engine of G states it (design 47 G §525), or, as read before, among its manifest reads.
|
||||||
|
func (n Nodes) ReadsParts(node string) bool {
|
||||||
|
return slices.Contains(n.Capable[node], WantParts) || slices.Contains(n.Reads[node], WantParts)
|
||||||
|
}
|
||||||
|
|
||||||
// WantParts is the capability a node-engine of G states (ADR 0614 §4, design 47 G §525): it reads a want's `parts` and `kept-on`.
|
// WantParts is the capability a node-engine of G states (ADR 0614 §4, design 47 G §525): it reads a want's `parts` and `kept-on`.
|
||||||
const WantParts = "want-parts"
|
const WantParts = "want-parts"
|
||||||
|
|
||||||
@@ -153,7 +159,7 @@ func (n Nodes) withKept(m Module, node string, w mwc.Want) mwc.Want {
|
|||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
k, ok := m.KeptBuilds(w.Fp)
|
k, ok := m.KeptBuilds(w.Fp)
|
||||||
if !ok || !slices.Contains(n.Reads[node], WantParts) {
|
if !ok || !n.ReadsParts(node) {
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
w.Parts, w.KeptOn, w.Version = k.Parts, k.KeptOn, k.Version
|
w.Parts, w.KeptOn, w.Version = k.Parts, k.KeptOn, k.Version
|
||||||
@@ -182,6 +188,9 @@ type Nodes struct {
|
|||||||
// Reads is, by node, the reader capabilities its node-engine states in its node record (nodeengine.NodeRecord.ManifestReads,
|
// Reads is, by node, the reader capabilities its node-engine states in its node record (nodeengine.NodeRecord.ManifestReads,
|
||||||
// ADR 0614 §4). A node with none, or none read, is read as stating the baseline (catalogue.StatedManifestReads).
|
// ADR 0614 §4). A node with none, or none read, is read as stating the baseline (catalogue.StatedManifestReads).
|
||||||
Reads map[string][]string
|
Reads map[string][]string
|
||||||
|
// Capable is, by node, the capabilities its node-engine states in its node record (nodeengine.NodeRecord.Capabilities): a
|
||||||
|
// node-engine of G states WantParts there (design 47 G §525).
|
||||||
|
Capable map[string][]string
|
||||||
// Serves says whether the build of a running statement serves an acting edge's seat, from that build's manifest: known false
|
// Serves says whether the build of a running statement serves an acting edge's seat, from that build's manifest: known false
|
||||||
// when its manifest cannot be read (design 47 G A-426). Nil: none is read.
|
// when its manifest cannot be read (design 47 G A-426). Nil: none is read.
|
||||||
Serves func(r nodeengine.Running, seat string) (serves, known bool)
|
Serves func(r nodeengine.Running, seat string) (serves, known bool)
|
||||||
|
|||||||
@@ -1604,18 +1604,22 @@ func TestAProviderRunsHealthyByItsRunning(t *testing.T) {
|
|||||||
func TestAWantNamesAKeptBuildsPartsAndNodeForANodeThatReadsThem(t *testing.T) {
|
func TestAWantNamesAKeptBuildsPartsAndNodeForANodeThatReadsThem(t *testing.T) {
|
||||||
kept := KeptBuild{Parts: map[string]string{"mail:image": "sha256:1"}, KeptOn: "g14", Version: "1.2.3"}
|
kept := KeptBuild{Parts: map[string]string{"mail:image": "sha256:1"}, KeptOn: "g14", Version: "1.2.3"}
|
||||||
for name, row := range map[string]struct {
|
for name, row := range map[string]struct {
|
||||||
reads []string
|
reads []string
|
||||||
kept func(string) (KeptBuild, bool)
|
kept func(string) (KeptBuild, bool)
|
||||||
wanted bool
|
wanted bool
|
||||||
|
capable []string
|
||||||
}{
|
}{
|
||||||
"states it": {[]string{WantParts}, func(fp string) (KeptBuild, bool) { return kept, fp == fNew }, true},
|
"states it": {[]string{WantParts}, func(fp string) (KeptBuild, bool) { return kept, fp == fNew }, true, nil},
|
||||||
"does not state": {[]string{"form:oci"}, func(fp string) (KeptBuild, bool) { return kept, fp == fNew }, false},
|
// §525: a node-engine of G states it among its record's capabilities, not its manifest reads.
|
||||||
"build not kept": {[]string{WantParts}, func(string) (KeptBuild, bool) { return KeptBuild{}, false }, false},
|
"states it as a capability": {[]string{"form:oci"}, func(fp string) (KeptBuild, bool) { return kept, fp == fNew }, true, []string{WantParts}},
|
||||||
"no kept builds": {[]string{WantParts}, nil, false},
|
"does not state": {[]string{"form:oci"}, func(fp string) (KeptBuild, bool) { return kept, fp == fNew }, false, nil},
|
||||||
"another fingerp": {[]string{WantParts}, func(fp string) (KeptBuild, bool) { return kept, fp == fOld }, false},
|
"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},
|
||||||
} {
|
} {
|
||||||
m, n := ready()
|
m, n := ready()
|
||||||
n.Reads = map[string][]string{"ace": row.reads, "g14": row.reads}
|
n.Reads = map[string][]string{"ace": row.reads, "g14": row.reads}
|
||||||
|
n.Capable = map[string][]string{"ace": row.capable}
|
||||||
m.KeptBuilds = row.kept
|
m.KeptBuilds = row.kept
|
||||||
w := Wants(m, heardOfHaves(n), wantedOld(), nil).Wants["ace"]
|
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.KeptOn == "g14") != row.wanted || (w.Version == "1.2.3") != row.wanted || (len(w.Parts) == 1) != row.wanted {
|
||||||
|
|||||||
Reference in New Issue
Block a user