composer: a build that can never be made is blamed after the held composition is judged (G-24 H3 review r1)
The held composition's own blames and its search come first; the module whose build can never be made is then blamed beside them. A held composition that still fails and blames nobody stays on the node's own account, so the module is not blamed in its place. Builds: design 47 G §721, §722, A-470j, A-470k
This commit is contained in:
@@ -278,7 +278,7 @@ func runCase(r Request, c Case, depth string) (CaseVerdict, error) {
|
||||
}
|
||||
}
|
||||
if len(never) > 0 && m.NotJudged == "" {
|
||||
m = blameNever(m, never, c.None) // after the awaited words, which judge it again where it does not compose
|
||||
m = blameNever(m, never, c.None) // after the held composition is judged, its search and the awaited words included
|
||||
}
|
||||
if m.Blamed == nil {
|
||||
m.Blamed = []blame{} // always written, so a verdict blaming none is told from an old composer's (A-469h)
|
||||
@@ -455,8 +455,10 @@ func neverOn(in compose.Input, node string, awaited, none map[string]string) (ne
|
||||
return never, pending
|
||||
}
|
||||
|
||||
// blameNever is m judged with each of never held: it composes with none of them, so it does not compose, says why, and
|
||||
// blames each with the revision's none words, in place of any problem its composition gave it (design 47 G §721, A-470j).
|
||||
// blameNever is m, judged with each of never held (its blames and the search already in it), with each of never blamed
|
||||
// with the revision's none words, in place of any problem its composition gave it: the machine composes with none of
|
||||
// them, so it does not compose, and says why (design 47 G §721, A-470j). A held composition that still fails and blames
|
||||
// nobody stays on the node's own account (§722): none of never is blamed in its place.
|
||||
func blameNever(m Machine, never, none map[string]string) Machine {
|
||||
mods := slices.Sorted(maps.Keys(never))
|
||||
var said []string
|
||||
@@ -464,6 +466,10 @@ func blameNever(m Machine, never, none map[string]string) Machine {
|
||||
said = append(said, mod+" ("+none[mod]+")")
|
||||
}
|
||||
words := "composed with it held as its node-engine holds it, since its build can never be made: " + strings.Join(said, ", ")
|
||||
if !m.Composes && len(m.Blamed) == 0 {
|
||||
m.Reason += "; " + words
|
||||
return m
|
||||
}
|
||||
if m.Composes {
|
||||
m.Composes, m.Reason = false, words
|
||||
} else {
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
engcomp "github.com/novox/mesh-host/internal/compositions"
|
||||
"os"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -320,31 +321,39 @@ func TestARequestItCannotRunIsRefused(t *testing.T) {
|
||||
}
|
||||
runner := `{"module": "app", "version": "1", "tool-runner": true, ` +
|
||||
`"build": {"artifacts": [{"name": "runtime", "kind": "bundle", "language": "go", "from": "cmd/runner", "binary": "runner"}]}}`
|
||||
office := `{"module": "office", "version": "1", "resources": [{"id": "c", "type": "file", "path": "/etc/office.conf", "template": "x"}]}`
|
||||
for _, row := range []struct {
|
||||
name, raw, digest string
|
||||
words string // in NotJudged, its build's paths not declared; "" composes at its build
|
||||
beside string // a module the change refuses on the same node: words are then in the refusal
|
||||
none string // the revision's none words for app (Case.None): judged held, app blamed with them
|
||||
tries int // the request's blame_tries
|
||||
}{
|
||||
{"the digest of the case's manifest", plain, same, "", "", ""},
|
||||
{"another digest, the same contract", plain, strings.Repeat("b", 64), "of another manifest than the change's (its build was made of the manifest " + strings.Repeat("b", 64), "", ""},
|
||||
{"no digest, the same contract", plain, "", "", "", ""},
|
||||
{"the digest of the case's manifest", plain, same, "", "", "", 20},
|
||||
{"another digest, the same contract", plain, strings.Repeat("b", 64), "of another manifest than the change's (its build was made of the manifest " + strings.Repeat("b", 64), "", "", 20},
|
||||
{"no digest, the same contract", plain, "", "", "", "", 20},
|
||||
{"no digest, another contract", strings.Replace(plain, `"version": "1"`, `"version": "2"`, 1), "",
|
||||
"app is composed by the running node-engine at its build fp1, of another manifest than the change's (its node-engine names no manifest", "", ""},
|
||||
"app is composed by the running node-engine at its build fp1, of another manifest than the change's (its node-engine names no manifest", "", "", 20},
|
||||
{"a tool runner, its bundle awaited", runner, "",
|
||||
"composed with it held as its node-engine holds it, since it does not compose without its build: app is composed by the running node-engine at its build fp1", "", ""},
|
||||
"composed with it held as its node-engine holds it, since it does not compose without its build: app is composed by the running node-engine at its build fp1", "", "", 20},
|
||||
// The group check of c5d32074c945, shanks: the change refused lab there, and the words were those of the
|
||||
// composition from the change's manifests unbuilt ("mesh-build-go runs as its own account and its build
|
||||
// produced no bundle to serve"), not of the one with them held, so the lift's own refusals failed the node.
|
||||
{"a tool runner awaited beside a module the change refuses", runner, "",
|
||||
"refused with it held as its node-engine holds it, since it does not compose without its build: app is composed by the running node-engine at its build fp1",
|
||||
`{"module": "office", "version": "1", "resources": [{"id": "c", "type": "file", "path": "/etc/office.conf", "template": "x"}]}`, ""},
|
||||
office, "", 20},
|
||||
// G-24 H3 (A-470j, A-470k; live at revision 449, lidarr, radarr and gitea): a build the revision gives no
|
||||
// fingerprint can never be made, so it does not leave the machine not judged: the machine is judged held, and
|
||||
// app is blamed with the revision's none words. An awaited build the case does not name so stays not judged
|
||||
// (the rows above).
|
||||
{"a build that can never be made, its machine judged held", plain, strings.Repeat("b", 64), "", "", "builders disagree: node 22 and node 24"},
|
||||
{"a tool runner whose bundle can never be made", runner, "", "", "", "no build module"},
|
||||
{"a build that can never be made, its machine judged held", plain, strings.Repeat("b", 64), "", "", "builders disagree: node 22 and node 24", 20},
|
||||
{"a tool runner whose bundle can never be made", runner, "", "", "", "no build module", 20},
|
||||
// The held composition is judged first, the search included, and the build that can never be made is blamed
|
||||
// beside what it blames (review round 1: office refused beside it went unblamed).
|
||||
{"a build that can never be made beside a module the change refuses", runner, "", "", office, "no build module", 20},
|
||||
// A held composition that still fails and blames nobody else (no search asked) fails on the node's own
|
||||
// account: the build that can never be made is not blamed in its place (§722).
|
||||
{"a build that can never be made beside a refusal nobody is blamed for", runner, "", "", office, "no build module", 0},
|
||||
} {
|
||||
in := compose.Input{Catalogue: map[string]catalogue.Manifest{"app": built}, Nodes: []compose.Node{{Name: "a", Assigned: []string{"app"}}},
|
||||
ComposedHow: &compose.ComposedHow{Node: "a", Builds: map[string]string{"app": "fp1"}}}
|
||||
@@ -360,16 +369,30 @@ func TestARequestItCannotRunIsRefused(t *testing.T) {
|
||||
manifests["office"] = Manifest{Raw: json.RawMessage(row.beside)}
|
||||
in.Nodes[0].Assigned = append(in.Nodes[0].Assigned, "office")
|
||||
}
|
||||
v, err := Run(withInput(t, Request{V: Version, Machines: []string{"a"}, Depth: DepthCompose, Declarations: true,
|
||||
// A row with a build that can never be made beside a refused module is composed as its node-engine composes it
|
||||
// (no declarations), where the search for culprits runs (frombus.ComposeSent).
|
||||
v, err := Run(withInput(t, Request{V: Version, Machines: []string{"a"}, Depth: DepthCompose, Declarations: row.none == "" || row.beside == "", BlameTries: row.tries,
|
||||
Cases: []Case{{Name: "change", Manifests: manifests, None: none}}}, in))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := v.Cases[0].Machines["a"]
|
||||
if row.none != "" {
|
||||
if m.NotJudged != "" || m.Composes || len(m.Blamed) != 1 || m.Blamed[0].Module != "app" || m.Blamed[0].Problem != row.none ||
|
||||
want, problem := []string{"app"}, map[string]string{}
|
||||
switch {
|
||||
case row.beside != "" && row.tries == 0:
|
||||
want = nil
|
||||
case row.beside != "":
|
||||
want = append(want, "office")
|
||||
}
|
||||
var got []string
|
||||
for _, b := range m.Blamed {
|
||||
got, problem[b.Module] = append(got, b.Module), b.Problem
|
||||
}
|
||||
slices.Sort(got)
|
||||
if m.NotJudged != "" || m.Composes || !slices.Equal(got, want) || (want != nil && problem["app"] != row.none) ||
|
||||
!strings.Contains(m.Reason, "its build can never be made") {
|
||||
t.Errorf("%s: machine %+v, want it judged with app held and blamed with %q", row.name, m, row.none)
|
||||
t.Errorf("%s: machine %+v, want it judged with app held and blamed with %q, and %v blamed", row.name, m, row.none, want)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user