fleets: write config acks in the fleet corner; skip door snapshot list
#966. A bucketless fleet box reaches storage through the hub's store door, which refuses the platform-root control/config-ack/ PUT and the status/boxes/ LIST on purpose. Fix the clients, not the door: - host: configAckFunc/configAckWriter write acks under fleets/<fleet>/ on a door box (doorFleet: openDeployStoreEnv's branch rule). - host: the alias pass on a door box no longer lists status/boxes/; it reports incomplete exactly as the refused list did (ruling 966-b). - console: relay status also reads fleets/<F>/control/config-ack/ for the app's own placed fleet (placedFleet, shared with chooseSealKey), counting an ack only for a host whose own placement is F and whose key names the body's host. - edge tests pin both door refusals; moves note the root-key coupling.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/console/apirelay.go+5 −3internal/console/fleetsecrets_relay_test.go+73 −0internal/console/relayops.go+80 −15internal/console/sealkey.go+33 −16internal/edge/storedoor_test.go+13 −0internal/host/agent.go+39 −1internal/host/configack_door_test.go+184 −0internal/host/movesfinal.go+1 −0internal/host/movesoffline_land.go+1 −0internal/host/movesrollback.go+1 −0
Intent
<task-notification> <task-id>a9fd60e14bb47d1b0</task-id> <tool-use-id>toolu_01YHR5anG8uFGRpR69V2jFDH</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2b517942-2259-467d-a8d0-994fd28c9e84/tasks/a9fd60e14bb47d1b0.output</output-file> <status>completed</status> <summary>Agent "Implement #1061 Task 1" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE Commits: - `882a3f34 activator: a join waits for its build install; not a crash (#1061)` - `a9455fe6 activator: one install deadline; outages are not installs (#1061 r1)` - `9f1d6a98 activator: one keyed install wait, set and cleared in one place (#1061 r2)` - `55b439c8 activator: key the install wait by row lifetime and target (#1061 r3)` Tests: Astra's sequence (install refusal before the permit, permit and step at t=0, no further wake, step at 45 s) fails on 9f1d6a98 by answering switched-failed, and now stays open. All seven W1 subtests and the rules test pass. Both full packages passed in one run with no flakes (activator 301 s, rollout 6 s), and the build, vet and darwin/windows builds are clean. The install wait is keyed by row lifetime and target only. I dropped the deploy ID too, since a retry of the same target gets a new ID and would orphan the wait just as the permit did. A wait that starts before any deploy is seen carries over to the target seen afterwards and keeps its start time. A new permit keeps the wait; a new target clears it. One thing to know: my first version of the pre-permit test wrongly passed on 9f1d6a98, because the test's own setup was ignored. I fixed the setup and the test now shows the failure. Concerns: none new. As before, a join that waited for its install and whose build then fails at start halts at 10 minutes with the install reason instead of at 32 s. Report (final fix appended): /home/paulca/amadan.net/carlos/platform/.claude/worktrees/sr-followups/.superpowers/sdd/plan-1061/task-1-report.md</result> <usage><subagent_tokens>230068</subagent_tokens><tool_uses>13</tool_uses><duration_ms>535609</duration_ms></usage> </task-notification>
<task-notification> <task-id>b2qbhup22</task-id> <tool-use-id>toolu_01D1TGqQiHg1MTofPSnwSTMJ</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2b517942-2259-467d-a8d0-994fd28c9e84/tasks/b2qbhup22.output</output-file> <status>completed</status> <summary>Background command "git log --oneline -3 && S=/home/paulca/.paseo/zerosub/homes/claude-37fe90ef3f56/plugins/cache/claude-plugins-official/superpowers/7.0.2/skills/subagent-driven-development; git diff 9f1d6a98..55b439c8 --stat; git diff -U10 9f1d6a98..55b439c8 > .superpowers/sdd/plan-1061/review-9f1d6a98..55b439c8.diff; P=.superpowers/sdd/plan-1061; timeout 1800 codex exec -m gpt-6-astra -c model_reasoning_effort=high -s read-only "Scoped final check, read-only (do not modify files, index or bra ... [998 characters truncated] ... ild that never started, or let a genuinely crashed started build avoid its failure answer)? Minors separately. Concise." </dev/null > $P/task-1-astra-final.txt 2>&1; f=$P/task-1-astra-final.txt; n=$(grep -n '^codex$' $f | tail -1 | cut -d: -f1); sed -n "$n,\$p" $f | head -30" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a9b3e2da465980c28</task-id> <tool-use-id>toolu_016Zpnhs7sNSZfFUndefNG3Y</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2b517942-2259-467d-a8d0-994fd28c9e84/tasks/a9b3e2da465980c28.output</output-file> <status>completed</status> <summary>Agent "Implement #966 fix" is waiting on its own background work</summary> <note>This agent stopped with background work of its own still running. It may resume on its own when that work completes or reports, and the same task-id notifies again if it does; the result below may be interim.</note> <result>I'll wait for the host suite notification.</result> <usage><subagent_tokens>144481</subagent_tokens><tool_uses>52</tool_uses><duration_ms>1185412</duration_ms></usage> </task-notification>
Attributed to this commit: 7.99 g CO₂e (914,110 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on sr-followups, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/internal/console/apirelay.go b/internal/console/apirelay.go| index 7902c1daa..7b2014438 100644 |
| --- a/internal/console/apirelay.go |
| +++ b/internal/console/apirelay.go |
| @@ -59,6 +59,7 @@ import ( |
| "time" |
| "github.com/carlosframework/platform/internal/appconfig" |
| + "github.com/carlosframework/platform/internal/registry" |
| "github.com/carlosframework/platform/internal/relay" |
| ) |
| @@ -364,11 +365,12 @@ func (s *Server) relayReply(ctx context.Context, acct *Account, app string, rec |
| // every status call). |
| var acks []appconfig.ConfigAck |
| if rec.Enabled && len(routes) > 0 { |
| - hosts := make(map[string]bool, len(routes)) |
| + hosts := make(map[string]string, len(routes)) |
| for _, rt := range routes { |
| - hosts[rt.Host] = true |
| + fleet, _ := registry.FleetPlacement(rt.Region) |
| + hosts[rt.Host] = fleet |
| } |
| - acks, err = s.relayConfigAcks(ctx, hosts) |
| + acks, err = s.relayConfigAcks(ctx, acct.Sqid, app, hosts) |
| if err != nil { |
| return apiRelayReply{}, err |
| } |
diff --git a/internal/console/fleetsecrets_relay_test.go b/internal/console/fleetsecrets_relay_test.go| index 7f3bc9ead..6aa15d3a9 100644 |
| --- a/internal/console/fleetsecrets_relay_test.go |
| +++ b/internal/console/fleetsecrets_relay_test.go |
| @@ -14,7 +14,9 @@ package console |
| import ( |
| "context" |
| + "encoding/json" |
| "fmt" |
| + "maps" |
| "net/http" |
| "path/filepath" |
| "strings" |
| @@ -23,7 +25,9 @@ import ( |
| "github.com/carlosframework/platform/internal/appconfig" |
| "github.com/carlosframework/platform/internal/objstore" |
| + "github.com/carlosframework/platform/internal/registry" |
| "github.com/carlosframework/platform/internal/relay" |
| + "github.com/carlosframework/platform/internal/release" |
| ) |
| // fsrRelayWorld is fcmFleetShop (bab, home, shop placed on it, the |
| @@ -650,3 +654,72 @@ func TestRelayReconcileReportsSealKeyFailures(t *testing.T) { |
| }) |
| } |
| } |
| + |
| +// TestRelayStatusReadsFleetCornerAcks (#966): a door box writes its config |
| +// ack under fleets/<its fleet>/, the only keyspace the store door lets it |
| +// write. relay status for shop, placed on home, reads an ack there for a |
| +// host placed on home as adopted. The fleet corner is any home box's to |
| +// write, so it is trusted only for home's own hosts: an ack under home for |
| +// a host placed on away, one under away for a host placed on home, and one |
| +// keyed for a home host whose body names an away host, are all ignored. |
| +func TestRelayStatusReadsFleetCornerAcks(t *testing.T) { |
| + w := fsrRelayWorld(t, "code-fsr-acks", true) |
| + ctx := context.Background() |
| + if status, body := postJSON(t, fleetsURL(w.fx, w.fx.sqid)+"/new", map[string]string{"name": "away", "bucket": "away-data"}, w.token); status != http.StatusOK { |
| + t.Fatalf("create away = %d %v", status, body) |
| + } |
| + for _, rt := range []registry.Route{ |
| + {Host: "a.shop.example.com", Region: "fleet/home"}, |
| + {Host: "b.shop.example.com", Region: "fleet/away"}, |
| + {Host: "c.shop.example.com", Region: "fleet/home"}, |
| + } { |
| + rt.Account, rt.App, rt.Kind, rt.Status = w.fx.sqid, "shop", "service", "ready" |
| + rt.Unit = "shop-" + rt.Host[:1] + ".service" |
| + w.fx.addRoute(t, rt) |
| + } |
| + fsrEnableRelay(t, w, "shop") |
| + issued := relayRecord(t, w.fx, "shop").IssuedSuffixes |
| + if issued["eu-west-1"] == "" { |
| + t.Fatalf("enable issued nothing for eu-west-1: %v", issued) |
| + } |
| + |
| + home := release.NewPrefixStore(w.fx.rel, "fleets/home/") |
| + away := release.NewPrefixStore(w.fx.rel, "fleets/away/") |
| + for _, c := range []struct { |
| + store release.Store |
| + host string |
| + }{ |
| + {home, "a.shop.example.com"}, |
| + {home, "b.shop.example.com"}, |
| + {away, "c.shop.example.com"}, |
| + } { |
| + if err := appconfig.WriteConfigAck(ctx, c.store, appconfig.ConfigAck{ |
| + Box: "box-1", Host: c.host, Shape: "unit", At: time.Now(), |
| + Restarted: true, RelaySuffixes: maps.Clone(issued), |
| + }); err != nil { |
| + t.Fatalf("seed ack %s: %v", c.host, err) |
| + } |
| + } |
| + |
| + // A home box forging b's ack under a key naming c, a home host: the |
| + // body's Host never carries an ack across to another host. |
| + forged, err := json.Marshal(appconfig.ConfigAck{ |
| + Box: "box-9", Host: "b.shop.example.com", Shape: "unit", At: time.Now(), |
| + Restarted: true, RelaySuffixes: maps.Clone(issued), |
| + }) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := home.Put(ctx, appconfig.ConfigAckKey("box-9", "c.shop.example.com"), forged, ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + |
| + _, out := getJSON(t, relayURL(w.fx, "shop"), w.token) |
| + rows := relayRouteRows(t, out) |
| + wantRoute(t, rows, "a.shop.example.com", "unit", "adopted at", "restarted") |
| + for _, host := range []string{"b.shop.example.com", "c.shop.example.com"} { |
| + if got := str(t, rows[host], "delivery"); got != "written, awaiting delivery" { |
| + t.Fatalf("%s delivery = %q, want an ack from a fleet the host is not placed on ignored", host, got) |
| + } |
| + } |
| +} |
diff --git a/internal/console/relayops.go b/internal/console/relayops.go| index d3e595b28..3f8c00af8 100644 |
| --- a/internal/console/relayops.go |
| +++ b/internal/console/relayops.go |
| @@ -869,6 +869,7 @@ type relayRoute struct { |
| Socket string |
| Unit string |
| Environment string |
| + Region string // the host's own placement: "fleet/<name>" on a fleet |
| } |
| // relayAppRoutes enumerates an app's routes from both places the console can |
| @@ -910,7 +911,7 @@ func (s *Server) relayAppRoutes(ctx context.Context, acct, app string) ([]relayR |
| addr = all[0] |
| } |
| out = append(out, relayRoute{Host: rec.Host, Kind: rec.Kind, Addr: addr, |
| - Unit: rec.Unit, Environment: rec.Environment}) |
| + Unit: rec.Unit, Environment: rec.Environment, Region: rec.Region}) |
| } |
| if s.cfg.Registry == "" { |
| return out, nil |
| @@ -934,7 +935,7 @@ func (s *Server) relayAppRoutes(ctx context.Context, acct, app string) ([]relayR |
| } |
| seen[rt.Host] = true |
| out = append(out, relayRoute{Host: rt.Host, Kind: rt.Kind, Addr: routeAddr(rt), |
| - Socket: rt.Socket, Unit: rt.Unit, Environment: rt.Environment}) |
| + Socket: rt.Socket, Unit: rt.Unit, Environment: rt.Environment, Region: rt.Region}) |
| } |
| sort.Slice(out, func(i, j int) bool { return out[i].Host < out[j].Host }) |
| return out, nil |
| @@ -1353,18 +1354,77 @@ func (s *Server) relayHeartbeats(ctx context.Context) ([]relay.Heartbeat, error) |
| } |
| // relayConfigAcks reads every per-route config-adoption acknowledgement |
| -// under configAckPrefix whose HOST — a key's basename, ConfigAckKey's own |
| -// "<box>/<host>.json" shape — is in hosts. There is no per-host box list |
| -// to narrow the LISTING by, the same limit relayHeartbeats accepts for |
| -// control/relay-ack/, so this still lists every key under the prefix; but |
| -// hosts filters that listing down to this app's own routes before a |
| -// single Get is issued, so a status call costs one List plus a Get per |
| -// THIS APP's route, never a Get per ack in the whole fleet (review |
| -// finding 2026-09-07 — relayReply used to pass every ack for every app on |
| -// the deployment through this filter instead of narrowing the read |
| -// itself). |
| -func (s *Server) relayConfigAcks(ctx context.Context, hosts map[string]bool) ([]appconfig.ConfigAck, error) { |
| - keys, err := s.cfg.Releases.List(ctx, configAckPrefix) |
| +// for acct/app's route hosts. hosts maps each host to the fleet its own |
| +// placement names ("" for none). |
| +// |
| +// Two places hold acks. A box with a bucket writes the platform-root |
| +// configAckPrefix, which no fleet credential can write, so an ack there is |
| +// read for any of hosts. A door box (a bucketless fleet box, #966) cannot |
| +// write the root and writes fleets/<its fleet>/ + configAckPrefix instead. |
| +// Any box of that fleet can write any key in that corner, so it is read |
| +// only for the fleet the app is placed on (placedFleet: refused unless it |
| +// is acct's own, the same fleet whose key seals the app's secrets), and an |
| +// ack there counts only for a host whose own placement is that fleet. The |
| +// ack body's Box and Host never choose the fleet. |
| +// |
| +// There is no per-host box list to narrow the LISTING by, the same limit |
| +// relayHeartbeats accepts for control/relay-ack/, so each place is listed |
| +// whole; but hosts filters the listing down to this app's own routes |
| +// before a single Get is issued, so a status call costs a List per place |
| +// plus a Get per THIS APP's route, never a Get per ack in the whole fleet |
| +// (review finding 2026-09-07). |
| +func (s *Server) relayConfigAcks(ctx context.Context, acct, app string, hosts map[string]string) ([]appconfig.ConfigAck, error) { |
| + out, err := s.relayAcksUnder(ctx, configAckPrefix, func(host string) bool { |
| + _, ok := hosts[host] |
| + return ok |
| + }) |
| + if err != nil { |
| + return nil, err |
| + } |
| + onFleet := false |
| + for _, f := range hosts { |
| + onFleet = onFleet || f != "" |
| + } |
| + if !onFleet { |
| + return out, nil |
| + } |
| + fleet, err := s.relayAckFleet(acct, app) |
| + if err != nil { |
| + // Fail closed: the fleet corner is unread, so its routes read as |
| + // awaiting delivery, never as adopted on an unchecked fleet. |
| + log.Printf("console: relay config acks %s/%s: %v", acct, app, err) |
| + return out, nil |
| + } |
| + if fleet == "" { |
| + return out, nil |
| + } |
| + more, err := s.relayAcksUnder(ctx, "fleets/"+fleet+"/"+configAckPrefix, func(host string) bool { |
| + return hosts[host] == fleet |
| + }) |
| + if err != nil { |
| + return nil, err |
| + } |
| + return append(out, more...), nil |
| +} |
| + |
| +// relayAckFleet is the fleet acct/app is placed on, checked to be acct's own |
| +// (placedFleet), or "" for an app placed nowhere. |
| +func (s *Server) relayAckFleet(acctSqid, app string) (string, error) { |
| + acct, err := s.store.AccountBySqid(acctSqid) |
| + if err != nil { |
| + return "", err |
| + } |
| + if acct == nil { |
| + return "", errUnknownAccount |
| + } |
| + fleet, _, err := s.placedFleet(acct, app) |
| + return fleet, err |
| +} |
| + |
| +// relayAcksUnder reads every ack under prefix whose HOST (a key's basename, |
| +// ConfigAckKey's own "<box>/<host>.json" shape) want admits. |
| +func (s *Server) relayAcksUnder(ctx context.Context, prefix string, want func(host string) bool) ([]appconfig.ConfigAck, error) { |
| + keys, err := s.cfg.Releases.List(ctx, prefix) |
| if err != nil { |
| return nil, err |
| } |
| @@ -1377,7 +1437,7 @@ func (s *Server) relayConfigAcks(ctx context.Context, hosts map[string]bool) ([] |
| if idx := strings.LastIndexByte(host, '/'); idx >= 0 { |
| host = host[idx+1:] |
| } |
| - if !hosts[host] { |
| + if !want(host) { |
| continue |
| } |
| body, _, err := s.cfg.Releases.Get(ctx, key) |
| @@ -1392,6 +1452,11 @@ func (s *Server) relayConfigAcks(ctx context.Context, hosts map[string]bool) ([] |
| log.Printf("console: relay config ack %s: %v", key, err) |
| continue |
| } |
| + if a.Host != host { |
| + // The key names the host the box wrote it for; a body naming |
| + // another is not this host's ack. |
| + continue |
| + } |
| out = append(out, a) |
| } |
| return out, nil |
diff --git a/internal/console/sealkey.go b/internal/console/sealkey.go| index 0f3223dfc..e7ec9f29b 100644 |
| --- a/internal/console/sealkey.go |
| +++ b/internal/console/sealkey.go |
| @@ -123,30 +123,17 @@ func (s *Server) chooseSealKey(ctx context.Context, acctSqid, app string) (sealC |
| if !found { |
| return sealChoice{}, errUnknownApp{App: app} |
| } |
| - placement, reg, err := s.sealPlacement(acct, app) |
| + name, row, err := s.placedFleet(acct, app) |
| if err != nil { |
| - return sealChoice{}, fmt.Errorf("console: seal key: placement of %s/%s: %w", acct.Sqid, app, err) |
| + return sealChoice{}, err |
| } |
| - if placement == "" { |
| + if name == "" { |
| pub, err := s.deploymentSealKey() |
| if err != nil { |
| return sealChoice{}, err |
| } |
| return sealChoice{sqid: acct.Sqid, pub: pub, bound: appconfig.BoundSealing()}, nil |
| } |
| - name, ok := registry.FleetPlacement(placement) |
| - if !ok { |
| - // Not a placement any door writes. Refused rather than read as |
| - // "not placed": the app may well run on a fleet. |
| - return sealChoice{}, fmt.Errorf("console: seal key: %s/%s has placement %q, which names no fleet", acct.Sqid, app, placement) |
| - } |
| - row, err := reg.GetFleet(name) |
| - if err != nil { |
| - return sealChoice{}, fmt.Errorf("console: seal key: fleet %s: %w", name, err) |
| - } |
| - if row == nil || row.Account != acct.Sqid { |
| - return sealChoice{}, errFleetNotOwned{Fleet: name} |
| - } |
| if row.SecretsPub == "" { |
| return sealChoice{}, errFleetNoSecretsKey{Fleet: name} |
| } |
| @@ -163,6 +150,36 @@ func (s *Server) chooseSealKey(ctx context.Context, acctSqid, app string) (sealC |
| return sealChoice{sqid: acct.Sqid, pub: pub, bound: true, fleet: name}, nil |
| } |
| +// placedFleet is the fleet acct's app is placed on, with its registry row, |
| +// or "" and nil for an app placed nowhere. A placement that names no fleet, |
| +// or a fleet that is not acct's own, is refused, never read as "not |
| +// placed". chooseSealKey and relayConfigAcks (#966) both read it, so the |
| +// fleet whose key seals an app's secrets is the fleet whose corner its |
| +// config acks are read from. |
| +func (s *Server) placedFleet(acct *Account, app string) (string, *registry.Fleet, error) { |
| + placement, reg, err := s.sealPlacement(acct, app) |
| + if err != nil { |
| + return "", nil, fmt.Errorf("console: seal key: placement of %s/%s: %w", acct.Sqid, app, err) |
| + } |
| + if placement == "" { |
| + return "", nil, nil |
| + } |
| + name, ok := registry.FleetPlacement(placement) |
| + if !ok { |
| + // Not a placement any door writes. Refused rather than read as |
| + // "not placed": the app may well run on a fleet. |
| + return "", nil, fmt.Errorf("console: seal key: %s/%s has placement %q, which names no fleet", acct.Sqid, app, placement) |
| + } |
| + row, err := reg.GetFleet(name) |
| + if err != nil { |
| + return "", nil, fmt.Errorf("console: seal key: fleet %s: %w", name, err) |
| + } |
| + if row == nil || row.Account != acct.Sqid { |
| + return "", nil, errFleetNotOwned{Fleet: name} |
| + } |
| + return name, row, nil |
| +} |
| + |
| // sealPlacement is appPlacement (the store's column, then routes) with the |
| // registry it read. A console with no registry reads the column alone, and |
| // cannot resolve a fleet the column names: reg is nil then, and a fleet |
diff --git a/internal/edge/storedoor_test.go b/internal/edge/storedoor_test.go| index b1ac5cd99..1597deb5a 100644 |
| --- a/internal/edge/storedoor_test.go |
| +++ b/internal/edge/storedoor_test.go |
| @@ -229,6 +229,14 @@ func TestStoreDoorACLMatrix(t *testing.T) { |
| {"fleets/other/status/boxes/box-a.json", opWrite, false, "and it cannot write there"}, |
| {"fleets/other/status/boxes/box-a.json", opDelete, false, "nor delete there"}, |
| {"fleets/pix/status/boxes/box-a.json", opWrite, false, "fleet prefix must not match a longer fleet name"}, |
| + // #966: a door box's config acks go into its own corner; the |
| + // platform-root control/config-ack/ stays closed to every box (a |
| + // fleet credential there could forge another tenant's ack). |
| + {"fleets/pi/control/config-ack/box-a/app.example.com.json", opWrite, true, "own config ack, in the fleet corner"}, |
| + {"fleets/pi/control/config-ack/box-a/app.example.com.json", opRead, true, "the ack writer reads before it CASes"}, |
| + {"control/config-ack/box-a/app.example.com.json", opWrite, false, "#966: never the platform-root ack"}, |
| + {"control/config-ack/box-a/app.example.com.json", opRead, false, "#966: nor read one"}, |
| + {"fleets/other/control/config-ack/box-a/app.example.com.json", opWrite, false, "nor another fleet's ack"}, |
| {"fleets/pi", opWrite, false, "the fleet prefix itself is not an object"}, |
| // --- domains/ claims: never through aclRead (#215) — serveClaim |
| @@ -375,6 +383,11 @@ func TestACLListScope(t *testing.T) { |
| {"bootstrap/", "", false}, |
| {"", "", false}, |
| {"status/", "", false}, |
| + // #966: the platform-root snapshots are every platform box's |
| + // hostnames and backends; a fleet box never lists them. |
| + {"status/boxes/", "", false}, |
| + {"status/boxes", "", false}, |
| + {"control/config-ack/", "", false}, |
| } |
| for _, c := range cases { |
| got, ok := aclListScope(testSqid, testFleet, c.prefix) |
diff --git a/internal/host/agent.go b/internal/host/agent.go| index 30782f1f2..d0f031acc 100644 |
| --- a/internal/host/agent.go |
| +++ b/internal/host/agent.go |
| @@ -1517,7 +1517,16 @@ func aliasPassReportingComplete(ctx context.Context, store release.Store, reg *r |
| } |
| start := auth.passBegin() |
| defer auth.passEnd() |
| - deploymentRoutes, routesWhole := edgesfile.DeploymentRoutesComplete(ctx, store, time.Now()) |
| + // A door box (#966) does not fold: the door refuses a list of the |
| + // platform-root status/boxes/ (other tenants' snapshots), and a fleet |
| + // box publishes no edges file. The route set stays unknown, so the pass |
| + // reports incomplete exactly as the refused list did (ruling 966-b), |
| + // without the request or its log line. |
| + var deploymentRoutes map[string]bool |
| + routesWhole := false |
| + if doorFleet(os.Getenv) == "" { |
| + deploymentRoutes, routesWhole = edgesfile.DeploymentRoutesComplete(ctx, store, time.Now()) |
| + } |
| rep := domains.AliasReport{DeploymentRoutesPartial: deploymentRoutes != nil && !routesWhole, Region: region, StartupNoRemoval: startup} |
| // The apps domain as domainsTickConfig reads it: account subdomains |
| // (spec §4.4) derive <prefix>.<name>.<apps> from it, and none without it. |
| @@ -2086,6 +2095,7 @@ func (p *pendingDirs) appeared() (host string, ok bool) { |
| // delivery itself depends on, and failing the whole sync pass over it would |
| // make a bucket blip on the ack object cost every OTHER route its config. |
| func configAckFunc(ctx context.Context, store release.Store, logPrefix string) func(appconfig.ConfigAck) { |
| + store = configAckStore(store, os.Getenv) |
| box := BoxLabel() |
| return func(a appconfig.ConfigAck) { |
| a.Box = box |
| @@ -2101,6 +2111,7 @@ func configAckFunc(ctx context.Context, store release.Store, logPrefix string) f |
| // triage T8). configAckFunc itself stays as it is, unbounded, for flag-off |
| // sync and the root pass (plan review #11). |
| func configAckWriter(store release.Store, logPrefix string) func(context.Context, appconfig.ConfigAck) { |
| + store = configAckStore(store, os.Getenv) |
| box := BoxLabel() |
| return func(ctx context.Context, a appconfig.ConfigAck) { |
| a.Box = box |
| @@ -2110,6 +2121,33 @@ func configAckWriter(store release.Store, logPrefix string) func(context.Context |
| } |
| } |
| +// configAckStore is where this box's config acks go (#966). A door box (a |
| +// bucketless fleet box: doorFleet) writes them under fleets/<fleet>/, the |
| +// only keyspace the store door lets it write; the platform-root |
| +// control/config-ack/ would 404 on every sync. The console reads them there |
| +// for a host placed on that fleet alone (relayConfigAcks). Every other box |
| +// keeps the root key. Acks only: config reads stay on the store as it is. |
| +func configAckStore(store release.Store, getenv func(string) string) release.Store { |
| + if fleet := doorFleet(getenv); fleet != "" { |
| + return release.NewPrefixStore(store, "fleets/"+fleet+"/") |
| + } |
| + return store |
| +} |
| + |
| +// doorFleet is the fleet whose store door this box's deployment store |
| +// speaks, or "" when it has a bucket or a directory: openDeployStoreEnv's |
| +// own branch rule, so it names a fleet exactly when that store is the door. |
| +func doorFleet(getenv func(string) string) string { |
| + if getenv("CARLOS_DEPLOYMENT_BUCKET") != "" || getenv("CARLOS_DEPLOYMENT_DIR") != "" { |
| + return "" |
| + } |
| + identity, err := resolveFleetIdentity(getenv) |
| + if err != nil { |
| + return "" |
| + } |
| + return identity.Fleet |
| +} |
| + |
| // reconcileMu serializes the two provisioning loops' Reconcile passes |
| // against each other, the same shape as configSyncMu above. They can |
| // genuinely overlap — instancesLoop's 5-minute pass mid-flight when a |
diff --git a/internal/host/configack_door_test.go b/internal/host/configack_door_test.go| new file mode 100644 |
| index 000000000..4c495ffbb |
| --- /dev/null |
| +++ b/internal/host/configack_door_test.go |
| @@ -0,0 +1,184 @@ |
| +package host |
| + |
| +// #966: a bucketless fleet box speaks the hub's store door, whose ACL admits |
| +// writes only under fleets/<own fleet>/** and lists no platform-root |
| +// status/boxes/. These pin the two client fixes: a config ack goes into the |
| +// fleet's own corner, and the alias pass does not issue the refused |
| +// snapshot list (it still reports incomplete, ruling 966-b). |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "os" |
| + "strings" |
| + "sync" |
| + "testing" |
| + |
| + "github.com/carlosframework/platform/internal/appconfig" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// TestDoorBackedConfigAckLandsInTheFleetCorner: the ack configAckFunc and |
| +// configAckWriter write on a door box goes on the wire as |
| +// fleets/<fleet>/control/config-ack/<label>/<host>.json, the one place the |
| +// door's write ACL admits it; a bucket-backed box (platform or fleet) still |
| +// writes the platform-root key. |
| +func TestDoorBackedConfigAckLandsInTheFleetCorner(t *testing.T) { |
| + ctx := context.Background() |
| + const want = "/store/o/fleets/pi/control/config-ack/pi-box/a.example.com.json" |
| + |
| + for _, c := range []struct { |
| + name string |
| + write func(release.Store) |
| + }{ |
| + {"configAckFunc", func(s release.Store) { |
| + configAckFunc(ctx, s, "agent")(appconfig.ConfigAck{Host: "a.example.com", Shape: "unit"}) |
| + }}, |
| + {"configAckWriter", func(s release.Store) { |
| + configAckWriter(s, "agent")(ctx, appconfig.ConfigAck{Host: "a.example.com", Shape: "unit"}) |
| + }}, |
| + } { |
| + t.Run("door/"+c.name, func(t *testing.T) { |
| + door := newDoorFake(t) |
| + for k, v := range fleetDoorEnv(door.url) { |
| + t.Setenv(k, v) |
| + } |
| + t.Setenv("CARLOS_DEPLOYMENT_BUCKET", "") |
| + t.Setenv("CARLOS_DEPLOYMENT_DIR", "") |
| + store, err := openDeployStoreEnv(ctx, os.Getenv) |
| + if err != nil { |
| + t.Fatalf("openDeployStoreEnv: %v", err) |
| + } |
| + c.write(store) |
| + hits := door.seen() |
| + if len(hits) == 0 { |
| + t.Fatal("door saw no request") |
| + } |
| + for _, h := range hits { |
| + if h.Path != want { |
| + t.Fatalf("door saw %s %s, want every ack request at %s", h.Method, h.Path, want) |
| + } |
| + } |
| + }) |
| + } |
| + |
| + t.Run("bucket-backed boxes keep the root key", func(t *testing.T) { |
| + for _, fleet := range []string{"", "pi"} { |
| + dir := t.TempDir() |
| + t.Setenv("CARLOS_DEPLOYMENT_BUCKET", "") |
| + t.Setenv("CARLOS_DEPLOYMENT_DIR", dir) |
| + t.Setenv("CARLOS_FLEET", fleet) |
| + t.Setenv("CARLOS_FLEET_BOX", "pi-box") |
| + store, err := openDeployStoreEnv(ctx, os.Getenv) |
| + if err != nil { |
| + t.Fatalf("openDeployStoreEnv: %v", err) |
| + } |
| + configAckFunc(ctx, store, "agent")(appconfig.ConfigAck{Host: "a.example.com", Shape: "unit"}) |
| + key := appconfig.ConfigAckKey(BoxLabel(), "a.example.com") |
| + if _, _, err := store.Get(ctx, key); err != nil { |
| + t.Fatalf("fleet %q: root ack %s: %v", fleet, key, err) |
| + } |
| + if keys, _ := store.List(ctx, "fleets/"); len(keys) != 0 { |
| + t.Fatalf("fleet %q: a bucket-backed box wrote under fleets/: %v", fleet, keys) |
| + } |
| + } |
| + }) |
| +} |
| + |
| +// listLog is a DirStore that records every List and ListMod prefix. With |
| +// door set it refuses a status/boxes/ listing the way the store door does. |
| +type listLog struct { |
| + *release.DirStore |
| + door bool |
| + mu sync.Mutex |
| + lists []string |
| +} |
| + |
| +func (s *listLog) record(prefix string) error { |
| + s.mu.Lock() |
| + s.lists = append(s.lists, prefix) |
| + s.mu.Unlock() |
| + if s.door && strings.HasPrefix(prefix, "status/boxes/") { |
| + return errors.New("fleetapi: list status/boxes/: unexpected status 404: 404 page not found") |
| + } |
| + return nil |
| +} |
| + |
| +func (s *listLog) List(ctx context.Context, prefix string) ([]string, error) { |
| + if err := s.record(prefix); err != nil { |
| + return nil, err |
| + } |
| + return s.DirStore.List(ctx, prefix) |
| +} |
| + |
| +// ListMod is recorded too: status.LoadBoxesComplete prefers it. |
| +func (s *listLog) ListMod(ctx context.Context, prefix string) ([]release.KeyMod, error) { |
| + if err := s.record(prefix); err != nil { |
| + return nil, err |
| + } |
| + return s.DirStore.ListMod(ctx, prefix) |
| +} |
| + |
| +func (s *listLog) listed(prefix string) bool { |
| + s.mu.Lock() |
| + defer s.mu.Unlock() |
| + for _, p := range s.lists { |
| + if strings.HasPrefix(p, prefix) { |
| + return true |
| + } |
| + } |
| + return false |
| +} |
| + |
| +// TestDoorAliasPassSkipsTheSnapshotList: on a door box the alias pass issues |
| +// no status/boxes/ list (the door refuses it, and it would read other |
| +// tenants' snapshots if it did not) and logs no snapshot failure, but still |
| +// reports incomplete, exactly as the failed list did. A bucket box still |
| +// folds and, on a healthy store, reports complete. |
| +func TestDoorAliasPassSkipsTheSnapshotList(t *testing.T) { |
| + aliasClaimCache.Reset() |
| + oldAuthority := boxAssetAuthority |
| + boxAssetAuthority = newAssetAuthority(nil) |
| + t.Cleanup(func() { |
| + aliasClaimCache.Reset() |
| + boxAssetAuthority = oldAuthority |
| + }) |
| + t.Setenv("CARLOS_REGION_HA", "") |
| + ctx := context.Background() |
| + |
| + t.Run("door box", func(t *testing.T) { |
| + for k, v := range fleetDoorEnv("https://t.example.com") { |
| + t.Setenv(k, v) |
| + } |
| + t.Setenv("CARLOS_DEPLOYMENT_BUCKET", "") |
| + t.Setenv("CARLOS_DEPLOYMENT_DIR", "") |
| + store := &listLog{DirStore: release.NewDirStore(t.TempDir()), door: true} |
| + logs := captureLog(t) |
| + ok, err := aliasPassReportingComplete(ctx, store, edgesTestRegistry(t), &aliasClaimCache, boxAssetAuthority, "", false) |
| + if err != nil { |
| + t.Fatalf("alias pass: %v", err) |
| + } |
| + if store.listed("status/boxes/") { |
| + t.Fatalf("a door box listed status/boxes/ (lists %v)", store.lists) |
| + } |
| + if ok { |
| + t.Fatal("a door box's alias pass reported complete; ruling 966-b keeps it incomplete") |
| + } |
| + if got := logs(); strings.Contains(got, "could not load box snapshots") { |
| + t.Fatalf("log = %q, want no snapshot failure line", got) |
| + } |
| + }) |
| + |
| + t.Run("bucket box", func(t *testing.T) { |
| + t.Setenv("CARLOS_FLEET", "") |
| + t.Setenv("CARLOS_DEPLOYMENT_DIR", t.TempDir()) |
| + store := &listLog{DirStore: release.NewDirStore(t.TempDir())} |
| + ok, err := aliasPassReportingComplete(ctx, store, edgesTestRegistry(t), &aliasClaimCache, boxAssetAuthority, "", false) |
| + if err != nil || !ok { |
| + t.Fatalf("alias pass: complete=%v err=%v", ok, err) |
| + } |
| + if !store.listed("status/boxes/") { |
| + t.Fatalf("a bucket box did not fold the snapshots (lists %v)", store.lists) |
| + } |
| + }) |
| +} |
diff --git a/internal/host/movesfinal.go b/internal/host/movesfinal.go| index 19f866c44..d9cf389e0 100644 |
| --- a/internal/host/movesfinal.go |
| +++ b/internal/host/movesfinal.go |
| @@ -661,6 +661,7 @@ func (f *sourceFinal) deleteRow(ctx context.Context) error { |
| // the delete. |
| func (f *sourceFinal) configAck(ctx context.Context) error { |
| cfg := f.cfg() |
| + // Root ack key: a door box writes under fleets/<fleet>/ (configAckStore, #966); moves refuse fleet routes. |
| key := appconfig.ConfigAckKey(cfg.Box, f.rec.Host) |
| body, _, err := f.s.Get(ctx, key) |
| if errors.Is(err, os.ErrNotExist) { |
diff --git a/internal/host/movesoffline_land.go b/internal/host/movesoffline_land.go| index 3dc24e6e7..c53b0f931 100644 |
| --- a/internal/host/movesoffline_land.go |
| +++ b/internal/host/movesoffline_land.go |
| @@ -935,6 +935,7 @@ func (r *landRun) config(ctx context.Context) { |
| r.landWait("config", "the config file does not hold the rendered bytes") |
| return |
| } |
| + // Root ack key: a door box writes under fleets/<fleet>/ (configAckStore, #966); moves refuse fleet routes. |
| body, _, err := r.s.Get(ctx, appconfig.ConfigAckKey(cfg.Box, r.host)) |
| if err != nil { |
| r.landWaitErr("config", "the config ack could not be read", err) |
diff --git a/internal/host/movesrollback.go b/internal/host/movesrollback.go| index 22f587e94..7ecbcbd82 100644 |
| --- a/internal/host/movesrollback.go |
| +++ b/internal/host/movesrollback.go |
| @@ -1579,6 +1579,7 @@ func (r *rollbackRun) ownership(ctx context.Context, j *moves.Journal) (rollback |
| } |
| } |
| } |
| + // Root ack key: a door box writes under fleets/<fleet>/ (configAckStore, #966); moves refuse fleet routes. |
| body, _, err := r.s.Get(ctx, appconfig.ConfigAckKey(cfg.Box, host)) |
| switch { |
| case errors.Is(err, os.ErrNotExist): |