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 5911577a..092877ec 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go @@ -45,7 +45,9 @@ type passer struct { kvs kvSet w *world logf func(string, ...any) - sdk string + // unread is the set of modules whose running build's manifest served last could not read, said once per change of it. + unread saidSet + sdk string // say publishes a condition to the operator; said is, by condition key and state, what this process has said, so a // pass says a condition once and a restart says it again (the router keeps one per key). say func(oc.Condition) error diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass_test.go index 2e2631c1..76e97147 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass_test.go @@ -1434,6 +1434,17 @@ func aWantWaitsOnTheVerbEdgesTheGraphKeeps(t *testing.T) { t.Errorf("served(%s) = %v, want %v: the running server's manifest serves w alone, late's is not read", v, served(v), want) } } + // The modules whose running build's manifest is not read are said once per change of their set (G-23). + var said []string + p.logf = func(f string, a ...any) { said = append(said, fmt.Sprintf(f, a...)) } + lateOnly := assign.Nodes{Haves: map[string]map[string]nodeengine.HaveByNodeModuleValue{"g14": {"server": at(fp("f")), "late": at(fp("2"))}}} + p.served(g, lateOnly) + p.served(g, lateOnly) + p.served(g, assign.Nodes{Haves: map[string]map[string]nodeengine.HaveByNodeModuleValue{"g14": {"late": at(fp("2")), "loop": at(fp("1"))}}}) + p.served(g, lateOnly) + if len(said) != 2 || !strings.Contains(said[0], "[loop late]") && !strings.Contains(said[0], "[late loop]") || !strings.Contains(said[1], "[late]") { + t.Errorf("the unread manifests were said %q, want once per change of the set", said) + } // A-426a: a healthy build held (no catalog entry of it) or waiting for a yes serves what it serves, said once; one held unhealthy, // or whose running statement says it stopped, does not. held := at(fp("2")) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/verbs.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/verbs.go index ac6766de..9a4dec05 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/verbs.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/verbs.go @@ -2,6 +2,8 @@ package main import ( "slices" + "strings" + "sync" "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" @@ -53,12 +55,31 @@ func (p *passer) served(g graph.Graph, n assign.Nodes) func(string) bool { } served, unread := graph.Served(servingHaves(n, p.countedServing), func(module, fp string) ([]string, bool) { return p.servesOf(module, fp) }, func(module string) []string { return g[module].Serves }) - if len(unread) > 0 { + if p.unread.changed(unread) && len(unread) > 0 { p.logf("the manifest of the running build of %v cannot be read, so what the module graph says they serve is counted as served", unread) } return served } +// saidSet is the last set of names said, so a pass says a set again only when it changed. +type saidSet struct { + mu sync.Mutex + last string +} + +// changed keeps names as the set said last and says whether it differs from the one before. +func (s *saidSet) changed(names []string) bool { + sorted := slices.Sorted(slices.Values(names)) + key := strings.Join(sorted, " ") + s.mu.Lock() + defer s.mu.Unlock() + if key == s.last { + return false + } + s.last = key + return true +} + // offering is, for this pass, whether a build whose manifest offers a provision runs healthy on a node present (ADR 0603 // §5, ADR 0614 §5): every running healthy have on an online node, its build's manifest read as servesOf reads it. A have // waiting for a person's yes on a newer build counts too: it names the build that still runs and that build's health, and