status: box reports mark hosts the rollout manager manages
HostRollout gains Managed (json "managed", omitempty), set true only by rollout.Manager.Status for hosts its schedulers hold. Declined-box holds and root retry status leave it false. The console fold copies it into hostReport.managed; an older box's report reads false, which readers take as unknown.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 files changed,
+74
−1
internal/console/remoteinstances.go+5 −0internal/console/remoteinstances_test.go+25 −0internal/host/rolloutdeclined_test.go+22 −0internal/rollout/status.go+1 −1internal/rollout/status_test.go+15 −0internal/status/snapshot.go+6 −0
Intent
Attributed to this commit: 107 g CO₂e (8,528,128 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-console-secrets, 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/remoteinstances.go b/internal/console/remoteinstances.go| index 75b548883..afa0a22f7 100644 |
| --- a/internal/console/remoteinstances.go |
| +++ b/internal/console/remoteinstances.go |
| @@ -243,6 +243,10 @@ type hostReport struct { |
| account, app string |
| awake bool |
| down, transient bool |
| + // managed is the entry's word that the box's rollout manager manages |
| + // the host (status.HostRollout.Managed). False from a box that predates |
| + // the field, so a reader takes false as unknown, never as unmanaged. |
| + managed bool |
| } |
| // fleetReports is every fresh box's word about every host. |
| @@ -288,6 +292,7 @@ func foldFleetReports(boxes []status.Box, complete bool, now time.Time) fleetRep |
| r.awake = hr.Awake && !hr.Transient |
| r.down = hr.Attempt == status.AttemptDown |
| r.transient = hr.Transient |
| + r.managed = hr.Managed |
| } |
| } |
| for name, reading := range m.Aliases { |
diff --git a/internal/console/remoteinstances_test.go b/internal/console/remoteinstances_test.go| index 0e12944a1..0ff137b0b 100644 |
| --- a/internal/console/remoteinstances_test.go |
| +++ b/internal/console/remoteinstances_test.go |
| @@ -11,6 +11,7 @@ package console |
| import ( |
| "context" |
| + "encoding/json" |
| "fmt" |
| "net/http" |
| "net/url" |
| @@ -786,3 +787,27 @@ func factsOf(f fleetReports, acct, app string) appFacts { |
| func pickFor(f fleetReports, host, acct, app string) *hostReport { |
| return factsOf(f, acct, app).host(provision.Record{Host: host, Account: acct, App: app}) |
| } |
| + |
| +// Console secrets slice 2, Task 1: the fold carries the box's word that the |
| +// rollout manager manages a host; a box report from before the field reads |
| +// as not managed. |
| +func TestFoldFleetReportsCarriesManaged(t *testing.T) { |
| + now := time.Now() |
| + boxes := []status.Box{{GeneratedAt: now, Label: "b", Metrics: &status.BoxMetrics{ |
| + RouteVersions: map[string]string{"h.example.com": "v7"}, |
| + Rollout: &status.RolloutReport{Hosts: map[string]status.HostRollout{ |
| + "h.example.com": {Account: "a", App: "shop", Managed: true}, |
| + }}, |
| + }}} |
| + if rep := pickFor(foldFleetReports(boxes, true, now), "h.example.com", "a", "shop"); rep == nil || !rep.managed { |
| + t.Fatalf("managed host folded as %+v", rep) |
| + } |
| + var old status.RolloutReport |
| + if err := json.Unmarshal([]byte(`{"hosts":{"h.example.com":{"account":"a","app":"shop","installed":"v7","awake":true}}}`), &old); err != nil { |
| + t.Fatal(err) |
| + } |
| + boxes[0].Metrics.Rollout = &old |
| + if rep := pickFor(foldFleetReports(boxes, true, now), "h.example.com", "a", "shop"); rep == nil || rep.managed { |
| + t.Fatalf("old-shape host folded as %+v, want not managed", rep) |
| + } |
| +} |
diff --git a/internal/host/rolloutdeclined_test.go b/internal/host/rolloutdeclined_test.go| index eee056c54..d1c43f433 100644 |
| --- a/internal/host/rolloutdeclined_test.go |
| +++ b/internal/host/rolloutdeclined_test.go |
| @@ -1285,3 +1285,25 @@ func TestDeclinedBoxRetryFromTheConsoleDoorToTheRestartLeg(t *testing.T) { |
| t.Fatal("the console's retry was not saved") |
| } |
| } |
| + |
| +// Console secrets slice 2, Task 1: a declined box runs no scheduler, so no |
| +// entry its report publishes says the rollout manager manages the host. |
| +func TestDeclinedReportNotManaged(t *testing.T) { |
| + t.Setenv("CARLOS_OPT_DIR", t.TempDir()) |
| + svc, reg, dd := rolloutFixture(t, false) |
| + const host = "h.example.com" |
| + rt := heldRouteIn(t, reg, host, "v2", "v1") |
| + acct := release.RouteAccount(rt) |
| + writeFailureBook(t, dd, []rollout.FailureRecord{{ |
| + Account: acct, App: "blog", Build: "v2", Host: "sib.example.com", Mode: "hold", Reason: "health", HeldDown: []string{host}, |
| + }}, nil) |
| + declineWithBook(t, svc, reg, dd) |
| + if _, ok := declinedHostReport(t, host); !ok { |
| + t.Fatal("the declined box published no entry for its held host") |
| + } |
| + for h, hr := range heldHolds().report() { |
| + if hr.Managed { |
| + t.Errorf("%s = %+v: a declined box's entry says managed", h, hr) |
| + } |
| + } |
| +} |
diff --git a/internal/rollout/status.go b/internal/rollout/status.go| index d347521cb..a4dc5d537 100644 |
| --- a/internal/rollout/status.go |
| +++ b/internal/rollout/status.go |
| @@ -57,7 +57,7 @@ func (m *Manager) Status() status.RolloutReport { |
| s.mu.Lock() |
| for host, h := range s.q.hosts { |
| hr := status.HostRollout{Account: s.key.acct, App: s.key.app, Installed: h.wantBuild, Serving: h.serving, |
| - Good: h.good, Awake: h.serving != ""} |
| + Good: h.good, Awake: h.serving != "", Managed: true} |
| // A host the activator was not asked about joined between the name |
| // read and this loop: nothing says it is settled, so this report |
| // calls it transient and the next one asks. |
diff --git a/internal/rollout/status_test.go b/internal/rollout/status_test.go| index 3d6cc73a1..6ea860f67 100644 |
| --- a/internal/rollout/status_test.go |
| +++ b/internal/rollout/status_test.go |
| @@ -391,3 +391,18 @@ func TestStatusReportsConsoleUnreachableUntilRecovery(t *testing.T) { |
| h.pass() |
| waitFor(t, "recovery", func() bool { row := h.m.Status().Hosts["a"]; return row.Serving == "v2" && row.Reason == "" }) |
| } |
| + |
| +// Console secrets slice 2, Task 1: every host the scheduler holds in its |
| +// queue is one the rollout manager manages, and the report says so, so the |
| +// console can tell a managed instance from one root restarts. |
| +func TestStatusMarksManagedHosts(t *testing.T) { |
| + h := newHarness(t, "a", "b") |
| + h.pass() |
| + r := h.m.Status() |
| + for _, host := range []string{"a", "b"} { |
| + got, ok := r.Hosts[host] |
| + if !ok || !got.Managed { |
| + t.Fatalf("%s = %+v (%v), want a managed entry", host, got, ok) |
| + } |
| + } |
| +} |
diff --git a/internal/status/snapshot.go b/internal/status/snapshot.go| index 6ab43d54a..4bd22fdb4 100644 |
| --- a/internal/status/snapshot.go |
| +++ b/internal/status/snapshot.go |
| @@ -419,6 +419,12 @@ type HostRollout struct { |
| // activator reports them (Plan 3 Group W). Absent for a binary |
| // instance, an asleep one and one that declares none. |
| Workers []WorkerState `json:"workers,omitempty"` |
| + // Managed is set when the box's armed rollout manager manages the host |
| + // (rollout.Manager.Status): its scheduler queues the host's builds and |
| + // config. A declined box's holds and root's retry status leave it |
| + // false. Absent from an older box, which the console reads as unknown, |
| + // not as unmanaged (console secrets slice 2). |
| + Managed bool `json:"managed,omitempty"` |
| } |
| // WorkerState is one worker of a rootfs instance. State is the activator's |