S4: an unread seat list holds a module before its build is read
On ace, a node-engine left on its bootstrapped seat list could not find the artifact store's seat, refused avahi's archive reference and with it the whole pass, so the seat-list hold never ran and every module said "reaches no artifact store". While the list is unread, a placed module whose seats are not all bootstrapped is now held as it runs before anything of its build is read (frombus.Scope.Held), its reason names the bootstrapped seats the node holds, and a pass refused whole says the unread list first (issue 1966). Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
@@ -32,6 +32,8 @@ import (
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-networking/modules/mesh-wireguard/go/overlay"
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatlist"
|
||||
"github.com/nats-io/nats.go"
|
||||
"github.com/novox/mesh-host/internal/compose"
|
||||
"github.com/novox/mesh-host/internal/compose/frombus"
|
||||
@@ -1842,6 +1844,20 @@ type gate struct{ open atomic.Bool }
|
||||
|
||||
func (g *gate) MayAct(...string) bool { return g.open.Load() }
|
||||
|
||||
// namedGate is a gate that says the seats it holds, as the reader of the seat list does (seatlist.Reader.Status).
|
||||
type namedGate struct {
|
||||
*gate
|
||||
seats []string
|
||||
}
|
||||
|
||||
func (g *namedGate) Status() seatlist.Status {
|
||||
st := seatlist.Status{Heard: g.open.Load()}
|
||||
for _, s := range g.seats {
|
||||
st.Held = append(st.Held, seatlist.Held{Seat: s, Source: seatlist.SourceBootstrap})
|
||||
}
|
||||
return st
|
||||
}
|
||||
|
||||
// ADR 0636 §1: a node that has not read the seat list composes nothing new of a module whose seats are not bootstrapped,
|
||||
// says it holds the module (so its have says why) and hands it at the read, which the reader says as an event; what
|
||||
// already runs with the same composition is not held.
|
||||
@@ -1852,22 +1868,38 @@ func TestAnUnreadSeatListHoldsWhatIsNewAndHandsItAtTheRead(t *testing.T) {
|
||||
man, _ := meshcatalogclient.EncodeManifest(meshcatalog.ManifestsByDigestValue{Module: "lemurs", Manifest: lemurs})
|
||||
key, _ := meshcatalogclient.ManifestsKey(digest)
|
||||
b.kv[buckets.Manifests+"/"+key] = man
|
||||
// Issue 1966: avahi's archive is in the artifact store, whose seat the bootstrap does not hold, so before the read the
|
||||
// node reaches no store; avahi is held for the list before its build is read, and the pass is not refused for it.
|
||||
avahi := `{"module":"avahi","version":"1","capabilities":["systemd"],"resources":[{"id":"tools","type":"archive",` +
|
||||
`"path":"/opt/avahi","source":"` + catalogue.ArtifactStoreScheme + `avahi/tools/blobs/sha256:` + strings.Repeat("d", 64) + `"}]}`
|
||||
avahiDigest := meshcatalogclient.ManifestDigest([]byte(avahi))
|
||||
avahiMan, _ := meshcatalogclient.EncodeManifest(meshcatalog.ManifestsByDigestValue{Module: "avahi", Manifest: avahi})
|
||||
avahiKey, _ := meshcatalogclient.ManifestsKey(avahiDigest)
|
||||
b.kv[buckets.Manifests+"/"+avahiKey] = avahiMan
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
env := b.env()
|
||||
g := &gate{}
|
||||
g := &namedGate{gate: &gate{}, seats: []string{"mesh-catalog", "node-engine"}}
|
||||
changed := make(chan struct{}, 1)
|
||||
env.SeatList, env.SeatListChanged = g, changed
|
||||
var mu sync.Mutex
|
||||
heldBy := map[string]string{}
|
||||
env.Refused = func(_ string, held map[string]string) { mu.Lock(); heldBy = held; mu.Unlock() }
|
||||
var refusedWhole []string
|
||||
env.Refused = func(why string, held map[string]string) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
heldBy = held
|
||||
if why != "" {
|
||||
refusedWhole = append(refusedWhole, why)
|
||||
}
|
||||
}
|
||||
c := New(env)
|
||||
out, err := c.Watch(ctx, "n1.>")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
place := assignedValues(t, meshmoduleassigner.Assignments{Node: "n1", Decided: meshmoduleassigner.NodeDecided{Hub: true, Address: "10.77.0.1"},
|
||||
Modules: []meshmoduleassigner.PlacedModule{{Module: "lemurs"}}})
|
||||
Modules: []meshmoduleassigner.PlacedModule{{Module: "lemurs"}, {Module: "avahi"}}})
|
||||
have, _ := nodeengineclient.EncodeHaveNode(nodeengine.HaveByNodeNodeValue{Record: &nodeengine.NodeRecord{Node: "n1", TunnelKey: "k", SealingKey: "sk", Capabilities: []string{"systemd"}}})
|
||||
mod, _ := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: digest, Repository: "novox/x", Commit: "c"})
|
||||
want, _ := bucketstest.Want(meshwants.WantsByWantNodeModuleValue{Fp: fp, Self: true})
|
||||
@@ -1875,6 +1907,8 @@ func TestAnUnreadSeatListHoldsWhatIsNewAndHandsItAtTheRead(t *testing.T) {
|
||||
b.putAssigned(t, place)
|
||||
b.put(t, buckets.Have, "n1.node", have)
|
||||
b.put(t, buckets.Modules, "lemurs", mod)
|
||||
avahiMod, _ := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: avahiDigest, Repository: "novox/x", Commit: "c"})
|
||||
b.put(t, buckets.Modules, "avahi", avahiMod)
|
||||
b.put(t, buckets.Wants, "want.n1.lemurs", want)
|
||||
b.put(t, buckets.Wants, "want.n1.node", nodeWant)
|
||||
for _, bucket := range []string{buckets.Wants, buckets.Assignments, buckets.Have, buckets.Modules, ResolvedBucket, builds.BuilderBuildsBucket} {
|
||||
@@ -1888,11 +1922,32 @@ func TestAnUnreadSeatListHoldsWhatIsNewAndHandsItAtTheRead(t *testing.T) {
|
||||
}
|
||||
handed[u.Key] = true
|
||||
}
|
||||
// The reason names the bootstrapped list the node holds (issue 1966: ace's modules said "reaches no artifact store").
|
||||
waits := fmt.Sprintf(WaitsForTheSeatListHeld, 2, "mesh-catalog, node-engine") + composesNothingNewOfIt
|
||||
mu.Lock()
|
||||
why := heldBy["lemurs"]
|
||||
why, avahiWhy, whole := heldBy["lemurs"], heldBy["avahi"], slices.Clone(refusedWhole)
|
||||
mu.Unlock()
|
||||
if why != WaitsForTheSeatList {
|
||||
t.Errorf("lemurs is held with %q, want %q", why, WaitsForTheSeatList)
|
||||
if why != waits || avahiWhy != waits || len(whole) != 0 {
|
||||
t.Errorf("lemurs is held with %q, avahi with %q, the pass refused %q; want both %q and no refusal", why, avahiWhy, whole, waits)
|
||||
}
|
||||
// A pass refused whole while the list is unread says the list first (issue 1966).
|
||||
refusing := b.env()
|
||||
refusing.SeatList = g
|
||||
refusing.Get = func(context.Context, string, string) ([]byte, error) {
|
||||
return nil, errors.New("nats says ${dir:mesh-state}, and nats declares no directory")
|
||||
}
|
||||
var refusal string
|
||||
refusing.Refused = func(w string, _ map[string]string) { refusal = w }
|
||||
c2 := New(refusing)
|
||||
c.mu.Lock()
|
||||
maps.Copy(c2.wants, c.wants)
|
||||
maps.Copy(c2.assignments, c.assignments)
|
||||
maps.Copy(c2.records, c.records)
|
||||
maps.Copy(c2.modules, c.modules)
|
||||
c.mu.Unlock()
|
||||
c2.compose(ctx)
|
||||
if line := fmt.Sprintf(WaitsForTheSeatListHeld, 2, "mesh-catalog, node-engine") + "; "; !strings.HasPrefix(refusal, line) {
|
||||
t.Errorf("a pass refused while the list is unread says %q, want it to begin %q", refusal, line)
|
||||
}
|
||||
for k := range handed {
|
||||
if strings.Contains(k, "lemurs") {
|
||||
|
||||
Reference in New Issue
Block a user