registry: per-instance pages switch, mirrored on assets_off
Record.Pages (*bool, nil = on) converges onto Route.PagesOff / column pages_off through RouteFor and convergeOwned (SetPages). Folded into both fingerprints only when set; forbidden on forward rows; kept on upsert unless the tenant changes.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
internal/provision/provision.go+11 −0internal/provision/reconcile.go+13 −0internal/provision/reconcile_test.go+55 −0internal/registry/forward.go+3 −1internal/registry/forward_test.go+34 −0internal/registry/registry.go+49 −10internal/registry/registry_test.go+87 −0internal/registry/remote_dispatch.go+3 −0
CI failed — run details
Intent
<task-notification> <task-id>ad94244154716b3a4</task-id> <tool-use-id>toolu_01HCJjxQeGhsh329zmpnRi8T</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/d79ef2b4-4291-4945-bd45-b3f16796c4ba/tasks/ad94244154716b3a4.output</output-file> <status>completed</status> <summary>Agent "Implement Task 3: pageindex simulation" 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. I fixed both review findings and the fence mutation is still caught. Commits: - `c253122d pageindex: log every simulated Clear and keep the store test on the API` (new) - `2bdbe94a pageindex: randomized invariants and the page-key guard` (earlier) Tests: - **Covering tests:** the sim, store and guard tests pass. - **Race:** `go test ./internal/pageindex -count=3 -race` passes (85 s); `-short` passes (4.7 s). - **Fence mutation:** fails the simulation with an I1 error, then reverted. - **Refused-object mutation:** rechecked because the store test changed; it fails ("79 page objects after a Reset"), then reverted. Changes: - **Every Clear is logged now:** a test-side per-scope lock is shared by Clears and taken exclusively by Reset, so a Clear always sees one epoch. Publishes and lookups never take it. An epoch change during a Clear is now a test error instead of a silent skip. - **Store test uses only the public API:** after a Reset of every scope it checks the store holds no page objects, every lookup misses and nothing is reserved. Concerns: none new. Report (fix section appended): /home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-page-cache-1/.superpowers/sdd/2026-11-08-edge-page-cache-plan-1-home/task-3-report.md</result> <usage><subagent_tokens>148558</subagent_tokens><tool_uses>6</tool_uses><duration_ms>171743</duration_ms></usage> </task-notification>
<task-notification> <task-id>b8shuzjk8</task-id> <tool-use-id>toolu_01TpydYP8BJH9oTbjB7QxVYw</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/d79ef2b4-4291-4945-bd45-b3f16796c4ba/tasks/b8shuzjk8.output</output-file> <status>completed</status> <summary>Background command "Run scoped Astra re-review of Task 3 fix" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 24.6 g CO₂e (3,208,016 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on edge-page-cache-1, 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/provision/provision.go b/internal/provision/provision.go| index ed7d3e585..e0d80b5ac 100644 |
| --- a/internal/provision/provision.go |
| +++ b/internal/provision/provision.go |
| @@ -221,6 +221,11 @@ type Record struct { |
| // (a record from before the field) publishes nothing. Converged onto |
| // the route row beside Assets. |
| AssetGen string `json:"asset_gen,omitempty"` |
| + // Pages is the instance's page-cache opt-out, shaped like Assets: absent |
| + // means on, false means the home box publishes no page index. A POINTER |
| + // for the same reason. PagesOn is the accessor. Converged onto the route |
| + // row (PagesOff) with no generation of its own. |
| + Pages *bool `json:"pages,omitempty"` |
| // Replica is NOT a separate record field: Role carries the role |
| // vocabulary alone (ValidRole's door), and every reader derives the |
| @@ -564,6 +569,12 @@ func (r Record) StatusNamedOrDefault() bool { |
| return false |
| } |
| +// PagesOn reports whether this instance takes part in the page cache: true |
| +// unless Pages is present and false. |
| +func (r Record) PagesOn() bool { |
| + return r.Pages == nil || *r.Pages |
| +} |
| + |
| // AssetsOn reports whether this instance follows the release's asset |
| // declaration: true unless Assets is present and false. |
| func (r Record) AssetsOn() bool { |
diff --git a/internal/provision/reconcile.go b/internal/provision/reconcile.go| index 45970398e..af510bd4b 100644 |
| --- a/internal/provision/reconcile.go |
| +++ b/internal/provision/reconcile.go |
| @@ -585,6 +585,7 @@ func RouteFor(rec Record, dataDir, seed string, nested bool, policy *UpdatePolic |
| Steering: rec.Steering, |
| AssetsOff: !rec.AssetsOn(), |
| AssetGen: rec.AssetGen, |
| + PagesOff: !rec.PagesOn(), |
| Replicas: replicaSet(rec.Replicas), |
| Replica: rec.Role == "replica", |
| Gate: rec.Gate, |
| @@ -1014,6 +1015,18 @@ func convergeOwned(reg *registry.Registry, existing registry.Route, rec Record, |
| rec.Host, existing.AssetsOff, want, existing.AssetGen, rec.AssetGen) |
| } |
| } |
| + // The page-cache opt-out converges from the record, both ways. |
| + if want := !rec.PagesOn(); existing.PagesOff != want { |
| + if dryRun { |
| + log.Printf("provision: dry-run: would converge %s pages off %v -> %v", |
| + rec.Host, existing.PagesOff, want) |
| + } else if err := reg.SetPages(rec.Host, want); err != nil { |
| + log.Printf("provision: converge pages on %s: %v", rec.Host, err) |
| + errs = append(errs, fmt.Errorf("converge pages on %s: %w", rec.Host, err)) |
| + } else { |
| + log.Printf("provision: converged %s pages off %v -> %v", rec.Host, existing.PagesOff, want) |
| + } |
| + } |
| // Replicas CONVERGES, where steering merely repoints: the bucket's value |
| // is authoritative in BOTH directions, including down to none — a set |
| // that shrank must actually shrink on the row, or the edges file goes on |
diff --git a/internal/provision/reconcile_test.go b/internal/provision/reconcile_test.go| index d65c43786..65d8d181d 100644 |
| --- a/internal/provision/reconcile_test.go |
| +++ b/internal/provision/reconcile_test.go |
| @@ -3935,3 +3935,58 @@ func TestMintedRowCarriesTheAssignment(t *testing.T) { |
| t.Fatalf("an unchanged pass wrote the row %d times", n) |
| } |
| } |
| + |
| +// TestConvergeAppliesPagesSwitch: the record's Pages opt-out reaches the |
| +// owned row through RouteFor and convergeOwned, both ways, touching nothing |
| +// else. |
| +func TestConvergeAppliesPagesSwitch(t *testing.T) { |
| + s, sqid := shopSetup(t) |
| + rec := shopRecord(sqid) |
| + if got := RouteFor(rec, "/data", "", false, nil); got.PagesOff { |
| + t.Fatal("RouteFor: absent Pages must leave PagesOff false") |
| + } |
| + off := false |
| + rec.Pages = &off |
| + if got := RouteFor(rec, "/data", "", false, nil); !got.PagesOff { |
| + t.Fatal("RouteFor: Pages=false must set PagesOff") |
| + } |
| + on := true |
| + rec.Pages = &on |
| + if !rec.PagesOn() || RouteFor(rec, "/data", "", false, nil).PagesOff { |
| + t.Fatal("Pages=true must read as on") |
| + } |
| + rec.Pages = nil |
| + if err := CreateRecord(ctx, s, rec); err != nil { |
| + t.Fatal(err) |
| + } |
| + reg := regWith(t) |
| + cfg := ReconcileConfig{Region: "ie", DataDir: "/data"} |
| + if err := Reconcile(ctx, s, reg, cfg); err != nil { |
| + t.Fatal(err) |
| + } |
| + before := *mustGet(t, reg, "a.shop.example.com") |
| + if before.PagesOff { |
| + t.Fatal("minted PagesOff = true, want false") |
| + } |
| + rec.Pages = &off |
| + putReplace(t, s, RecordKey(sqid, "shop", rec.Host), mustJSON(t, rec)) |
| + if err := Reconcile(ctx, s, reg, cfg); err != nil { |
| + t.Fatal(err) |
| + } |
| + after := *mustGet(t, reg, "a.shop.example.com") |
| + if !after.PagesOff { |
| + t.Fatal("PagesOff not converged on") |
| + } |
| + after.PagesOff = false |
| + if after != before { |
| + t.Errorf("converging pages touched another column:\n before %+v\n after %+v", before, after) |
| + } |
| + rec.Pages = nil |
| + putReplace(t, s, RecordKey(sqid, "shop", rec.Host), mustJSON(t, rec)) |
| + if err := Reconcile(ctx, s, reg, cfg); err != nil { |
| + t.Fatal(err) |
| + } |
| + if mustGet(t, reg, "a.shop.example.com").PagesOff { |
| + t.Error("PagesOff not converged back off") |
| + } |
| +} |
diff --git a/internal/registry/forward.go b/internal/registry/forward.go| index 2adfe5a9e..1d808d787 100644 |
| --- a/internal/registry/forward.go |
| +++ b/internal/registry/forward.go |
| @@ -113,7 +113,7 @@ var forwardShape = map[string]string{ |
| "Socket": "forbidden", "Addr": "forbidden", "Addrs": "forbidden", "Health": "forbidden", |
| "HoldOp": "forbidden", "Incarnation": "forbidden", "ServingSeq": "forbidden", |
| "SeedSource": "forbidden", "ImportGate": "forbidden", "AssetsOff": "forbidden", |
| - "AssetGen": "forbidden", "LastError": "forbidden", "DBPath": "forbidden", |
| + "AssetGen": "forbidden", "PagesOff": "forbidden", "LastError": "forbidden", "DBPath": "forbidden", |
| "Version": "forbidden", "PrevVersion": "forbidden", "GoodVersion": "forbidden", |
| "GoodDigest": "forbidden", "GoodDemand": "forbidden", "ServingVersion": "forbidden", |
| "Pool": "forbidden", "Environment": "forbidden", "Tunnel": "forbidden", |
| @@ -153,6 +153,7 @@ var ForwardForbidden = []ForwardColumn{ |
| {"ImportGate", "import_gate", "TEXT"}, |
| {"AssetsOff", "assets_off", "INTEGER"}, |
| {"AssetGen", "asset_gen", "TEXT"}, |
| + {"PagesOff", "pages_off", "INTEGER"}, |
| {"LastError", "last_error", "TEXT"}, |
| {"DBPath", "db_path", "TEXT"}, |
| {"Version", "version", "TEXT"}, |
| @@ -213,6 +214,7 @@ func (t Route) InertForward() bool { |
| t.ImportGate == "" && |
| !t.AssetsOff && |
| t.AssetGen == "" && |
| + !t.PagesOff && |
| t.LastError == "" && |
| t.DBPath == "" && |
| t.Version == "" && |
diff --git a/internal/registry/forward_test.go b/internal/registry/forward_test.go| index c6e23bd48..9e9f89327 100644 |
| --- a/internal/registry/forward_test.go |
| +++ b/internal/registry/forward_test.go |
| @@ -657,3 +657,37 @@ func TestForwardCallsOverRemote(t *testing.T) { |
| t.Fatalf("remote DeleteForward left %+v, %v", got, err) |
| } |
| } |
| + |
| +// TestForwardRowRefusesPagesOff: pages_off is forbidden on a forward row. A |
| +// row carrying it is not inert, and PutForward over a corrupted row writes it |
| +// back to zero. |
| +func TestForwardRowRefusesPagesOff(t *testing.T) { |
| + rt := validForward("shop.example.com", "home") |
| + if !rt.InertForward() { |
| + t.Fatalf("a valid forward row is not inert: %+v", rt) |
| + } |
| + rt.PagesOff = true |
| + if rt.InertForward() { |
| + t.Error("InertForward() true with PagesOff set") |
| + } |
| + if forwardShape["PagesOff"] != "forbidden" { |
| + t.Errorf("forwardShape[PagesOff] = %q, want forbidden", forwardShape["PagesOff"]) |
| + } |
| + |
| + reg := openTestRegistry(t) |
| + if err := reg.PutForward(validForward("shop.example.com", "home")); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := reg.sql.Exec(`UPDATE routes SET pages_off = 1 WHERE host = ?`, "shop.example.com"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got, err := reg.Get("shop.example.com"); err != nil || got == nil || got.InertForward() { |
| + t.Fatalf("a forward row with pages_off=1 reads as inert: %+v (%v)", got, err) |
| + } |
| + if err := reg.PutForward(validForward("shop.example.com", "home")); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got, err := reg.Get("shop.example.com"); err != nil || got == nil || got.PagesOff || !got.InertForward() { |
| + t.Fatalf("PutForward left %+v (%v), want pages_off cleared", got, err) |
| + } |
| +} |
diff --git a/internal/registry/registry.go b/internal/registry/registry.go| index 9ea5f0921..f654c57b7 100644 |
| --- a/internal/registry/registry.go |
| +++ b/internal/registry/registry.go |
| @@ -125,6 +125,13 @@ type Route struct { |
| // provision.Record.AssetGen. IN Fingerprint, folded in only when set, |
| // for AssetsOff's reason. |
| AssetGen string |
| + // PagesOff is the instance's page-cache opt-out (edge page cache design): |
| + // true means the home box publishes no page index for this host. |
| + // Inverted from the record's Pages *bool so the zero value is the |
| + // default, on. Converged from provision.Record.Pages by RouteFor and |
| + // convergeOwned through SetPages. IN Fingerprint and SnapshotFingerprint, |
| + // folded in only when set, for AssetsOff's reason. |
| + PagesOff bool |
| LastError string |
| // Stateless projects the serving generation mode; it never authorizes a launch. |
| @@ -746,6 +753,7 @@ var routeAddedColumns = []addedColumn{ |
| {Name: "rate_limit", Type: "TEXT", Default: "''"}, |
| {Name: "assets_off", Type: "INTEGER", Default: "0"}, |
| {Name: "asset_gen", Type: "TEXT", Default: "''"}, |
| + {Name: "pages_off", Type: "INTEGER", Default: "0"}, |
| {Name: "incarnation", Type: "INTEGER", Default: "0"}, |
| {Name: "serving_seq", Type: "INTEGER", Default: "0"}, |
| // The app policy's converge (#328, #329; Route.EgressAllow): '' = none. |
| @@ -1108,11 +1116,11 @@ dns_checked_at, cert_expires_at, account, environment, caps, tunnel, |
| provisioned, seed, unit, fleet_box, addrs, health, steering, gate, created_at, |
| args, idle_seconds, max_run_seconds, replicas, replica, claim_incarnation, claim_stamp, claim_owner, claim_row_id, hold_op, |
| good_version, good_digest, good_demand, serving_version, update_settings, build_state, |
| -seed_source, import_gate, runtime, rate_limit, assets_off, asset_gen, incarnation, serving_seq, |
| +seed_source, import_gate, runtime, rate_limit, assets_off, asset_gen, pages_off, incarnation, serving_seq, |
| egress_allow, size, policy_expires_at, ha, fleet_assigned, fleet_moved, fleet_label, stateless, fleet_boxes, copies, replica_revision, replica_incarnation, demo_id, demo_host, demo_lifetime, demo_expires_at` |
| // routeColCount is the number of names in routeCols. |
| -const routeColCount = 77 |
| +const routeColCount = 78 |
| // placeholders is n comma-joined bind parameters. |
| func placeholders(n int) string { |
| @@ -1121,7 +1129,7 @@ func placeholders(n int) string { |
| func scanRoute(scan func(...any) error) (Route, error) { |
| var t Route |
| - var hib, can, sn, plat, prov, rep, assetsOff, ha, moved, stateless int |
| + var hib, can, sn, plat, prov, rep, assetsOff, pagesOff, ha, moved, stateless int |
| err := scan(&t.Host, &t.Slug, &t.Kind, &t.Socket, &t.Addr, &t.Status, |
| &t.LastError, &t.DBPath, &t.Version, &t.PrevVersion, &t.App, &t.Pool, |
| &t.Region, &t.Channel, &hib, &can, &t.Replication, &t.NextDue, &t.Backing, |
| @@ -1130,12 +1138,13 @@ func scanRoute(scan func(...any) error) (Route, error) { |
| &t.Addrs, &t.Health, &t.Steering, &t.Gate, &t.CreatedAt, |
| &t.Args, &t.IdleSeconds, &t.MaxRunSeconds, &t.Replicas, &rep, &t.ClaimIncarnation, &t.ClaimStamp, &t.ClaimOwner, &t.ClaimRowID, &t.HoldOp, |
| &t.GoodVersion, &t.GoodDigest, &t.GoodDemand, &t.ServingVersion, &t.UpdateSettings, &t.BuildState, |
| - &t.SeedSource, &t.ImportGate, &t.Runtime, &t.RateLimit, &assetsOff, &t.AssetGen, &t.Incarnation, &t.ServingSeq, |
| + &t.SeedSource, &t.ImportGate, &t.Runtime, &t.RateLimit, &assetsOff, &t.AssetGen, &pagesOff, &t.Incarnation, &t.ServingSeq, |
| &t.EgressAllow, &t.Size, &t.PolicyExpiresAt, &ha, &t.Assigned, &moved, &t.FleetLabel, &stateless, &t.FleetBoxes, &t.Copies, &t.ReplicaRevision, &t.ReplicaIncarnation, &t.DemoID, &t.DemoHost, &t.DemoLifetime, &t.DemoExpiresAt) |
| t.Stateless = stateless != 0 |
| t.HA = ha != 0 |
| t.Moved = moved != 0 |
| t.AssetsOff = assetsOff != 0 |
| + t.PagesOff = pagesOff != 0 |
| t.Hibernate = hib != 0 |
| t.Canary = can != 0 |
| t.StatusNamed = sn != 0 |
| @@ -1621,6 +1630,8 @@ ON CONFLICT(host) DO UPDATE SET |
| WHEN excluded.asset_gen = '' THEN routes.assets_off ELSE excluded.assets_off END, |
| asset_gen=CASE WHEN `+tenantChangedSQL+` THEN excluded.asset_gen |
| WHEN excluded.asset_gen = '' THEN routes.asset_gen ELSE excluded.asset_gen END, |
| + pages_off=CASE WHEN `+tenantChangedSQL+` THEN excluded.pages_off |
| + ELSE routes.pages_off END, |
| incarnation=routes.incarnation, serving_seq=routes.serving_seq, |
| egress_allow=CASE WHEN `+tenantChangedSQL+` THEN excluded.egress_allow |
| WHEN excluded.egress_allow = '' THEN routes.egress_allow ELSE excluded.egress_allow END, |
| @@ -1705,7 +1716,7 @@ func routeArgs(t Route) []any { |
| t.Steering, t.Gate, t.CreatedAt, t.Args, t.IdleSeconds, t.MaxRunSeconds, |
| t.Replicas, b2iDB(t.Replica), t.ClaimIncarnation, t.ClaimStamp, t.ClaimOwner, t.ClaimRowID, t.HoldOp, |
| t.GoodVersion, t.GoodDigest, t.GoodDemand, t.ServingVersion, t.UpdateSettings, t.BuildState, |
| - t.SeedSource, t.ImportGate, t.Runtime, t.RateLimit, b2iDB(t.AssetsOff), t.AssetGen, t.Incarnation, t.ServingSeq, |
| + t.SeedSource, t.ImportGate, t.Runtime, t.RateLimit, b2iDB(t.AssetsOff), t.AssetGen, b2iDB(t.PagesOff), t.Incarnation, t.ServingSeq, |
| t.EgressAllow, t.Size, t.PolicyExpiresAt, b2iDB(t.HA), t.Assigned, b2iDB(t.Moved), t.FleetLabel, b2iDB(t.Stateless), t.FleetBoxes, t.Copies, t.ReplicaRevision, t.ReplicaIncarnation, t.DemoID, t.DemoHost, t.DemoLifetime, t.DemoExpiresAt, |
| } |
| } |
| @@ -2537,6 +2548,30 @@ func (r *Registry) SetAssets(host string, off bool, gen string) error { |
| return nil |
| } |
| +// SetPages converges a route's page-cache opt-out as one narrow UPDATE: off |
| +// true means the home box publishes no page index for the host. It moves in |
| +// both directions, down to false too. Errors on an unmatched host, like |
| +// SetAssets. |
| +func (r *Registry) SetPages(host string, off bool) error { |
| + if r.remote != nil { |
| + _, err := r.remote.call(nil, remoteRequest{Method: "SetPages", Host: host, PagesOff: off}, nil) |
| + return err |
| + } |
| + |
| + res, err := r.sql.Exec(`UPDATE routes SET pages_off = ? WHERE host = ? AND kind <> 'forward'`, b2iDB(off), host) |
| + if err != nil { |
| + return err |
| + } |
| + n, err := res.RowsAffected() |
| + if err != nil { |
| + return err |
| + } |
| + if n == 0 { |
| + return noRoute(r.sql, host) |
| + } |
| + return nil |
| +} |
| + |
| // SetUpdateSettings repoints a route's effective update settings as a narrow |
| // UPDATE: reconcile converges it from the record every pass, in both |
| // directions, including down to "". Errors on an unmatched host, like |
| @@ -3970,7 +4005,7 @@ func (r *Registry) Fingerprint() (string, error) { |
| SELECT rowid, status, socket, addr, version, hibernate, channel, backing, tunnel, |
| db_path, region, fleet_box, addrs, health, gate, hold_op, import_gate, rate_limit, |
| claim_incarnation, claim_stamp, claim_owner, claim_row_id, |
| - assets_off, asset_gen, incarnation, serving_seq, |
| + assets_off, asset_gen, pages_off, incarnation, serving_seq, |
| host, kind, account, app, platform, fleet_label, stateless, fleet_boxes, copies, replica_revision, replica_incarnation, demo_id, demo_host, demo_lifetime, demo_expires_at, |
| ` + fingerprintForwardInert + ` |
| FROM routes ORDER BY rowid`) |
| @@ -3981,7 +4016,7 @@ FROM routes ORDER BY rowid`) |
| h := sha256.New() |
| n := 0 |
| for rows.Next() { |
| - var rowid, hibernate, assetsOff, platform, forwardInert, stateless int64 |
| + var rowid, hibernate, assetsOff, pagesOff, platform, forwardInert, stateless int64 |
| var fleetBoxes, replicaIncarnation string |
| var copies int |
| var replicaRevision uint64 |
| @@ -3994,7 +4029,7 @@ FROM routes ORDER BY rowid`) |
| if err := rows.Scan(&rowid, &status, &socket, &addr, &version, &hibernate, |
| &channel, &backing, &tunnel, &dbPath, ®ion, &fleetBox, &addrs, &health, &gate, &holdOp, &importGate, &rateLimit, |
| &claim.ClaimIncarnation, &claim.ClaimStamp, &claim.ClaimOwner, &claim.ClaimRowID, |
| - &assetsOff, &assetGen, &pair.Incarnation, &pair.ServingSeq, |
| + &assetsOff, &assetGen, &pagesOff, &pair.Incarnation, &pair.ServingSeq, |
| &host, &kind, &account, &app, &platform, &fleetLabel, &stateless, &fleetBoxes, &copies, &replicaRevision, &replicaIncarnation, &demoID, &demoHost, &demoLifetime, &demoExpiresAt, &forwardInert); err != nil { |
| return "", err |
| } |
| @@ -4060,6 +4095,10 @@ FROM routes ORDER BY rowid`) |
| if assetsOff != 0 { |
| fmt.Fprint(h, "\x1fassets_off=1") |
| } |
| + // pages_off follows the same rule, for the same reason. |
| + if pagesOff != 0 { |
| + fmt.Fprint(h, "\x1fpages_off=1") |
| + } |
| if assetGen != "" { |
| fmt.Fprintf(h, "\x1fasset_gen=%q", assetGen) |
| } |
| @@ -4407,9 +4446,9 @@ func (r *Registry) SnapshotFingerprint() (string, error) { |
| // assets_off and asset_gen follow the same rule: a registry that |
| // never set either digests exactly as it did before the columns |
| // existed, so upgrading does not force a snapshot on every box. |
| - if cols[i] == "assets_off" { |
| + if cols[i] == "assets_off" || cols[i] == "pages_off" { |
| if v.Valid && v.String != "" && v.String != "0" { |
| - fmt.Fprintf(h, "assets_off=%s\x1f", v.String) |
| + fmt.Fprintf(h, "%s=%s\x1f", cols[i], v.String) |
| } |
| continue |
| } |
diff --git a/internal/registry/registry_test.go b/internal/registry/registry_test.go| index 1819c663b..85079fae8 100644 |
| --- a/internal/registry/registry_test.go |
| +++ b/internal/registry/registry_test.go |
| @@ -91,6 +91,7 @@ func TestUpsertRoundTripsAllColumns(t *testing.T) { |
| Runtime: RuntimeRootfsV1, |
| AssetsOff: true, |
| AssetGen: "0123456789abcdef", |
| + PagesOff: true, |
| Incarnation: 31, ServingSeq: 32, |
| EgressAllow: "10.0.5.20 fd00:5::20", |
| Size: "large", |
| @@ -3669,3 +3670,89 @@ func TestUpsertAssetColumnsDoNotSurviveTenantChange(t *testing.T) { |
| t.Fatalf("AssetsOff = %v, AssetGen = %q, want the same tenant's values kept", got.AssetsOff, got.AssetGen) |
| } |
| } |
| + |
| +// TestSetPagesRoundTripsAndMovesFingerprint: SetPages writes only pages_off, |
| +// the digest moves with it in both fingerprints, and clearing it returns the |
| +// original digest. |
| +func TestSetPagesRoundTripsAndMovesFingerprint(t *testing.T) { |
| + reg := openTestRegistry(t) |
| + if err := reg.Upsert(Route{Host: "shop.example.com", Kind: "instance", Status: "ready"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + fp := func() (string, string) { |
| + t.Helper() |
| + v, err := reg.Fingerprint() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + s, err := reg.SnapshotFingerprint() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + return v, s |
| + } |
| + baseF, baseS := fp() |
| + if err := reg.SetPages("shop.example.com", true); err != nil { |
| + t.Fatal(err) |
| + } |
| + got, err := reg.Get("shop.example.com") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if !got.PagesOff || got.AssetsOff || got.AssetGen != "" { |
| + t.Fatalf("PagesOff = %v, AssetsOff = %v, AssetGen = %q, want true, false, empty", got.PagesOff, got.AssetsOff, got.AssetGen) |
| + } |
| + offF, offS := fp() |
| + if offF == baseF || offS == baseS { |
| + t.Fatal("a fingerprint did not move on pages_off") |
| + } |
| + if err := reg.SetPages("shop.example.com", false); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got, err = reg.Get("shop.example.com"); err != nil || got.PagesOff { |
| + t.Fatalf("PagesOff after clearing = %v (%v), want false", got.PagesOff, err) |
| + } |
| + if f, s := fp(); f != baseF || s != baseS { |
| + t.Fatal("clearing pages_off did not return the original digests") |
| + } |
| + if err := reg.SetPages("nope.example.com", true); err == nil { |
| + t.Fatal("SetPages on an unmatched host: want error, got nil") |
| + } |
| + // The same through the remote transport. |
| + remote, _ := remoteTestRegistry(t) |
| + if err := remote.Upsert(Route{Host: "shop.example.com", Kind: "instance", Status: "ready"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := remote.SetPages("shop.example.com", true); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got, err := remote.Get("shop.example.com"); err != nil || !got.PagesOff { |
| + t.Fatalf("remote PagesOff = %v (%v), want true", got != nil && got.PagesOff, err) |
| + } |
| +} |
| + |
| +// TestUpsertKeepsPagesOffUnlessTheTenantChanges: a bare re-add keeps the |
| +// opt-out; a replacement tenant never inherits it. |
| +func TestUpsertKeepsPagesOffUnlessTheTenantChanges(t *testing.T) { |
| + reg := openTestRegistry(t) |
| + base := Route{Host: "shop.example.com", Kind: "instance", Status: "ready", Account: "abc", App: "shop", PagesOff: true} |
| + if err := reg.Upsert(base); err != nil { |
| + t.Fatal(err) |
| + } |
| + same := base |
| + same.PagesOff = false |
| + if err := reg.Upsert(same); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got, _ := reg.Get("shop.example.com"); !got.PagesOff { |
| + t.Fatal("same tenant: PagesOff cleared by an Upsert, want kept") |
| + } |
| + other := same |
| + other.App = "other" |
| + if err := reg.Upsert(other); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got, _ := reg.Get("shop.example.com"); got.PagesOff { |
| + t.Fatal("replacement tenant inherited PagesOff") |
| + } |
| +} |
diff --git a/internal/registry/remote_dispatch.go b/internal/registry/remote_dispatch.go| index 048fe7597..db76ba63b 100644 |
| --- a/internal/registry/remote_dispatch.go |
| +++ b/internal/registry/remote_dispatch.go |
| @@ -71,6 +71,7 @@ type remoteRequest struct { |
| Steering string |
| AssetsOff bool |
| AssetGen string |
| + PagesOff bool |
| UpdateSettings string |
| BuildState string |
| Replicas string |
| @@ -316,6 +317,8 @@ func (r *Registry) dispatchRemote(ctx context.Context, q remoteRequest, callback |
| err = r.SetUpstreams(q.Host, q.Addr, q.Addrs, q.Health) |
| case "SetSteering": |
| err = r.SetSteering(q.Host, q.Steering) |
| + case "SetPages": |
| + err = r.SetPages(q.Host, q.PagesOff) |
| case "SetAssets": |
| err = r.SetAssets(q.Host, q.AssetsOff, q.AssetGen) |
| case "SetUpdateSettings": |