diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go index 657b1fb6..98ce4beb 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go @@ -24,8 +24,10 @@ import ( "git.novox.be/novox/mesh-sdk/go/seatlist" "sync" + "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel" "git.novox.be/novox/mesh-contracts/provisioning/go/clients/meshprovisionerclient" + mpr "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph" "git.novox.be/novox/mesh-sdk/go/catalogue" @@ -325,8 +327,19 @@ func (p *passer) wants(ctx context.Context) { branches = []string{g.branch} } if fp != "" && !p.ends.mayWant(name, fp, branches, wantedOf[name]) { - p.sayNoWant(name, g.nodes, wantedOf[name], assign.Outcome{Rules: noPipelineRules(g.nodes, name, fp, branches)}) - return + if !runnerFirstStart(name, manifests, p.w.runningNow()) { + p.sayNoWant(name, g.nodes, wantedOf[name], assign.Outcome{Rules: noPipelineRules(g.nodes, name, fp, branches)}) + return + } + // The first start of the pipeline runner (design 47 G A-428): no runner runs to pass its pipeline, so its want is + // written from the trunk's entry by the other rules, and said once. + if key := "runner-first-start " + name + "@" + fp; !p.skipped[key] { + if p.skipped == nil { + p.skipped = map[string]bool{} + } + p.skipped[key] = true + p.logf("%s at %s is wanted with no passed pipeline: it claims the seat %s and no module holding that seat runs on any node, so none can pass one (design 47 G A-428)", name, shortHex(fp), mpr.Seat) + } } // A dependent's new version waits for its dependency's newest released version to be delivered (ยง376, A-189). if p.holdForDelivery(ctx, name, fp, g.branch, g.nodes) { @@ -1502,3 +1515,20 @@ func noPipelineRules(nodes []string, module, fp string, branches []string) map[s } return out } + +// runnerFirstStart says whether module claims the seat mesh-pipeline-runner while no module claiming it runs on any node (design 47 +// G A-428): read from the node-engine seat's running statements the assigner hears, each module's claims from its manifest. With +// no running heard yet it says false: the gate stands until the assigner knows. +func runnerFirstStart(module string, manifests map[string]catalogue.Manifest, running map[string]map[string]nodeengine.Running) bool { + if !manifests[module].ClaimsSeat(mpr.Seat) || running == nil { + return false + } + for _, mods := range running { + for m, r := range mods { + if !r.Stopped && r.Fingerprint != "" && manifests[m].ClaimsSeat(mpr.Seat) { + return false + } + } + } + return true +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines_test.go index 535fa85c..b29ba21d 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines_test.go @@ -196,6 +196,17 @@ func TestAWantFollowsAPassedPipeline(t *testing.T) { t.Error("the runner's member that failed is wanted") } } + // Design 47 G A-428: the runner's first start skips the gate while no module claiming the seat runs; another module never + // does, and a runner running anywhere (stopped ones aside) closes it; with no running heard the gate stands. + manifests := map[string]catalogue.Manifest{"runner": {Claims: []catalogue.Claim{{Name: mpr.Seat}}}, "web": {}} + none := map[string]map[string]nodeengine.Running{"ace": {"web": {Fingerprint: fp1}}} + if !runnerFirstStart("runner", manifests, none) || runnerFirstStart("web", manifests, none) || runnerFirstStart("runner", manifests, nil) { + t.Error("the runner's first start: the runner skips the gate, another module or an unknown world does not") + } + if runnerFirstStart("runner", manifests, map[string]map[string]nodeengine.Running{"novox": {"runner": {Fingerprint: "fp-runner"}}}) || + !runnerFirstStart("runner", manifests, map[string]map[string]nodeengine.Running{"novox": {"runner": {Stopped: true}}}) { + t.Error("a runner running closes the gate's opening; one stopped does not") + } // A want that names the fingerprint already is not held by a later failure (a node placed afterwards gets it). e := newPipelineEnds(newMemEnds(), func() {}, t.Logf) e.on.Store(true)