status: a box reports offline move facts in its private report
#339 items 1 and 4. A box that can take part in an offline move reports, in the private Metrics block, the hosts it keeps a stale live link for and the entries beside each instance's files directory, so the stage and start doors can read them while the instance serves. Present (even empty) means the box looked; absent means it cannot say.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+77
−2
internal/status/contract_test.go+14 −1internal/status/snapshot.go+37 −1internal/status/snapshot_test.go+26 −0
diff --git a/internal/status/contract_test.go b/internal/status/contract_test.go| index 8c672eab7..e628ed5f1 100644 |
| --- a/internal/status/contract_test.go |
| +++ b/internal/status/contract_test.go |
| @@ -83,7 +83,7 @@ var allowedBoxKeys = map[string][]string{ |
| "routes": {"static", "resident", "hibernating", "awake", "asleep"}, |
| "replication": {"healthy", "lag_seconds"}, |
| // capabilities names supported protocols only, in the bucket-private metrics. |
| - "metrics": {"capabilities", "mem_total_bytes", "mem_avail_bytes", "load1", "disk_free_bytes", "release", "tunnel", "route_versions", "upstreams", "layout", "config_refusals", "config_refusals_total", "release_refusals", "proof_waits", "config_guard", "build_states", "build_states_err", "update_settings", "updates", "egress", "size_committed_mib"}, |
| + "metrics": {"capabilities", "mem_total_bytes", "mem_avail_bytes", "load1", "disk_free_bytes", "release", "tunnel", "route_versions", "upstreams", "layout", "config_refusals", "config_refusals_total", "release_refusals", "proof_waits", "config_guard", "build_states", "build_states_err", "update_settings", "updates", "egress", "size_committed_mib", "offline_move"}, |
| "metrics.route_versions": {wildcardAnyKey}, |
| "metrics.upstreams": {wildcardAnyKey}, |
| "metrics.upstreams.*[]": {"addr", "up", "since", "fails", "last_error"}, |
| @@ -116,6 +116,13 @@ var allowedBoxKeys = map[string][]string{ |
| // in the private block only; the values are pinned to the field level. |
| "metrics.egress": {wildcardAnyKey}, |
| "metrics.egress.*": {"allowed", "refused", "state", "detail"}, |
| + // offline_move (#339) is what an offline move's stage and start doors |
| + // read: hosts with a stale live link here, and per host the entries |
| + // beside its files directory. Private block only, pinned to the field |
| + // level. |
| + "metrics.offline_move": {"stale_live_links", "app_dirs"}, |
| + "metrics.offline_move.app_dirs": {wildcardAnyKey}, |
| + "metrics.offline_move.app_dirs.*[]": {"path", "empty"}, |
| } |
| // allowedFleetKeys are THE schema for Fleet's JSON output. Same friction as |
| @@ -386,6 +393,12 @@ func fixtureProbes() status.Probes { |
| // The committed figure, so metrics.size_committed_mib is exercised |
| // by the allowlist walk too (#329). |
| SizeCommittedMiB: &sizeCommitted, |
| + // The offline move facts, so metrics.offline_move is exercised by |
| + // the allowlist walk too (#339). |
| + OfflineMove: &status.OfflineMoveFacts{ |
| + StaleLiveLinks: []string{"contract-left.internal"}, |
| + AppDirs: map[string][]status.AppDir{"contract-dirs.internal": {{Path: "/data/.instances/x/documents", Empty: true}}}, |
| + }, |
| ConfigGuard: "bypassed (CARLOS_NO_SEALED_CONFIG)", |
| MemFrac: &memFrac, |
diff --git a/internal/status/snapshot.go b/internal/status/snapshot.go| index f81d61f59..a15622d34 100644 |
| --- a/internal/status/snapshot.go |
| +++ b/internal/status/snapshot.go |
| @@ -229,6 +229,35 @@ type Probes struct { |
| // SizeCommittedMiB is the sum, in MiB, of the sizes this box's awake |
| // instances run at (#329, spec §5.5), or nil with no activator armed. |
| SizeCommittedMiB *int64 |
| + // OfflineMove is what this box tells an offline move's stage and start |
| + // doors while the instance still serves (#339), or nil when the box |
| + // cannot take part in an offline move. Private Metrics only: it names |
| + // hosts. |
| + OfflineMove *OfflineMoveFacts |
| +} |
| + |
| +// OfflineMoveFacts is what a box that can take part in an offline move |
| +// reports about its own disk for the console's stage and start doors |
| +// (#339): the two things that otherwise refuse the move only after the |
| +// instance is offline. Present (even empty) means the box looked; absent |
| +// is a box that cannot say, which the doors read as saying nothing. |
| +type OfflineMoveFacts struct { |
| + // StaleLiveLinks are the hosts this box keeps a live link for |
| + // (<opt>/live/<host>) with no route row here: what a box the instance |
| + // once left keeps, root-owned. A move back to this box fails the |
| + // landing's release item over it, at flip. Sorted. |
| + StaleLiveLinks []string `json:"stale_live_links,omitempty"` |
| + // AppDirs is, per instance this box hosts that keeps any, the entries |
| + // beside its files directory that an offline move cannot carry, as the |
| + // seal judges them. Sorted by path. |
| + AppDirs map[string][]AppDir `json:"app_dirs,omitempty"` |
| +} |
| + |
| +// AppDir is one entry an instance keeps beside its files directory: its |
| +// path on the box, and whether it is an empty directory. |
| +type AppDir struct { |
| + Path string `json:"path"` |
| + Empty bool `json:"empty,omitempty"` |
| } |
| // HostEgress is one instance's egress read-back (#328, spec §4.4): the |
| @@ -777,6 +806,11 @@ type BoxMetrics struct { |
| // promised, beside MemTotalBytes and MemAvailBytes. Information for the |
| // console's size door, never a gate. Omitted with no activator armed. |
| SizeCommittedMiB *int64 `json:"size_committed_mib,omitempty"` |
| + // OfflineMove is the box's offline move facts (#339, Probes.OfflineMove): |
| + // stale live links and app directories beside instances' files |
| + // directories. Host-keyed and private like RouteVersions. Omitted on a |
| + // box that cannot take part in an offline move. |
| + OfflineMove *OfflineMoveFacts `json:"offline_move,omitempty"` |
| } |
| // UpdateSettingsProtocol is the BoxMetrics.UpdateSettings a binary reports |
| @@ -1218,7 +1252,8 @@ func CollectBox(routes []registry.Route, p Probes, now time.Time) Box { |
| len(routeVersions) > 0 || len(routeServing) > 0 || len(aliasReadings) > 0 || p.AliasesRead || len(p.Upstreams) > 0 || len(p.ReplicaCopies) > 0 || |
| len(routeDBBytes) > 0 || p.Layout != nil || len(p.ConfigRefusals) > 0 || len(p.ReleaseRefusals) > 0 || len(p.ProofWaits) > 0 || p.Rollout != nil || p.ConfigGuard != "" || |
| p.Alerts != nil || p.GeoIP != nil || p.HeldStreams != nil || len(p.BuildStates) > 0 || p.BuildStatesErr != "" || |
| - p.DemoClaimSeedReady || p.DemoMovedReady || p.UpdateSettings != 0 || len(p.Updates) > 0 || len(p.Egress) > 0 || p.SizeCommittedMiB != nil { |
| + p.DemoClaimSeedReady || p.DemoMovedReady || p.UpdateSettings != 0 || len(p.Updates) > 0 || len(p.Egress) > 0 || p.SizeCommittedMiB != nil || |
| + p.OfflineMove != nil { |
| var capabilities []string |
| if p.DemoClaimSeedReady { |
| capabilities = append(capabilities, seeds.DemoClaimCapability) |
| @@ -1276,6 +1311,7 @@ func CollectBox(routes []registry.Route, p Probes, now time.Time) Box { |
| Egress: p.Egress, |
| SizeCommittedMiB: p.SizeCommittedMiB, |
| + OfflineMove: p.OfflineMove, |
| } |
| } |
diff --git a/internal/status/snapshot_test.go b/internal/status/snapshot_test.go| index 95aafe5a3..1f75e861a 100644 |
| --- a/internal/status/snapshot_test.go |
| +++ b/internal/status/snapshot_test.go |
| @@ -447,3 +447,29 @@ func TestDemoClaimSeedCapabilityConfigured(t *testing.T) { |
| t.Fatal("dormant claim changed status JSON") |
| } |
| } |
| + |
| +// TestCollectBoxCarriesOfflineMoveFacts pins Probes.OfflineMove (#339): the |
| +// facts reach the private Metrics block as offline_move, and an empty |
| +// report (the box looked and found nothing) is still published, so a door |
| +// can tell it from a box that cannot say. |
| +func TestCollectBoxCarriesOfflineMoveFacts(t *testing.T) { |
| + at := time.Date(2026, 11, 13, 9, 0, 0, 0, time.UTC) |
| + facts := &OfflineMoveFacts{ |
| + StaleLiveLinks: []string{"left.example.com"}, |
| + AppDirs: map[string][]AppDir{"shop-a.example.com": {{Path: "/data/.instances/i/documents", Empty: true}}}, |
| + } |
| + b := CollectBox(nil, Probes{OfflineMove: facts}, at) |
| + if b.Metrics == nil || b.Metrics.OfflineMove != facts { |
| + t.Fatalf("metrics = %+v, want the offline move facts", b.Metrics) |
| + } |
| + out, err := json.Marshal(CollectBox(nil, Probes{OfflineMove: &OfflineMoveFacts{}}, at)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if !strings.Contains(string(out), `"offline_move":{}`) { |
| + t.Fatalf("an empty report is not published: %s", out) |
| + } |
| + if b := CollectBox(nil, Probes{}, at); b.Metrics != nil { |
| + t.Fatalf("no facts and nothing else known must mean no metrics block: %+v", b.Metrics) |
| + } |
| +} |