Node-engine: a running module the assignment names is held, never removed, whatever composed nothing of it (A-410)
Builds: design 47 G A-410
This commit is contained in:
@@ -155,6 +155,31 @@ func Answer(ctx context.Context, r Reader, mesh Mesh, s Scope, fps map[string]st
|
||||
Today: "running, kept as it runs"})
|
||||
}
|
||||
skipped = slices.DeleteFunc(skipped, func(m string) bool { return runs[m] })
|
||||
// And whatever the candidate's assignment of this node names that runs and was composed to nothing for any other reason
|
||||
// (the module is in no catalogue the composition reads, so it has no resources and is not even skipped): held the same
|
||||
// way. Only a module no assignment names is removed (A-410).
|
||||
placedHere := map[string]bool{}
|
||||
if p, given := s.Assignments[s.Node]; given && p != nil {
|
||||
for _, m := range p.Modules {
|
||||
placedHere[m.Module] = true
|
||||
}
|
||||
} else if !given {
|
||||
for _, m := range trunk[s.Node].Modules {
|
||||
placedHere[m.Module] = true
|
||||
}
|
||||
}
|
||||
a.Removed = slices.DeleteFunc(a.Removed, func(m string) bool {
|
||||
if !placedHere[m] {
|
||||
return false
|
||||
}
|
||||
a.Held = append(a.Held, nodeengine.CandidateRefusal{Module: m,
|
||||
Why: "the assignment names " + m + " on this node, and the composition made nothing of it, so it is kept as it runs",
|
||||
Today: "running, kept as it runs"})
|
||||
return true
|
||||
})
|
||||
if len(a.Removed) == 0 {
|
||||
a.Removed = nil
|
||||
}
|
||||
|
||||
// What the proposal adds, by node and module: placed by a candidate and not by the trunk on that node.
|
||||
added := map[string]bool{}
|
||||
|
||||
@@ -217,6 +217,24 @@ func answerNamesEveryRefusalAndLeavesAnOldBuildToTheNode(t *testing.T) {
|
||||
if !heldIt || len(a.Added) != 0 {
|
||||
t.Errorf("a running module with no fingerprint is answered held %+v added %+v, want held with why and not added", a.Held, a.Added)
|
||||
}
|
||||
// (D) One the assignment names whose manifest says its name alone (no resources: what stands in for a module whose entry
|
||||
// is not held) composes to nothing, and is not even skipped: held too, not removed (A-410).
|
||||
nameOnly := []byte(`{"module":"ghost","version":"0"}`)
|
||||
ghostDigest := meshcatalogclient.ManifestDigest(nameOnly)
|
||||
b.manifests[ghostDigest] = nameOnly
|
||||
b.modules["ghost"] = meshcatalog.ModulesByModuleValue{Manifest: ghostDigest}
|
||||
pGhost := b.assignments["n1"]
|
||||
trunkMods := pGhost.Modules
|
||||
pGhost.Modules = append(append([]meshmoduleassigner.PlacedModule{}, trunkMods...), meshmoduleassigner.PlacedModule{Module: "ghost"})
|
||||
b.assignments["n1"] = pGhost
|
||||
ghostRuns := append(append([]engcomp.Composed{}, unmarked...), engcomp.Composed{Node: "n1", Module: "ghost", FP: fp("2")})
|
||||
a = Answer(ctx, b, Mesh{}, Scope{Node: "n1", Assignments: given(b), InOwn: []string{"spiegel"}}, noFp, ghostRuns, "p-h1", 3)
|
||||
if !reflect.DeepEqual(a.Removed, []string{"gone"}) || !slices.ContainsFunc(a.Held, func(h nodeengine.CandidateRefusal) bool { return h.Module == "ghost" }) {
|
||||
t.Errorf("a named module the composition made nothing of: removed %v held %+v, want it held and only gone removed (%.600s)", a.Removed, a.Held, fmt.Sprintf("%+v", a))
|
||||
}
|
||||
pGhost.Modules = trunkMods
|
||||
b.assignments["n1"] = pGhost
|
||||
delete(b.modules, "ghost")
|
||||
// Without what runs, the fold composes spiegel from its manifest, as before, and the composition refuses it.
|
||||
if _, _, held, err := Compose(ctx, b, Mesh{}, Scope{Node: "n1", InOwn: []string{"spiegel"}}, fps); err != nil ||
|
||||
!strings.Contains(held["spiegel"], "spiegel has not been built for this mesh") {
|
||||
|
||||
Reference in New Issue
Block a user