From 07ea73bd64f69a16c7596f27a7900ba5997b6c65 Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 17 Nov 2026 16:12:51 +0100 Subject: [PATCH] selfcompose: a stopped or build-less placed module is laid from its placement; an unobtained trunk build is asked again lacksEntry holds for a stopped run and for one naming no build, and the loop for another node's placed modules lays every one not yet laid where it holds. A trunk build askTrunkBuilds could not get is said with its reason and asked again on the next pass. Builds: design 47 G-22 A-461d, A-461e --- internal/selfcompose/entries.go | 20 +++++++++-------- internal/selfcompose/entries_test.go | 33 +++++++++++++++++++--------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/internal/selfcompose/entries.go b/internal/selfcompose/entries.go index 9b003c16..f5801ffe 100644 --- a/internal/selfcompose/entries.go +++ b/internal/selfcompose/entries.go @@ -421,8 +421,8 @@ func (c *Composer) layModules() { } } } - // A module placed on another node and not heard running is one whose running build has no entry (A-461d): laid from the build - // its placement names, or its trunk build (A-461b). + // A module placed on another node and not heard running (or stopped, or running no build it names) is one whose running build has + // no entry (A-461d): laid, where not laid yet, from the build its placement names, or its trunk build (A-461b). placedOn := make([]string, 0, len(c.assignments)) for node := range c.assignments { placedOn = append(placedOn, node) @@ -433,7 +433,7 @@ func (c *Composer) layModules() { continue } for _, pm := range c.assignments[node].Modules { - if _, heard := c.heard[node][pm.Module]; heard { + if _, laid := modules[pm.Module]; laid || !c.lacksEntry(node, pm.Module) { continue } if built := c.placedBuild(node, pm.Module); built != "" { @@ -503,11 +503,8 @@ func (c *Composer) lacksEntry(node, module string) bool { return false } run, heard := c.heard[node][module] - if heard && run.stopped { - return false - } - if !heard || run.fingerprint == "" { - return true // placed there, and not heard running (A-461d) + if !heard || run.stopped || run.fingerprint == "" { + return true // placed there, and not heard running (A-461d), stopped or running no build it names } k, ok := c.keptEnt[run.fingerprint] return !ok || k.entry.Module == "" @@ -533,7 +530,12 @@ func (c *Composer) askTrunkBuilds() { } c.mu.Unlock() for _, a := range asks { - fp, _ := c.trunkFp(a.module) + fp, why := c.trunkFp(a.module) + if fp == "" { + // Said with its reason, and asked again on the next pass: nothing is kept of an answer that was none (A-461e). + c.env.Say(fmt.Sprintf("the trunk build of %s, placed on %s, could not be had, and is asked again: %s", a.module, a.node, why)) + continue + } c.mu.Lock() if c.trunkBuilds == nil { c.trunkBuilds = map[string]trunkBuild{} diff --git a/internal/selfcompose/entries_test.go b/internal/selfcompose/entries_test.go index dbc82d67..6bb5f7b3 100644 --- a/internal/selfcompose/entries_test.go +++ b/internal/selfcompose/entries_test.go @@ -351,16 +351,18 @@ func TestRunningBuildEntryKeptAndHandedAgain(t *testing.T) { node string build, trunk string holds, laid bool - notHeard bool // A-461d: nothing of what the node runs is heard + heard string // A-461d: what is heard of it: "" its running build, "none", "stopped", "no-build" }{ - {"placed build has an entry", "n2", placedFp, "", true, true, false}, - {"neither build has an entry", "n2", placedFp, "", false, false, false}, - {"placement names no build, trunk build has an entry", "n2", "", placedFp, true, true, false}, - {"placement names no build, trunk names none", "n2", "", "", false, false, false}, - {"this node's own module is not laid from a placement", "n1", placedFp, "", true, false, false}, - {"placed, not heard, placement names no build, trunk build has an entry (A-461d)", "n2", "", placedFp, true, true, true}, - {"placed, not heard, placed build has an entry (A-461d)", "n2", placedFp, "", true, true, true}, - {"placed, not heard, trunk names none (A-461d)", "n2", "", "", false, false, true}, + {"placed build has an entry", "n2", placedFp, "", true, true, ""}, + {"neither build has an entry", "n2", placedFp, "", false, false, ""}, + {"placement names no build, trunk build has an entry", "n2", "", placedFp, true, true, ""}, + {"placement names no build, trunk names none", "n2", "", "", false, false, ""}, + {"this node's own module is not laid from a placement", "n1", placedFp, "", true, false, ""}, + {"placed, not heard, placement names no build, trunk build has an entry (A-461d)", "n2", "", placedFp, true, true, "none"}, + {"placed, not heard, placed build has an entry (A-461d)", "n2", placedFp, "", true, true, "none"}, + {"placed, stopped there, placement names no build, trunk build has an entry (A-461d)", "n2", "", placedFp, true, true, "stopped"}, + {"placed, heard with no build, placement names no build, trunk build has an entry (A-461d)", "n2", "", placedFp, true, true, "no-build"}, + {"placed, not heard, trunk names none (A-461d)", "n2", "", "", false, false, "none"}, } { t.Run(tc.name, func(t *testing.T) { env := newFakeBus().env() @@ -375,14 +377,25 @@ func TestRunningBuildEntryKeptAndHandedAgain(t *testing.T) { c.mu.Lock() c.assignments[tc.node] = meshmoduleassigner.Assignments{Node: tc.node, Modules: []meshmoduleassigner.PlacedModule{{Module: "distribution", Build: tc.build}}} c.heard = map[string]map[string]heardRun{tc.node: {"distribution": {fingerprint: old}}} - if tc.notHeard { + switch tc.heard { + case "none": c.heard = map[string]map[string]heardRun{} + case "stopped": + c.heard = map[string]map[string]heardRun{tc.node: {"distribution": {fingerprint: old, stopped: true}}} + case "no-build": + c.heard = map[string]map[string]heardRun{tc.node: {"distribution": {}}} } c.mu.Unlock() if tc.holds { c.holdEntry(t, "distribution", placedFp, `{"module":"distribution","version":"2"}`) } c.askTrunkBuilds() + c.mu.Lock() + _, kept := c.trunkBuilds["distribution"] + c.mu.Unlock() + if tc.node == "n2" && tc.build == "" && tc.trunk == "" && kept { + t.Error("a trunk build that could not be had was kept, so it is asked once per process (A-461e)") + } if _, asked := c.wantedBuilds()[placedFp]; asked != (tc.node == "n2" && (tc.build != "" || tc.trunk != "")) { t.Errorf("the placed build asked = %v", asked) }