The store owns the seat set, so only the control plane may judge a claim
A claim on a seat was checked against `SeatNamed` inside `ParseManifest`, and the build machine parses manifests too. It has no store, so there it answered from the set compiled into the binary — a copy of data the control plane owns (ADR 0122). When the two disagreed, that copy won where it mattered. The store's row said the bus seat answers for `amqp`; the binary's said `mesh-bus`; and a holder that provides `amqp` was refused at build time for not providing `mesh-bus`. The seat went unheld, the controller lost the address it composes through that seat, and the control plane crash-looped on a bus that was healthy the whole time. So the two checks that read the set — a seat's scope, and what its holder must provide — move to CatalogueProblems, which runs only in the control plane and only after UseSeats has replaced the set with the store's. The parser keeps what it can judge from the manifest alone, the reserved-namespace rule included. A test pins it: the same manifest, two different values in the store, and the answer follows the store both times. It fails if the check moves back.
This commit is contained in:
@@ -91,7 +91,10 @@ func TestAClaimMustMatchTheDeclaredScope(t *testing.T) {
|
||||
|
||||
// The mesh's own seats still work, and are not shadowed by the derived half.
|
||||
func TestTheMeshsOwnSeatsAreStillClaimable(t *testing.T) {
|
||||
m := Manifest{Module: "nats", Claims: []Claim{{Name: "mesh-broker", Scope: ScopeMesh}}}
|
||||
// It delivers the bus, so its holder provides the bus — the rule this check now enforces.
|
||||
m := Manifest{Module: "nats",
|
||||
Provides: []Offer{{Name: "mesh-bus", Scope: ScopeMesh}},
|
||||
Claims: []Claim{{Name: "mesh-broker", Scope: ScopeMesh}}}
|
||||
if got := problemsFor(t, Shelf{"nats": m}); got != "" {
|
||||
t.Fatalf("a mesh seat was refused by the derived check: %s", got)
|
||||
}
|
||||
@@ -106,3 +109,38 @@ func TestTheProblemsAreStable(t *testing.T) {
|
||||
t.Fatalf("unstable:\n%s\n%s", first, second)
|
||||
}
|
||||
}
|
||||
|
||||
// **A build machine has no store, so it may not judge a seat.** The set is data the control plane
|
||||
// owns (novox/hq ADR 0122), and `ParseManifest` runs on the build machine too, against whatever set
|
||||
// that binary was compiled with. When the two disagreed, a valid holder of the bus seat was refused
|
||||
// mid-rollout — the compiled row said the seat delivered one provision, the store's row said
|
||||
// another, and the build failed on the copy rather than the truth. The parser judges the manifest;
|
||||
// the seat set judges the claim, where it is loaded.
|
||||
func TestTheParserDoesNotJudgeWhatOnlyTheStoreKnows(t *testing.T) {
|
||||
was := Seats()
|
||||
t.Cleanup(func() { UseSeats(was) })
|
||||
|
||||
// A store whose bus seat delivers something this module does provide.
|
||||
UseSeats([]Seat{{Name: "mesh-broker", Scope: ScopeMesh, Delivers: "amqp", Decision: "test"}})
|
||||
raw := []byte(`{"module":"lavinmq","version":"1",` +
|
||||
`"provides":[{"name":"amqp","scope":"mesh"}],` +
|
||||
`"claims":[{"name":"mesh-broker","scope":"mesh"}]}`)
|
||||
|
||||
m, err := ParseManifest(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("the parser refused a claim only the seat set can judge: %v", err)
|
||||
}
|
||||
if got := CatalogueProblems(Shelf{m.Module: m}); len(got) != 0 {
|
||||
t.Fatalf("a holder that provides what the store says the seat delivers was refused: %v", got)
|
||||
}
|
||||
|
||||
// And with the store saying the seat delivers something else, registration is what refuses it.
|
||||
UseSeats([]Seat{{Name: "mesh-broker", Scope: ScopeMesh, Delivers: "mesh-bus", Decision: "test"}})
|
||||
if _, err := ParseManifest(raw); err != nil {
|
||||
t.Fatalf("the parser judged it the second time: %v", err)
|
||||
}
|
||||
got := strings.Join(CatalogueProblems(Shelf{m.Module: m}), "; ")
|
||||
if !strings.Contains(got, `does not provide "mesh-bus"`) {
|
||||
t.Fatalf("registration did not refuse a holder that cannot answer for the seat: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user