carlos / platform Public

fleet-routes-followups: host deferred minors (#457 1a, Task 12)

- hubFleetOwners' comment and the budget test's parity comment no longer
  say the forward phase and the edge cannot disagree on owners: the edge's
  Reload reads the fleets table itself, so they can for one pass; they
  converge on the next reads and fail closed (the edge serves a forward
  row only on its own read of the owner).
- TestForwardRequestBudget now also checks the edges-file PUT when the
  forward row goes: budgetRun deletes the fleet app's records after the
  steady pass and the armed hub must publish exactly one more edges file
  than the dormant hub. A mutation making the writer skip a PUT that only
  shrinks the file passed the old test and fails this one.
- budgetStore's doc and the test's doc say the counts are on the
  optional-interface fallbacks (the counting store hides the DirStore's
  ConditionalGetter, ETagLister, ModLister, SizeLister, PageLister,
  Opener), as the telemetry rows are with the index off.
- Task 13 carry checked, no change: fpWorld's refused forward row of a
  foreign account (baj on bah's fleet) and its aliases are excluded from
  the edges file (fpRefusedNames).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev f356645e1842800f9cf046a0d88af8c15eb3b022 parent ae39931
2 files changed, +60 −19
  • internal/host/fleet_forward_budget_test.go +50 −16
  • internal/host/hub.go +10 −3
diff --git a/internal/host/fleet_forward_budget_test.go b/internal/host/fleet_forward_budget_test.go
index a366d2aba..d1e7502df 100644
--- a/internal/host/fleet_forward_budget_test.go
+++ b/internal/host/fleet_forward_budget_test.go
@@ -60,9 +60,11 @@ func TestBoxProvisionConfigArmsForwardingOnTheHubOnly(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- // Parity: the owners the edge's fleet arm, the edges file and the alias
- // pass judge by on this box (fleetArmInputs), so the phase never mints a
- // row the hub's edge refuses for want of an owner, nor the reverse.
+ // Parity: the owners the edges file and the alias pass judge by on this
+ // box (fleetArmInputs) are the phase's own read. The edge's Reload reads
+ // the fleets table itself, so it can trail them by one pass; it
+ // converges on its next reload and fails closed meanwhile, serving a
+ // forward row only on its own read of the owner (hubFleetOwners).
edgeOwners, edgeHub, tunnels, err := fleetArmInputs(reg, hub)
if err != nil {
t.Fatal(err)
@@ -94,7 +96,10 @@ func TestBoxProvisionConfigArmsForwardingOnTheHubOnly(t *testing.T) {
}
// budgetStore counts every call made through it by operation and key while
-// counting is on.
+// counting is on. It embeds release.Store, so it hides every optional
+// interface the DirStore below has (release.ConditionalGetter, ETagLister,
+// ModLister, SizeLister, PageLister and Opener among them): each reader
+// that asks for one takes its fallback path here, on both hubs alike.
type budgetStore struct {
release.Store
mu sync.Mutex
@@ -287,8 +292,11 @@ func (w *budgetWorld) passSet(t *testing.T, cfg provision.ReconcileConfig) {
// nothing (the hub as it is today, settled), then two with the forward
// phase as armed says. It returns the calls of the first of those (where a
// forward row first appears) and of the second (steady state: nothing
-// changing).
-func budgetRun(t *testing.T, c budgetCase, armed bool) (first, steady map[string]int, reg *registry.Registry) {
+// changing). Then it deletes the fleet app's records and returns the calls
+// of one more pass set (gone: where the armed hub retires the rows). On an
+// armed world it checks a forward row stands at each host before the
+// deletion and none after.
+func budgetRun(t *testing.T, c budgetCase, armed bool) (first, steady, gone map[string]int) {
t.Helper()
w := newBudgetWorld(t, c)
cfg := BoxProvisionConfig(w.reg, func(k string) string {
@@ -315,7 +323,26 @@ func budgetRun(t *testing.T, c budgetCase, armed bool) (first, steady map[string
}
first = w.s.count(func() { w.passSet(t, cfg) })
steady = w.s.count(func() { w.passSet(t, cfg) })
- return first, steady, w.reg
+ if armed {
+ for _, h := range c.shopHosts {
+ rt, err := w.reg.Get(h)
+ if err != nil || rt == nil || !rt.IsForward() {
+ t.Fatalf("the armed hub holds no forward row at %s (%+v, %v): the comparison measures nothing", h, rt, err)
+ }
+ }
+ }
+ for _, h := range c.shopHosts {
+ if err := provision.DeleteRecord(context.Background(), w.s, fpOwner, "shop", h); err != nil {
+ t.Fatalf("delete record %s: %v", h, err)
+ }
+ }
+ gone = w.s.count(func() { w.passSet(t, cfg) })
+ for _, h := range c.shopHosts {
+ if rt, err := w.reg.Get(h); err != nil || rt != nil {
+ t.Fatalf("after the records went the hub still holds %+v at %s (%v)", rt, h, err)
+ }
+ }
+ return first, steady, gone
}
// writes is how many PUTs and DELETEs calls holds.
@@ -376,7 +403,16 @@ func showCalls(m map[string]int) string {
// (C = 1: no other row of the owner's is on the hub). Bindings, build
// states, retention, canary status, the domains pass and the alias pass
// without a catch-all: unchanged. The edges file: one PUT when the row
-// appears, none in steady state.
+// appears, none in steady state, and one when the row goes (the app's
+// records deleted, the phase retires the row).
+//
+// The numbers hold for the store this test counts through, as the telemetry
+// rows hold for the index off: budgetStore hides the store's optional
+// interfaces, so every reader that would use one (a conditional GET, an
+// ETag or modification-time listing, a paged listing) runs its fallback, on
+// the dormant hub and the armed one alike. A production store that has them
+// can make other calls than these on both hubs; the difference between the
+// two is what this test pins.
//
// Two more cases (R3-2): an instance catch-all claim for shop adds one List
// of the app's instance records per alias pass (K = 1); two of shop's
@@ -426,14 +462,8 @@ func TestForwardRequestBudget(t *testing.T) {
twoHosts},
} {
t.Run(tc.name, func(t *testing.T) {
- beforeFirst, before, _ := budgetRun(t, tc.c, false)
- afterFirst, after, reg := budgetRun(t, tc.c, true)
- for _, h := range tc.c.shopHosts {
- rt, err := reg.Get(h)
- if err != nil || rt == nil || !rt.IsForward() {
- t.Fatalf("the armed hub holds no forward row at %s (%+v, %v): the comparison measures nothing", h, rt, err)
- }
- }
+ beforeFirst, before, beforeGone := budgetRun(t, tc.c, false)
+ afterFirst, after, afterGone := budgetRun(t, tc.c, true)
if got := callDiff(before, after); !reflect.DeepEqual(got, tc.want) {
t.Errorf("steady-state difference per pass set:%s\nwant:%s", showCalls(got), showCalls(tc.want))
}
@@ -454,6 +484,10 @@ func TestForwardRequestBudget(t *testing.T) {
if b, a := edgesPuts(beforeFirst), edgesPuts(afterFirst); a != b+1 {
t.Errorf("edges file PUTs on the pass the forward row appears: %d, want %d (one more than the dormant hub's)%s", a, b+1, showCalls(callDiff(beforeFirst, afterFirst)))
}
+ // The pass where the forward row goes: one more PUT again.
+ if b, a := edgesPuts(beforeGone), edgesPuts(afterGone); a != b+1 {
+ t.Errorf("edges file PUTs on the pass the forward row goes: %d, want %d (one more than the dormant hub's)%s", a, b+1, showCalls(callDiff(beforeGone, afterGone)))
+ }
})
}
}
diff --git a/internal/host/hub.go b/internal/host/hub.go
index f67dda28a..94cf7fadd 100644
--- a/internal/host/hub.go
+++ b/internal/host/hub.go
@@ -39,9 +39,16 @@ func fleetArmInputs(reg *registry.Registry, getenv func(string) string) (owners
// routes spec §4.3): each fleet in this box's own fleets table with its
// owning account, read afresh on each call, so a loop that builds its config
// once still sees every fleet created or deleted since. It is also where
-// fleetArmInputs reads the owners the edge's fleet arm, the edges file and
-// the alias pass judge by, so the forward phase and the edge cannot disagree
-// about who owns a fleet.
+// fleetArmInputs reads the owners the edges file and the alias pass judge
+// by, so the forward phase and those two read the same table the same way.
+//
+// The edge's Reload reads the table itself (ListFleets), so for one pass
+// after a fleet is created, deleted or changes owner the phase and the edge
+// can disagree. They converge on their next reads, and the disagreement
+// fails closed: the edge serves a forward row only when its own read names
+// the row's account as the fleet's owner, so a row the phase minted first
+// is refused until the edge reads the same, and a row the phase has not yet
+// retired is refused once the edge's read stops naming that owner.
func hubFleetOwners(reg *registry.Registry) func() (map[string]string, error) {
return func() (map[string]string, error) {
fleets, err := reg.ListFleets()