assigner: leave a stale assignment out of a machine's composition (H-A-148)
The retired checker's assignment on the control-node made every composition there refuse "nothing provides", so every composition step on that machine ended could not run. A module assigned to a machine that the case's manifests do not hold (no watched branch lists it) is now left out of the case's assignments as well, said in the journal and at the judgement as unlisted, and the machine is judged on what remains: a stale assignment is a fault of the assignments, not of the change judged. Builds: design 47 H H-A-148, H-A-143; ADR 0578 §2
This commit is contained in:
@@ -13,6 +13,8 @@ import (
|
|||||||
|
|
||||||
"github.com/nats-io/nats.go/jetstream"
|
"github.com/nats-io/nats.go/jetstream"
|
||||||
|
|
||||||
|
mmac "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
|
||||||
|
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||||
ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
||||||
mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||||
meshcatalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
meshcatalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
@@ -59,8 +61,10 @@ type compositionRun struct {
|
|||||||
// them (design 47 H-A-143, G §532). Nil: the step's revision alone.
|
// them (design 47 H-A-143, G §532). Nil: the step's revision alone.
|
||||||
newest func() map[string]mcc.Half
|
newest func() map[string]mcc.Half
|
||||||
watched func(module string) []string
|
watched func(module string) []string
|
||||||
// assigned is the modules the assignments place on a machine (world.assignments), for the modules no watched branch lists.
|
// assigned is the modules the assignments place on a machine (world.assignments), for the modules no watched branch lists;
|
||||||
assigned func(node string) []string
|
// assignment is the machine's assignments whole, which the case composes with those modules left out (H-A-148).
|
||||||
|
assigned func(node string) []string
|
||||||
|
assignment func(node string) (mma.Assignments, bool)
|
||||||
// running is the last `running` heard of a module on a node (world.runningOf), never the node-engine's bucket.
|
// running is the last `running` heard of a module on a node (world.runningOf), never the node-engine's bucket.
|
||||||
running func(node, module string) (ne.Running, bool)
|
running func(node, module string) (ne.Running, bool)
|
||||||
// away says the watchman holds machine away (machine-away, not back since): the one presence the assigner keeps (world.awayNow),
|
// away says the watchman holds machine away (machine-away, not back since): the one presence the assigner keeps (world.awayNow),
|
||||||
@@ -254,8 +258,15 @@ func (r *compositionRun) start(ctx context.Context, key string, run meshwants.Co
|
|||||||
end(node + ": " + err.Error())
|
end(node + ": " + err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
cs := composer.Case{Name: changeCase, Manifests: prep.manifests, None: prep.none}
|
||||||
|
if left, err := r.leftOut(node, prep.manifests); err != nil {
|
||||||
|
end(node + ": " + err.Error())
|
||||||
|
return
|
||||||
|
} else if left != nil {
|
||||||
|
cs.Assignments = left
|
||||||
|
}
|
||||||
req := composer.Request{V: composer.Version, Input: in.Body, Depth: composer.DepthCompose, Machines: []string{node},
|
req := composer.Request{V: composer.Version, Input: in.Body, Depth: composer.DepthCompose, Machines: []string{node},
|
||||||
Cases: []composer.Case{{Name: changeCase, Manifests: prep.manifests, None: prep.none}}, Seats: prep.seats,
|
Cases: []composer.Case{cs}, Seats: prep.seats,
|
||||||
BlameTries: r.runs.set.blameTries} // the composer's bound of its search for culprits (§721, A-466r)
|
BlameTries: r.runs.set.blameTries} // the composer's bound of its search for culprits (§721, A-466r)
|
||||||
raw, err := json.Marshal(req)
|
raw, err := json.Marshal(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -301,8 +312,9 @@ const notTried = "not tried: the search reached its bound"
|
|||||||
// it, on the node's own account; a verdict with no `blamed` (a composer before §721) is judged as before, with the warning "the
|
// it, on the node's own account; a verdict with no `blamed` (a composer before §721) is judged as before, with the warning "the
|
||||||
// composer names no culprits"; otherwise the machine passes, with a warning for each other module blamed there.
|
// composer names no culprits"; otherwise the machine passes, with a warning for each other module blamed there.
|
||||||
//
|
//
|
||||||
// unlisted are the modules the machine is assigned that none of their watched branches lists: each is said on every path, in the
|
// unlisted are the modules the machine is assigned that none of their watched branches lists, left out of its composition: each is
|
||||||
// machine's failed or could-not-run words where one is set, else as a warning, never dropped in silence (H-A-143, H-A-144).
|
// said on every path, in the machine's failed or could-not-run words where one is set, else as a warning, never the machine's
|
||||||
|
// failure and never dropped in silence (H-A-143, H-A-144, H-A-148).
|
||||||
func judgeRun(module string, run meshwants.CompositionRun, unlisted []string) machineEnd {
|
func judgeRun(module string, run meshwants.CompositionRun, unlisted []string) machineEnd {
|
||||||
end := judgeVerdict(module, run)
|
end := judgeVerdict(module, run)
|
||||||
for _, u := range unlisted {
|
for _, u := range unlisted {
|
||||||
@@ -602,6 +614,36 @@ func (r *compositionRun) unlistedOn(node string) []string {
|
|||||||
return slices.Compact(out)
|
return slices.Compact(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// leftOut is the case's assignments of node with each module the case's manifests do not hold (none of its watched branches lists
|
||||||
|
// it) left out, or nil where none is (the case then composes the input's): a stale assignment is a fault of the assignments, not of
|
||||||
|
// the change judged, so it is left out of the composition, said in the journal and, at the judgement, as unlisted (design 47
|
||||||
|
// H-A-148, H-A-143; ADR 0578 §2).
|
||||||
|
func (r *compositionRun) leftOut(node string, manifests map[string]composer.Manifest) (map[string]json.RawMessage, error) {
|
||||||
|
if r.assignment == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
a, ok := r.assignment(node)
|
||||||
|
if !ok {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
var unlisted []string
|
||||||
|
for _, m := range a.Modules {
|
||||||
|
if _, held := manifests[m.Module]; !held {
|
||||||
|
unlisted = append(unlisted, m.Module)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(unlisted) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
a.Modules = slices.DeleteFunc(slices.Clone(a.Modules), func(m mma.PlacedModule) bool { return slices.Contains(unlisted, m.Module) })
|
||||||
|
raw, err := mmac.EncodeAssignments(a)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("its assignments with %s left out cannot be encoded: %w", strings.Join(unlisted, ", "), err)
|
||||||
|
}
|
||||||
|
r.logf("%s: the composition leaves out %s, assigned there and listed on no watched branch (H-A-148)", node, strings.Join(unlisted, ", "))
|
||||||
|
return map[string]json.RawMessage{node: raw}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// nodeEngineEntry is the entry of the module that claims the seat node-engine, or false.
|
// nodeEngineEntry is the entry of the module that claims the seat node-engine, or false.
|
||||||
func nodeEngineEntry(entries map[string]meshcatalog.CatalogEntry) (meshcatalog.CatalogEntry, bool) {
|
func nodeEngineEntry(entries map[string]meshcatalog.CatalogEntry) (meshcatalog.CatalogEntry, bool) {
|
||||||
for _, name := range slices.Sorted(mapsKeys(entries)) {
|
for _, name := range slices.Sorted(mapsKeys(entries)) {
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
mmac "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
|
||||||
|
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||||
ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
||||||
mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||||
meshcatalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
meshcatalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
@@ -283,6 +285,52 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) {
|
|||||||
c.Manifests["lidarr"].Raw != nil {
|
c.Manifests["lidarr"].Raw != nil {
|
||||||
t.Errorf("the case across the watched branches holds %v", slices.Sorted(maps.Keys(c.Manifests)))
|
t.Errorf("the case across the watched branches holds %v", slices.Sorted(maps.Keys(c.Manifests)))
|
||||||
}
|
}
|
||||||
|
if c := across.requests["ace"].Cases[0]; c.Assignments != nil {
|
||||||
|
t.Errorf("with no assignments held the case composes the input's, it carries %v", c.Assignments)
|
||||||
|
}
|
||||||
|
|
||||||
|
// A stale assignment is left out of the case's assignments as well, said, and the machine composes; a listed module stays in
|
||||||
|
// (H-A-148, ADR 0578 §2).
|
||||||
|
for _, tc := range []struct {
|
||||||
|
name string
|
||||||
|
assigned []string
|
||||||
|
want []string // the case's modules of ace; nil: the input's assignments
|
||||||
|
}{
|
||||||
|
{"a stale assignment left out and said, the machine composes", []string{"m", "f1-circuits", "checker"}, []string{"m", "f1-circuits"}},
|
||||||
|
{"listed modules alone: the input's assignments", []string{"m", "f1-circuits"}, nil},
|
||||||
|
} {
|
||||||
|
left := newRunStand(t, "src2:e1", "src2:e1", "d1")
|
||||||
|
left.r.newest, left.r.watched = across.r.newest, across.r.watched
|
||||||
|
left.r.assigned = func(string) []string { return tc.assigned }
|
||||||
|
left.r.assignment = func(node string) (mma.Assignments, bool) {
|
||||||
|
a := mma.Assignments{Node: node}
|
||||||
|
for _, m := range tc.assigned {
|
||||||
|
a.Modules = append(a.Modules, mma.PlacedModule{Module: m})
|
||||||
|
}
|
||||||
|
return a, true
|
||||||
|
}
|
||||||
|
left.verdict = func(string) (composer.Machine, bool) { return composer.Machine{Composes: true}, true }
|
||||||
|
out := left.r.run(context.Background(), "ask-step", step)
|
||||||
|
said := "ace is assigned checker, which no watched branch lists (H-A-143)"
|
||||||
|
if out.Outcome != meshwants.StepEndedOutcomePassed || (tc.want != nil) != slices.Contains(out.Warnings, said) {
|
||||||
|
t.Errorf("%s: the step came to %+v", tc.name, out)
|
||||||
|
}
|
||||||
|
raw, ok := left.requests["ace"].Cases[0].Assignments["ace"]
|
||||||
|
if tc.want == nil {
|
||||||
|
if ok {
|
||||||
|
t.Errorf("%s: the case carries assignments %s", tc.name, raw)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
a, err := mmac.DecodeAssignments(raw)
|
||||||
|
var got []string
|
||||||
|
for _, m := range a.Modules {
|
||||||
|
got = append(got, m.Module)
|
||||||
|
}
|
||||||
|
if err != nil || !slices.Equal(got, tc.want) {
|
||||||
|
t.Errorf("%s: the case composes ace with %v (%v), want %v", tc.name, got, err, tc.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// At the inputs state's cap the ask is refused, naming the store (§354).
|
// At the inputs state's cap the ask is refused, naming the store (§354).
|
||||||
full := newRunStand(t, "src2:e1", "src2:e1", "d1")
|
full := newRunStand(t, "src2:e1", "src2:e1", "d1")
|
||||||
|
|||||||
@@ -665,7 +665,7 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber,
|
|||||||
// The composition step (design 47 G §22, §354): the seat mesh-wants' accepted kind step, run by one run ask per machine.
|
// The composition step (design 47 G §22, §354): the seat mesh-wants' accepted kind step, run by one run ask per machine.
|
||||||
if bus != nil && js != nil && inputs != nil && p.publishWants != nil && runs != nil {
|
if bus != nil && js != nil && inputs != nil && p.publishWants != nil && runs != nil {
|
||||||
run := &compositionRun{runs: runs, inputs: &compositionInputs{machines: w.machinesOf, callFile: bus.CallFile}, keeper: inputs, reads: &compositionReads{}, call: bus.CallKept,
|
run := &compositionRun{runs: runs, inputs: &compositionInputs{machines: w.machinesOf, callFile: bus.CallFile}, keeper: inputs, reads: &compositionReads{}, call: bus.CallKept,
|
||||||
trunk: trunkOf(iv, w.trunkName), newest: iv.newestOf(), watched: iv.watchedOf, assigned: w.assignedOn, running: w.runningOf, away: func(machine string) bool { return w.awayNow()[machine] }, put: runAskPublisher(js), ask: bus.CallFile, now: time.Now, logf: logger.Printf}
|
trunk: trunkOf(iv, w.trunkName), newest: iv.newestOf(), watched: iv.watchedOf, assigned: w.assignedOn, assignment: w.assignmentOf, running: w.runningOf, away: func(machine string) bool { return w.awayNow()[machine] }, put: runAskPublisher(js), ask: bus.CallFile, now: time.Now, logf: logger.Printf}
|
||||||
steps := &compositionSteps{node: thisNode, say: p.publishWants, run: run.run, resume: run.resume,
|
steps := &compositionSteps{node: thisNode, say: p.publishWants, run: run.run, resume: run.resume,
|
||||||
validate: run.validate, resumeValidate: run.resumeValidate, ended: runs.stepEnded, now: time.Now, logf: logger.Printf}
|
validate: run.validate, resumeValidate: run.resumeValidate, ended: runs.stepEnded, now: time.Now, logf: logger.Printf}
|
||||||
move := steps.move(ctx) // the readers a rerun carried (§727, A-470d)
|
move := steps.move(ctx) // the readers a rerun carried (§727, A-470d)
|
||||||
|
|||||||
@@ -562,3 +562,9 @@ func (w *world) assignedOn(node string) []string {
|
|||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// assignmentOf is node's assignments, or false where none is held.
|
||||||
|
func (w *world) assignmentOf(node string) (mma.Assignments, bool) {
|
||||||
|
a, ok := w.assignments()[node]
|
||||||
|
return a, ok
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user