Merge pull request 'Design 47 H1: the validate and composition run asks carry their entry's pins (H-A-203)' (#304) from fix/47-H1-runner-validate-pins into main
This commit was merged in pull request #304.
This commit is contained in:
@@ -216,7 +216,7 @@ type runPrep struct {
|
|||||||
seats []json.RawMessage
|
seats []json.RawMessage
|
||||||
manifests map[string]composer.Manifest
|
manifests map[string]composer.Manifest
|
||||||
none map[string]string
|
none map[string]string
|
||||||
programOf func(node string) (buildstep.RunProgram, string, error)
|
programOf func(node string) (buildstep.RunProgram, string, map[string]string, error)
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,7 +274,7 @@ func (r *compositionRun) start(ctx context.Context, key string, run meshwants.Co
|
|||||||
end(node + " gave no composition input: " + in.Why)
|
end(node + " gave no composition input: " + in.Why)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
program, engineFp, err := prep.programOf(node)
|
program, engineFp, pins, err := prep.programOf(node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
end(node + ": " + err.Error())
|
end(node + ": " + err.Error())
|
||||||
return
|
return
|
||||||
@@ -317,7 +317,8 @@ func (r *compositionRun) start(ctx context.Context, key string, run meshwants.Co
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
a := buildstep.StepAsk{ID: ask, Kind: buildstep.AskCheck, Language: buildstep.AskGo, Asker: runAsker, At: r.now().UTC(),
|
a := buildstep.StepAsk{ID: ask, Kind: buildstep.AskCheck, Language: buildstep.AskGo, Asker: runAsker, At: r.now().UTC(),
|
||||||
Run: &buildstep.RunJob{Program: program, Heads: []buildstep.RunHead{}, Input: ref, Reader: "the composition of " + node + " by the node-engine at " + program.Commit}}
|
Run: &buildstep.RunJob{Program: program, Heads: []buildstep.RunHead{}, Input: ref, Reader: "the composition of " + node + " by the node-engine at " + program.Commit},
|
||||||
|
Packages: pins} // the composer is built against its entry's pins, as every build (H-A-203, H-A-192)
|
||||||
if err := r.put(ctx, a); err != nil {
|
if err := r.put(ctx, a); err != nil {
|
||||||
end(node + ": its run ask " + ask + " is not put: " + err.Error())
|
end(node + ": its run ask " + ask + " is not put: " + err.Error())
|
||||||
}
|
}
|
||||||
@@ -732,53 +733,76 @@ func programOfEntry(e meshcatalog.CatalogEntry) (buildstep.RunProgram, error) {
|
|||||||
return buildstep.RunProgram{Repository: e.Repository, Commit: e.Commit, Dir: dir, Package: composer.Package}, nil
|
return buildstep.RunProgram{Repository: e.Repository, Commit: e.Commit, Dir: dir, Package: composer.Package}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pinsOfEntry are the mesh packages' versions an entry pins, the ones it names with a version (H-A-203, H-A-183): the pins
|
||||||
|
// a run's program is built against, in the form the entry keeps and the builder sends. nil when it pins none.
|
||||||
|
func pinsOfEntry(e meshcatalog.CatalogEntry) map[string]string {
|
||||||
|
var out map[string]string
|
||||||
|
for path, version := range e.Packages {
|
||||||
|
if version == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if out == nil {
|
||||||
|
out = map[string]string{}
|
||||||
|
}
|
||||||
|
out[path] = version
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
// programs answers, per machine, the composer its run builds and the node-engine fingerprint it was chosen from (A-226, A-243,
|
// programs answers, per machine, the composer its run builds and the node-engine fingerprint it was chosen from (A-226, A-243,
|
||||||
// A-252, §719): where the revision's node-engine entry differs from the trunk's, that build for every machine; else the build the
|
// A-252, §719): where the revision's node-engine entry differs from the trunk's, that build for every machine; else the build the
|
||||||
// machine's node-engine runs, as its `running` says, its entry read through mesh-catalog's `entry`; a machine whose node-engine's
|
// machine's node-engine runs, as its `running` says, its entry read through mesh-catalog's `entry`; a machine whose node-engine's
|
||||||
// `running` is not heard gets the revision's entry, said (A-451).
|
// `running` is not heard gets the revision's entry, said (A-451).
|
||||||
func (r *compositionRun) programs(ctx context.Context, half mcc.Half) (func(node string) (buildstep.RunProgram, string, error), error) {
|
func (r *compositionRun) programs(ctx context.Context, half mcc.Half) (func(node string) (buildstep.RunProgram, string, map[string]string, error), error) {
|
||||||
engine, ok := nodeEngineEntry(half.Entries)
|
engine, ok := nodeEngineEntry(half.Entries)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("the catalog revision %d holds no module claiming the seat %s", half.Revision.Revision, ne.Seat)
|
return nil, fmt.Errorf("the catalog revision %d holds no module claiming the seat %s", half.Revision.Revision, ne.Seat)
|
||||||
}
|
}
|
||||||
if trunk, ok := r.trunk(); !ok || func() bool { t, ok := nodeEngineEntry(trunk.Entries); return !ok || t.Fp != engine.Fp }() {
|
if trunk, ok := r.trunk(); !ok || func() bool { t, ok := nodeEngineEntry(trunk.Entries); return !ok || t.Fp != engine.Fp }() {
|
||||||
p, err := programOfEntry(engine)
|
p, err := programOfEntry(engine)
|
||||||
return func(string) (buildstep.RunProgram, string, error) { return p, engine.Fp, err }, nil
|
return func(string) (buildstep.RunProgram, string, map[string]string, error) {
|
||||||
|
return p, engine.Fp, pinsOfEntry(engine), err
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
var mu sync.Mutex
|
var mu sync.Mutex
|
||||||
byFp := map[string]buildstep.RunProgram{}
|
type built struct {
|
||||||
return func(node string) (buildstep.RunProgram, string, error) {
|
program buildstep.RunProgram
|
||||||
|
pins map[string]string
|
||||||
|
}
|
||||||
|
byFp := map[string]built{}
|
||||||
|
return func(node string) (buildstep.RunProgram, string, map[string]string, error) {
|
||||||
running, ok := r.running(node, engine.Module)
|
running, ok := r.running(node, engine.Module)
|
||||||
if !ok || running.Fingerprint == "" {
|
if !ok || running.Fingerprint == "" {
|
||||||
r.logf("%s: no build of %s is heard running there, so its composer is the catalog revision's entry %s (A-451)", node,
|
r.logf("%s: no build of %s is heard running there, so its composer is the catalog revision's entry %s (A-451)", node,
|
||||||
engine.Module, engine.Fp)
|
engine.Module, engine.Fp)
|
||||||
p, err := programOfEntry(engine)
|
p, err := programOfEntry(engine)
|
||||||
return p, engine.Fp, err
|
return p, engine.Fp, pinsOfEntry(engine), err
|
||||||
}
|
}
|
||||||
fp := running.Fingerprint
|
fp := running.Fingerprint
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
p, ok := byFp[fp]
|
b, ok := byFp[fp]
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
if ok {
|
if ok {
|
||||||
return p, fp, nil
|
return b.program, fp, b.pins, nil
|
||||||
}
|
}
|
||||||
what := "the entry of the node-engine's build " + fp + " is not read"
|
what := "the entry of the node-engine's build " + fp + " is not read"
|
||||||
body, said, err := r.callRetry(ctx, entryVerbKey, meshcatalog.EntryInput{Fingerprint: fp})
|
body, said, err := r.callRetry(ctx, entryVerbKey, meshcatalog.EntryInput{Fingerprint: fp})
|
||||||
if err != nil || body == nil {
|
if err != nil || body == nil {
|
||||||
return buildstep.RunProgram{}, fp, unreadErr(what, err, said)
|
return buildstep.RunProgram{}, fp, nil, unreadErr(what, err, said)
|
||||||
}
|
}
|
||||||
var a meshcatalog.EntryAnswer
|
var a meshcatalog.EntryAnswer
|
||||||
if err := json.Unmarshal(body, &a); err != nil {
|
if err := json.Unmarshal(body, &a); err != nil {
|
||||||
return buildstep.RunProgram{}, fp, fmt.Errorf("%s: %w", what, err)
|
return buildstep.RunProgram{}, fp, nil, fmt.Errorf("%s: %w", what, err)
|
||||||
}
|
}
|
||||||
p, err = programOfEntry(a.Entry)
|
p, err := programOfEntry(a.Entry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return p, fp, err
|
return p, fp, nil, err
|
||||||
}
|
}
|
||||||
|
pins := pinsOfEntry(a.Entry)
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
byFp[fp] = p
|
byFp[fp] = built{program: p, pins: pins}
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
return p, fp, nil
|
return p, fp, pins, nil
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ func newRunStand(t *testing.T, revisionEngine, trunkEngine, seatDigest string) *
|
|||||||
s := &runStand{asks: map[string]buildstep.StepAsk{}, requests: map[string]composer.Request{}}
|
s := &runStand{asks: map[string]buildstep.StepAsk{}, requests: map[string]composer.Request{}}
|
||||||
engine := func(fp, commit string) meshcatalog.CatalogEntry {
|
engine := func(fp, commit string) meshcatalog.CatalogEntry {
|
||||||
return meshcatalog.CatalogEntry{Module: "engine", Fp: fp, Repository: "novox/mesh-host", Commit: commit, Path: ".", Serves: []string{ne.Seat + ".composition"},
|
return meshcatalog.CatalogEntry{Module: "engine", Fp: fp, Repository: "novox/mesh-host", Commit: commit, Path: ".", Serves: []string{ne.Seat + ".composition"},
|
||||||
Manifest: map[string]any{"module": "engine"}}
|
Manifest: map[string]any{"module": "engine"}, Packages: map[string]string{"git.novox.be/novox/mesh-sdk/go": "v0.1.25-" + fp, "git.novox.be/novox/x/go": ""}}
|
||||||
}
|
}
|
||||||
revisionCommit := commitE1
|
revisionCommit := commitE1
|
||||||
if revisionEngine != "src2:e1" {
|
if revisionEngine != "src2:e1" {
|
||||||
@@ -186,6 +186,13 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) {
|
|||||||
if s.asks["g14"].Run.Program.Commit != commitE2 {
|
if s.asks["g14"].Run.Program.Commit != commitE2 {
|
||||||
t.Errorf("g14's composer is built at %s, want the build its node-engine runs", s.asks["g14"].Run.Program.Commit)
|
t.Errorf("g14's composer is built at %s, want the build its node-engine runs", s.asks["g14"].Run.Program.Commit)
|
||||||
}
|
}
|
||||||
|
// Each composer is built against the pins of the node-engine entry it is built from, a pin with no version left out
|
||||||
|
// (H-A-203, H-A-192).
|
||||||
|
for node, fp := range map[string]string{"ace": "src2:e1", "g14": "src2:e2"} {
|
||||||
|
if got := s.asks[node].Packages; len(got) != 1 || got["git.novox.be/novox/mesh-sdk/go"] != "v0.1.25-"+fp {
|
||||||
|
t.Errorf("%s's composer is built against the pins %v; want its entry's", node, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
if req.Depth != composer.DepthCompose || req.BlameTries != 20 || len(req.Machines) != 1 || req.Machines[0] != "ace" || len(req.Cases) != 1 || req.Cases[0].Name != changeCase ||
|
if req.Depth != composer.DepthCompose || req.BlameTries != 20 || len(req.Machines) != 1 || req.Machines[0] != "ace" || len(req.Cases) != 1 || req.Cases[0].Name != changeCase ||
|
||||||
string(req.Input) != `{"node":"ace"}` || len(req.Seats) != 1 || string(req.Seats[0]) != `{"seat":"s1"}` {
|
string(req.Input) != `{"node":"ace"}` || len(req.Seats) != 1 || string(req.Seats[0]) != `{"seat":"s1"}` {
|
||||||
t.Errorf("the request of ace %+v", req)
|
t.Errorf("the request of ace %+v", req)
|
||||||
|
|||||||
@@ -345,7 +345,8 @@ func (r *compositionRun) startValidate(ctx context.Context, key string, run mesh
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
a := buildstep.StepAsk{ID: ask, Kind: buildstep.AskCheck, Language: buildstep.AskGo, Asker: runAsker, At: r.now().UTC(),
|
a := buildstep.StepAsk{ID: ask, Kind: buildstep.AskCheck, Language: buildstep.AskGo, Asker: runAsker, At: r.now().UTC(),
|
||||||
Run: &buildstep.RunJob{Program: program, Heads: []buildstep.RunHead{}, Input: ref, Reader: "the manifest validator of " + step.Pipeline + " at " + program.Commit}}
|
Run: &buildstep.RunJob{Program: program, Heads: []buildstep.RunHead{}, Input: ref, Reader: "the manifest validator of " + step.Pipeline + " at " + program.Commit},
|
||||||
|
Packages: pinsOfEntry(entry)} // the validator is built against its entry's pins at the step's revision (H-A-203, H-A-192, H-A-205)
|
||||||
if err := r.put(ctx, a); err != nil {
|
if err := r.put(ctx, a); err != nil {
|
||||||
couldNot("its run ask " + ask + " is not put: " + err.Error())
|
couldNot("its run ask " + ask + " is not put: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ import (
|
|||||||
// is judged against an empty case before, said in its end, and no revision below it is asked.
|
// is judged against an empty case before, said in its end, and no revision below it is asked.
|
||||||
func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) {
|
func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) {
|
||||||
indexer := meshcatalog.CatalogEntry{Module: "indexer", Repository: "novox/mesh-delivery", Commit: commitE3, Path: "modules/mesh-delivery-indexer",
|
indexer := meshcatalog.CatalogEntry{Module: "indexer", Repository: "novox/mesh-delivery", Commit: commitE3, Path: "modules/mesh-delivery-indexer",
|
||||||
Fp: "src2:ix", Serves: []string{"seat:" + meshcatalog.Seat + ".revision"}, Manifest: map[string]any{"module": "indexer"}, ManifestDigest: "d-ix"}
|
Fp: "src2:ix", Serves: []string{"seat:" + meshcatalog.Seat + ".revision"}, Manifest: map[string]any{"module": "indexer"}, ManifestDigest: "d-ix",
|
||||||
|
Packages: map[string]string{"git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient": "v0.1.4"}}
|
||||||
entry := func(module, digest string, edges ...meshcatalog.Edge) meshcatalog.CatalogEntry {
|
entry := func(module, digest string, edges ...meshcatalog.Edge) meshcatalog.CatalogEntry {
|
||||||
return meshcatalog.CatalogEntry{Module: module, Manifest: map[string]any{"module": module, "d": digest}, ManifestDigest: digest, Edges: edges}
|
return meshcatalog.CatalogEntry{Module: module, Manifest: map[string]any{"module": module, "d": digest}, ManifestDigest: digest, Edges: edges}
|
||||||
}
|
}
|
||||||
@@ -124,6 +125,10 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) {
|
|||||||
if p := asks[0].Run.Program; p.Commit != commitE3 || p.Dir != "modules/mesh-delivery-indexer" || p.Package != validatorPackage || len(asks[0].Run.Heads) != 0 {
|
if p := asks[0].Run.Program; p.Commit != commitE3 || p.Dir != "modules/mesh-delivery-indexer" || p.Package != validatorPackage || len(asks[0].Run.Heads) != 0 {
|
||||||
t.Errorf("the validator is built from %+v", asks[0].Run)
|
t.Errorf("the validator is built from %+v", asks[0].Run)
|
||||||
}
|
}
|
||||||
|
// The validator is built against the indexer entry's pins at the step's revision (H-A-203, H-A-192, H-A-205).
|
||||||
|
if got := asks[0].Packages; len(got) != 1 || got["git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"] != "v0.1.4" {
|
||||||
|
t.Errorf("the validator is built against the pins %v; want its entry's", got)
|
||||||
|
}
|
||||||
if c := requests[0].Cases; len(c) != 2 || c[0].Name != changeCase || c[1].Name != beforeCase || len(c[1].Manifests) != 3 || requests[0].Predefined != nil || requests[0].Packages != nil {
|
if c := requests[0].Cases; len(c) != 2 || c[0].Name != changeCase || c[1].Name != beforeCase || len(c[1].Manifests) != 3 || requests[0].Predefined != nil || requests[0].Packages != nil {
|
||||||
t.Errorf("the validator's request is %+v", requests[0])
|
t.Errorf("the validator's request is %+v", requests[0])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user