composer: a machine's verdict names the modules it blames (G-24 H1)
The assigner fails only the composition steps of the modules a machine blames, so the composer names them: the modules the change refuses that the node held neither in its read nor composing without the change, answered structured by ComposeSent, and both owners of a path two modules own, from the resolution's pairs. Blamed is always written, so a verdict blaming none is told from an old composer's. The two request-file tests are one, for the test budget. Builds: design 47 G §721, §733; A-468h, A-468l, A-469h, A-469j
This commit is contained in:
@@ -75,7 +75,7 @@ func Answer(ctx context.Context, r Reader, mesh Mesh, s Scope, fps map[string]st
|
||||
return refuse(fmt.Errorf("frombus: the credentials of %s: %w", s.Node, err))
|
||||
}
|
||||
}
|
||||
composed, skipped, stood, err := composeEach(in, s.Node, fps, false, s.Running, failed, ranOf(ctx, r, mesh, s.Running, fps))
|
||||
composed, skipped, stood, err := composeEach(in, s.Node, fps, false, s.Running, failed, ranOf(ctx, r, mesh, s.Running, fps), nil)
|
||||
if err != nil {
|
||||
// Not one module's: the node's own (a value served elsewhere, the mesh's network), said once as the node's.
|
||||
if len(failed) == 0 {
|
||||
@@ -331,8 +331,11 @@ func standsInFor(x, node string) (string, string) {
|
||||
// else the manifest it is composed from. Only the part of the offer that cannot compose is left out, by provision
|
||||
// (culprit): de-spiegel's routes, its names unset, leave route-proxy without them while mailu keeps its smtp account,
|
||||
// and the hold says so.
|
||||
//
|
||||
// owned, where not nil, is told each culprit held for a refusal that names paths two modules both own, with those pairs
|
||||
// (resolution.Refusal.OwnedTwice): a composer blames both owners with the path (design 47 G §721; A-468l).
|
||||
func composeEach(in compose.Input, node string, fps map[string]string, applied bool, running []compositions.Composed, failed map[string]string,
|
||||
ran func(module string) (catalogue.Manifest, bool)) (out map[string]compositions.Composed, skipped, stood []string, err error) {
|
||||
ran func(module string) (catalogue.Manifest, bool), owned func(culprit string, twice []resolution.OwnedTwice)) (out map[string]compositions.Composed, skipped, stood []string, err error) {
|
||||
mode := compose.Foreseeing
|
||||
if applied {
|
||||
mode = compose.Reading
|
||||
@@ -383,6 +386,9 @@ func composeEach(in compose.Input, node string, fps map[string]string, applied b
|
||||
if module == "" {
|
||||
return nil, nil, nil, firstReason(err, failed)
|
||||
}
|
||||
if refusal := (*resolution.Refusal)(nil); owned != nil && errors.As(err, &refusal) && len(refusal.OwnedTwice) > 0 {
|
||||
owned(module, refusal.OwnedTwice)
|
||||
}
|
||||
hold(module, err.Error(), leave)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -703,7 +703,7 @@ func Compose(ctx context.Context, r Reader, mesh Mesh, s Scope, fps map[string]s
|
||||
return nil, nil, held, fmt.Errorf("frombus: the credentials of %s: %w", s.Node, err)
|
||||
}
|
||||
}
|
||||
out, skipped, _, err = composeEach(in, s.Node, fps, true, s.Running, held, ranOf(ctx, r, mesh, s.Running, fps))
|
||||
out, skipped, _, err = composeEach(in, s.Node, fps, true, s.Running, held, ranOf(ctx, r, mesh, s.Running, fps), nil)
|
||||
return out, skipped, held, err
|
||||
}
|
||||
|
||||
@@ -730,7 +730,7 @@ func ComposingInput(ctx context.Context, r Reader, mesh Mesh, s Scope, fps map[s
|
||||
|
||||
// ComposeSent composes node from an input ComposingInput read, through the path Compose takes (composeEach, the read's holds
|
||||
// first): what a check's sandbox runs. False when the input says no way of composing node (an input from a node-engine
|
||||
// before ComposedHow): the caller cannot compose it as the node does.
|
||||
// before ComposedHow): the caller cannot compose it as the node does. A node the change refuses is a *Refuses.
|
||||
func ComposeSent(in compose.Input, node string) (map[string]engcomp.Composed, bool, error) {
|
||||
c := in.ComposedHow
|
||||
if c == nil || c.Node != node {
|
||||
@@ -740,7 +740,14 @@ func ComposeSent(in compose.Input, node string) (map[string]engcomp.Composed, bo
|
||||
if held == nil {
|
||||
held = map[string]string{}
|
||||
}
|
||||
out, _, _, err := composeEach(in, node, c.Builds, false, c.Running, held, nil)
|
||||
twice := map[string][]resolution.OwnedTwice{}
|
||||
out, _, _, err := composeEach(in, node, c.Builds, false, c.Running, held, nil, func(culprit string, pairs []resolution.OwnedTwice) {
|
||||
for _, p := range pairs {
|
||||
if p.Modules[0] == culprit || p.Modules[1] == culprit {
|
||||
twice[culprit] = append(twice[culprit], p)
|
||||
}
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return nil, true, err
|
||||
}
|
||||
@@ -748,18 +755,57 @@ func ComposeSent(in compose.Input, node string) (map[string]engcomp.Composed, bo
|
||||
// refusing it: the node does not compose, said in that module's words, never passed with the rest composed (issue 774,
|
||||
// review of the sandbox input).
|
||||
var refused []string
|
||||
for _, m := range sortedKeys(held) {
|
||||
blamed := map[string]string{}
|
||||
ours := func(m string) bool {
|
||||
_, was := c.Held[m]
|
||||
if _, before := c.HeldBefore[m]; !was && !before {
|
||||
_, before := c.HeldBefore[m]
|
||||
return !was && !before
|
||||
}
|
||||
for _, m := range sortedKeys(held) {
|
||||
if ours(m) {
|
||||
refused = append(refused, m+": "+held[m])
|
||||
blamed[m] = held[m]
|
||||
}
|
||||
}
|
||||
if len(refused) > 0 {
|
||||
return nil, true, fmt.Errorf("on %s the change refuses %s", node, strings.Join(refused, "; "))
|
||||
if len(refused) == 0 {
|
||||
return out, true, nil
|
||||
}
|
||||
return out, true, nil
|
||||
// Two modules owning one path are each blamed, with that path, the one held for it and the one it was held beside
|
||||
// (design 47 G §721; A-468l).
|
||||
for _, m := range sortedKeys(blamed) {
|
||||
for _, p := range twice[m] {
|
||||
words := fmt.Sprintf("%s and %s both declare the path %q", p.Modules[0], p.Modules[1], p.Path)
|
||||
for _, owner := range p.Modules {
|
||||
if ours(owner) {
|
||||
blamed[owner] = words
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
e := &Refuses{Node: node, words: strings.Join(refused, "; ")}
|
||||
for _, m := range sortedKeys(blamed) {
|
||||
e.Blamed = append(e.Blamed, Blamed{Module: m, Problem: blamed[m]})
|
||||
}
|
||||
return nil, true, e
|
||||
}
|
||||
|
||||
// Refuses is ComposeSent's refusal of a node by the change, answered structured (design 47 G §721; A-469j): each module
|
||||
// the sandbox held that its node-engine held neither in the read nor composing without the change (HeldBefore), and
|
||||
// each other owner of a path one of them was held for, with its problem.
|
||||
type Refuses struct {
|
||||
Node string
|
||||
Blamed []Blamed
|
||||
words string
|
||||
}
|
||||
|
||||
// Blamed is one module a refusal of the change blames, with its problem.
|
||||
type Blamed struct {
|
||||
Module string
|
||||
Problem string
|
||||
}
|
||||
|
||||
func (e *Refuses) Error() string { return fmt.Sprintf("on %s the change refuses %s", e.Node, e.words) }
|
||||
|
||||
// Plans is the provisioning plan of each module handed to the provisioner on the scope's node, composed from the bus
|
||||
// alone (novox/hq ADR 0570 clause 2): the controller's handedPlans over the same input (mesh-control
|
||||
// cmd/mesh-controller/compose_sdk.go), its rendering in the Foreseeing mode with the mesh's generators. A plan names
|
||||
|
||||
@@ -20,7 +20,19 @@ func heldKey(claim, kind string) string {
|
||||
//
|
||||
// Every reason at once rather than the first, and each says what to do about it. A person
|
||||
// resolving these fixes them in one pass or in four.
|
||||
type Refusal struct{ Problems []string }
|
||||
type Refusal struct {
|
||||
Problems []string
|
||||
// OwnedTwice is each path two modules both own among Problems, as a pair: a composer blames both owners with the
|
||||
// path, never by the words (design 47 G §721; A-468l).
|
||||
OwnedTwice []OwnedTwice
|
||||
}
|
||||
|
||||
// OwnedTwice is one path two modules both declare as their own (checkResources), the module that declared it first
|
||||
// first.
|
||||
type OwnedTwice struct {
|
||||
Path string
|
||||
Modules [2]string
|
||||
}
|
||||
|
||||
func (r *Refusal) Error() string {
|
||||
return "these assignments cannot be applied:\n - " + strings.Join(r.Problems, "\n - ")
|
||||
@@ -616,7 +628,8 @@ func resolve(catalogue map[string]mcat.Manifest, assigned []string, node mcat.No
|
||||
// Listed after the holding: an optional consumer of a requirement nothing answers is left absent there (ADR 0330 §3, §7).
|
||||
resolution.Absent = absentOf(absent, order, catalogue)
|
||||
problems = append(problems, unheld...)
|
||||
problems = append(problems, checkResources(resolution.Modules)...)
|
||||
owned, twice := resourceProblems(resolution.Modules)
|
||||
problems = append(problems, owned...)
|
||||
resolution.Claims = claims
|
||||
|
||||
// Judged over the closure — what this node will actually run — so a holder pulled in by a
|
||||
@@ -641,7 +654,7 @@ func resolve(catalogue map[string]mcat.Manifest, assigned []string, node mcat.No
|
||||
problems = append(problems, why)
|
||||
}
|
||||
sort.Strings(problems)
|
||||
return mcat.Resolution{}, nil, &Refusal{Problems: problems}
|
||||
return mcat.Resolution{}, nil, &Refusal{Problems: problems, OwnedTwice: twice}
|
||||
}
|
||||
return resolution, held, nil
|
||||
}
|
||||
@@ -910,6 +923,13 @@ func canonicalSeat(name string) string {
|
||||
// resolves with no refusal. What is refused is the contradiction — a path one module owns and
|
||||
// another merely accesses — because shared data is the operator's and nobody's to own.
|
||||
func checkResources(modules []mcat.Manifest) []string {
|
||||
problems, _ := resourceProblems(modules)
|
||||
return problems
|
||||
}
|
||||
|
||||
// resourceProblems is checkResources' problems, with each path two modules both own as a pair beside its words.
|
||||
func resourceProblems(modules []mcat.Manifest) ([]string, []OwnedTwice) {
|
||||
var twice []OwnedTwice
|
||||
// Judged as the machine composes them: where the node-resolver holder writes the resolver file, the
|
||||
// uplink holder's rendering of it is not composed, so it is not a second owner (novox/hq ADR 0247).
|
||||
modules = steppedBack(modules)
|
||||
@@ -987,6 +1007,9 @@ func checkResources(modules []mcat.Manifest) []string {
|
||||
if other, taken := owner[key]; taken && other != m.Module {
|
||||
problems = append(problems, fmt.Sprintf(
|
||||
"%s and %s both declare the %s %q", other, m.Module, field, value))
|
||||
if field == "path" {
|
||||
twice = append(twice, OwnedTwice{Path: value, Modules: [2]string{other, m.Module}})
|
||||
}
|
||||
}
|
||||
owner[key] = m.Module
|
||||
if field == "path" {
|
||||
@@ -1007,6 +1030,7 @@ func checkResources(modules []mcat.Manifest) []string {
|
||||
if other, taken := owner[key]; taken && other != m.Module {
|
||||
problems = append(problems, fmt.Sprintf(
|
||||
"%s and %s both declare the path %q", other, m.Module, fact.Path))
|
||||
twice = append(twice, OwnedTwice{Path: fact.Path, Modules: [2]string{other, m.Module}})
|
||||
}
|
||||
owner[key] = m.Module
|
||||
ownedPath[fact.Path] = m.Module
|
||||
@@ -1042,7 +1066,7 @@ func checkResources(modules []mcat.Manifest) []string {
|
||||
}
|
||||
}
|
||||
}
|
||||
return problems
|
||||
return problems, twice
|
||||
}
|
||||
|
||||
// meshNetwork is what to assign to a machine that needs to reach another one.
|
||||
|
||||
Reference in New Issue
Block a user