diff --git a/internal/selfcompose/entries.go b/internal/selfcompose/entries.go index 922142c6..14ccf1e3 100644 --- a/internal/selfcompose/entries.go +++ b/internal/selfcompose/entries.go @@ -549,12 +549,13 @@ func (c *Composer) needsAddressOf(node, module string) bool { return false } -// runsWithoutEntry says this node runs module (heard, not stopped) and holds no entry of its wanted build nor of its running build -// (c.mu held): the case where its provisions are read from its trunk build (A-480a). +// runsWithoutEntry says this node holds module on, as it runs it, and holds no entry of its wanted build nor of its running build +// (c.mu held): the case where its provisions are read from its trunk build (A-480a). A module built by hand before G says no running +// event (the engine says one only of a build whose manifest it knows), so it is held as running unless it was heard stopped. func (c *Composer) runsWithoutEntry(module string) bool { - run, ok := c.heard[c.env.Node][module] + run := c.heard[c.env.Node][module] w, wanted := c.wants[module] - if !ok || run.stopped || !wanted || w.Fp == "" { + if run.stopped || !wanted || w.Fp == "" { return false } for _, fp := range []string{w.Fp, run.fingerprint} { diff --git a/internal/selfcompose/entries_test.go b/internal/selfcompose/entries_test.go index c3298890..b506ba2e 100644 --- a/internal/selfcompose/entries_test.go +++ b/internal/selfcompose/entries_test.go @@ -44,7 +44,10 @@ func composeFromEntries(t *testing.T) { var mu sync.Mutex var asked []string ask := func(_ context.Context, seat, verb string, args any) (json.RawMessage, error) { - in := args.(meshcatalog.EntryInput) + in, isEntry := args.(meshcatalog.EntryInput) + if !isEntry { + return nil, errors.New("the catalog half holds no trunk build here") // A-480a: the module verb, asked of a ghost + } mu.Lock() asked = append(asked, in.Fingerprint) mu.Unlock() @@ -268,20 +271,22 @@ func runningModuleWithoutEntryStandsAsTheNewestBuild(t *testing.T) { newest := meshcatalogclient.SourcePrefix2 + strings.Repeat("2", 64) body := `{"module":"postgres","version":"2"}` for _, tc := range []struct { - name string - runs bool - newest string - holds bool - laid bool - wantFp string - trunk bool // A-480a: the catalog half's trunk build of the module has an entry (the newest build has none) + name string + runs bool + newest string + holds bool + laid bool + wantFp string + stopped bool // A-480a: heard stopped + trunk bool // A-480a: the catalog half's trunk build of the module has an entry (the newest build has none) }{ - {"runs, newest entry held", true, newest, true, true, old, false}, - {"not running here", false, newest, true, false, old, false}, - {"names no newer build", true, "", false, false, old, false}, - {"newest entry not held", true, newest, false, false, old, false}, - {"runs, no newest build, trunk entry held (A-480a)", true, "", false, true, old, true}, - {"not running here, trunk entry held (A-480a)", false, "", false, false, old, true}, + {"runs, newest entry held", true, newest, true, true, old, false, false}, + {"not running here", false, newest, true, false, old, false, false}, + {"names no newer build", true, "", false, false, old, false, false}, + {"newest entry not held", true, newest, false, false, old, false, false}, + {"runs, no newest build, trunk entry held (A-480a)", true, "", false, true, old, false, true}, + {"heard no running event (built by hand), trunk entry held (A-480a)", false, "", false, true, old, false, true}, + {"heard stopped, trunk entry held (A-480a)", false, "", false, false, old, true, true}, } { t.Run(tc.name, func(t *testing.T) { env := newFakeBus().env() @@ -300,6 +305,9 @@ func runningModuleWithoutEntryStandsAsTheNewestBuild(t *testing.T) { if tc.runs { c.heard = map[string]map[string]heardRun{"n1": {"postgres": {fingerprint: old}}} } + if tc.stopped { + c.heard = map[string]map[string]heardRun{"n1": {"postgres": {fingerprint: old, stopped: true}}} + } c.mu.Unlock() if tc.holds { c.holdEntry(t, "postgres", newest, body)