carlos / platform Public

console remote instances: round 3 review fixes (Astra, 18b5884b)

1. P1: a box report with no tenant identity for a host contributes
   nothing (pick joins only reports naming this account and app): no
   version, size, domains, certificate date or readings; the host is
   "Can't tell right now", never "Setting up" while some box serves it.
   The Web addresses tile says "no data right now" rather than "DNS &
   certs OK" for a domain with no reading, and a held-down instance with
   a pre-failure sample is not counted as reporting.
2-5. The canary-retire guard drops build-based convergence for one
   conservative rule (Paul kept the 15-minute window). With no route or
   record naming the channel, retiring is refused unless the app has
   settled: no record created or changed within channelSettle (or missing
   from the modification-time listing), no record deleted within it (the
   console audit log dates deletions through its doors), every box report
   read, and no fresh report of a host of the app that no record names.
   Local hosts' records count like any other. The refusal reuses "Could
   not verify no hosts follow this channel — try again." as a flash.

Tests fail first on 18b5884b; 12 mutants, all killed. Census
re-proposed (approval classes only); record-write entries for
channelHosts and retireUnsettled (key-site), unsettledFollowers removed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev ba69fcc15a34cca331b11a077617ba6777565904 parent 18b5884
15 files changed, +508 −419
  • docs/superpowers/notes/census-proposal-console-remote-instances.md +6 −6
  • docs/superpowers/notes/console-remote-instances.md +44 −6
  • internal/console/apiinstances.go +2 −2
  • internal/console/overview.go +10 −0
  • internal/console/remoteinstances.go +98 −101
  • internal/console/remoteinstances_round1_test.go +1 −1
  • internal/console/remoteinstances_round2_test.go +1 −223
  • internal/console/remoteinstances_round3_test.go +271 −0
  • internal/console/remoteinstances_test.go +7 −16
  • internal/console/server.go +46 −42
  • internal/console/templates/app_overview.html +1 −1
  • internal/console/view.go +1 −1
  • internal/provision/console_remote_instances_census_test.go +8 −8
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-console-remote-instances.tsv +11 −11

CI failed — run details

diff --git a/docs/superpowers/notes/census-proposal-console-remote-instances.md b/docs/superpowers/notes/census-proposal-console-remote-instances.md
index b8f0b17fd..3a0de1777 100644
--- a/docs/superpowers/notes/census-proposal-console-remote-instances.md
+++ b/docs/superpowers/notes/census-proposal-console-remote-instances.md
@@ -10,10 +10,10 @@ Ruling `census-ruling-console-remote-instances`. Every change below keeps the di
| `internal/console/instancepage.go` `Server.handleAppInstance` | body | unchanged (6) | A remote row (no local registry row) takes its aliases from its box report; local rows read ListAliases as before. |
| `internal/console/metricsview.go` `buildUnitRows` | body | unchanged (2) | Each unit row also keeps its raw per-sample readings (float32 CPU, int64 memory) so an owner's graph can be redrawn from only their samples; reads nothing new. |
| `internal/console/metricsview.go` `type UnitRow` | body | unchanged (1) | Two unexported fields carrying those raw per-sample readings; schema only. |
-| `internal/console/templates/app_overview.html` `external` | body | unchanged (1) | Running tile: does not claim Served when a static route's state is unknown, and reads the existing 'no data right now' when every instance's state is unknown; display only. |
-| `internal/console/apiinstances.go` `Server.instanceHealth` | sites | +whole:Route ×4 | Records with no local registry row get health only from a box report naming the record's own account and app (held down: Failed; transient or no tenant: Can't tell right now), readings pinned to that box and bounded by each record's created_at. Builds registry.Route literals from the record; reads no registry for them. |
-| `internal/console/server.go` `Server.channelHosts` | sites | +registry:Host, +whole:Route | Canary-retire guard also counts the account's instance records (ListRecordsStrict) and sidecar records (listed, then each read with GetSidecarRecord; any read error refuses), and records on other boxes that changed within channelSettle (or have no modification time) unless their box report shows the new channel's build, or whose box report still shows the retiring channel's build at any age (unsettledFollowers); it notes which hosts have a local registry row (rt.Host) so only remote hosts are candidates. Fails closed, including on an unreadable retiring pointer. |
-| `internal/console/view.go` `Assemble` | sites | +registry:Host, +whole:Route | Collects the set of local registry hosts (rt.Host) so a record host the registry has gets no remote row (its record's created_at bounds the local row's metrics history); adds rows from the account's records and box reports when given a remote source. |
+| `internal/console/server.go` `Server.channelHosts` | body | unchanged (4) | Canary-retire guard also counts the account's instance records (ListRecordsStrict) and sidecar records (listed, then each read with GetSidecarRecord; any read error refuses) naming the channel; with none, it refuses unless the app has settled (retireUnsettled: no record created, changed or deleted within channelSettle, every box report read, no box serving a host of the app that no record names). The registry read is as on main. Fails closed. |
+| `internal/console/templates/app_overview.html` `external` | body | unchanged (1) | Running tile does not claim Served when a route's state is unknown and reads the existing 'no data right now' when every instance's state is unknown; Web addresses tile reads 'no data right now' instead of 'DNS & certs OK' for a domain with no reading; display only. |
+| `internal/console/apiinstances.go` `Server.instanceHealth` | sites | +whole:Route ×4 | Records with no local registry row get health only from a box report naming the record's own account and app (held down: Failed; transient, unidentified or unread: Can't tell right now), readings pinned to that box and bounded by each record's created_at. Builds registry.Route literals from the record; reads no registry for them. |
+| `internal/console/view.go` `Assemble` | sites | +registry:Host, +whole:Route | Collects the set of local registry hosts (rt.Host) so a record host the registry has gets no remote row (its record's created_at bounds the local row's metrics history); adds rows from the account's records and tenant-named box reports when given a remote source. |
Envelopes re-pinned: `internal/console`, `internal/console/templates`.
@@ -27,11 +27,11 @@ Recorded dispositions, which each change must still satisfy:
- `internal/console/instancepage.go` `Server.handleAppInstance`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=merge-ruling-2;basis=Instance page adds updates view from rollout join; browser rendering remains legacy.
- `internal/console/metricsview.go` `buildUnitRows`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input
- `internal/console/metricsview.go` `type UnitRow`: diagnostic, task H3. Basis: schema-only
+- `internal/console/server.go` `Server.channelHosts`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route
- `internal/console/templates/app_overview.html` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input
- `internal/console/apiinstances.go` `Server.instanceHealth`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route
-- `internal/console/server.go` `Server.channelHosts`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route
- `internal/console/view.go` `Assemble`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route
-Seal: `0c4eabfe38e12b098285bdeb5ceb0b16e5333928f5b02e160a6b16b5fd9ce1e0` → `6fc23039029e8ec93637ea4ac7b5718e0add91c4c4595e54ce42621dc1d35ba6`.
+Seal: `0c4eabfe38e12b098285bdeb5ceb0b16e5333928f5b02e160a6b16b5fd9ce1e0` → `660d053abfe5f3136aaa853f325bb638bda1221f243b6a75c57978b739b51aae`.
Overlay: `internal/provision/testdata/plan14-root-reads-console-remote-instances.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/notes/console-remote-instances.md b/docs/superpowers/notes/console-remote-instances.md
index f92b10a40..118375003 100644
--- a/docs/superpowers/notes/console-remote-instances.md
+++ b/docs/superpowers/notes/console-remote-instances.md
@@ -92,7 +92,7 @@ being inert when the AU and UK boxes started hosting instances.
| Deployments, Releases | Counts and canary followers include remote rows. |
| Settings, Domains | Remote hosts are listed with the box's DNS status and certificate date. |
| Fleet tab | "Apps on the shared fleet" also counts apps with a record not placed on a customer fleet. |
-| `channelHosts` | The canary-retire guard also counts instance and sidecar records whose channel matches, and records on other boxes that may have been moved off the channel moments ago (below). They are read strictly and live from the bucket, never through the record view, because this is the reader whose "nobody" deletes a pointer. A failed listing, a listed record that will not read (even one deleted between the listing and the read), or more records than the cap refuses the retire. |
+| `channelHosts` | The canary-retire guard also counts instance and sidecar records whose channel matches, and refuses while the app has not settled (Round 3, below). They are read strictly and live from the bucket, never through the record view, because this is the reader whose "nobody" deletes a pointer. A failed listing, a listed record that will not read (even one deleted between the listing and the read), or more records than the cap refuses the retire. |
| `carlos instances list` | A record with no local row takes its health from its box report and the sweep, instead of always "Setting up". Same cause, same fix. |
## What stays local, on purpose
@@ -149,10 +149,9 @@ is filed as an amadan discussion.
the Overview costs less than before.
- Metrics: unchanged (shared in-process cache).
- `channelHosts`: 1 LIST plus 1 GET per instance record, plus the same for
- sidecar records, per canary create or retire, plus 2 modification-time
- LISTs when the app has records on other boxes, and the channel pointer
- GETs and the shared box-report read when one of those changed within
- the settle window. Write doors only.
+ sidecar records, per canary create or retire; when no record names the
+ channel, 2 modification-time LISTs, one console audit query and the
+ shared box-report read. Write doors only.
- **Pinned by `TestRemoteInstanceRequestBudget`:** an armed Overview view
makes 1 LIST and 2 GETs of box reports (two boxes) and no record reads; a
second Overview, Deployments and the account app list within the minute
@@ -218,7 +217,8 @@ Three findings, all fixed, each with a test that failed on 02edd585
a transient one reads "Can't tell right now". Astra's note that a
static-only app with unknown remote state still read "All good" and
"Served" is fixed with it.
-3. Canary retire missed a remote follower whose record had moved to
+3. (Superseded by the simpler rule in Round 3, below.) Canary retire
+ missed a remote follower whose record had moved to
another channel but whose box had not converged. Box reports do not
carry a host's channel, so the guard uses builds and time. A record on
another box is a possible follower of the retiring channel when a fresh
@@ -247,3 +247,41 @@ listing counted as settled; an unreadable retiring pointer read as "no
build"; and record age alone was taken as convergence even while the box
reported the retiring build.
+## Round 3 review (Astra, 18b5884b)
+
+Paul ruled to keep the 15-minute window for the same-build case. Astra's
+remaining findings were fixed, and the retire guard was simplified to one
+conservative rule.
+
+1. A box report with no tenant identity for a host (no rollout entry) now
+ contributes nothing: no version, size, domains, certificate date or
+ readings. The host's state is "Can't tell right now", and it is never
+ "Setting up" while some box serves it. The Web addresses tile no longer
+ calls a domain with no reading "DNS & certs OK"; it says the existing
+ "no data right now". A held-down instance with a sample from before its
+ failure is no longer counted as reporting.
+2. The retire guard no longer tries to prove convergence from builds.
+ Retiring channel C of an app is allowed only when no route on the
+ console's box and no instance or sidecar record names C, and the app has
+ settled:
+ - no record was created or changed in the last `channelSettle` (15
+ minutes), and none is missing from the modification-time listing;
+ - no record was deleted in that time. The change index carries no
+ times, so deletions are dated by the console's own audit log: every
+ member deletion goes through the instance and sidecar delete doors,
+ which audit it. An unreadable audit log, or one too busy to look back
+ that far, counts as a recent deletion;
+ - every box report was read; and
+ - no fresh box report names this account and app for a host that no
+ record names. That covers a deletion made behind the console's back,
+ and a route a box has not yet dropped after its record went. It also
+ holds a retire for an app with a hand route on another box, which
+ could be following the channel and whose channel nobody can see.
+
+ Records of hosts on the console's own box count like any other, so a
+ local route never stands in for a remote copy. The refusal is the
+ existing "Could not verify no hosts follow this channel — try again."
+ sentence, shown as a flash. A clearer sentence that names the wait would
+ be new copy, for Luna. The cost: a retire right after any record change
+ waits up to 15 minutes.
+
diff --git a/internal/console/apiinstances.go b/internal/console/apiinstances.go
index 85c79f176..e7fc4e2cc 100644
--- a/internal/console/apiinstances.go
+++ b/internal/console/apiinstances.go
@@ -303,8 +303,8 @@ func (s *Server) instanceHealth(ctx context.Context, recs []provision.Record) ma
reports, loaded = foldFleetReports(boxes, complete, time.Now()), true
}
rep := reports.pick(rec.Host, rec.Account, rec.App)
- if rep == nil || !rep.tenantKnown {
- if _, fleetPlaced := registry.FleetPlacement(rec.Region); rep != nil || !reports.complete || fleetPlaced {
+ if rep == nil {
+ if _, fleetPlaced := registry.FleetPlacement(rec.Region); reports.seen(rec.Host) || !reports.complete || fleetPlaced {
out[rec.Host] = healthUnknown
}
continue
diff --git a/internal/console/overview.go b/internal/console/overview.go
index f482f7ea1..fc1b260fc 100644
--- a/internal/console/overview.go
+++ b/internal/console/overview.go
@@ -89,6 +89,10 @@ type OverviewStats struct {
// pointing here yet, or a cert that is not ready.
DomainTotal int
DomainAttention int
+ // DomainUnknown counts domains of instances on other boxes that no
+ // accepted box report has a DNS or certificate reading for: the tile
+ // must not call those OK.
+ DomainUnknown int
// Shipped releases. The versions list is capped (versionsCap), so
// ReleasesCapped says "20+" rather than lying with "20".
@@ -161,6 +165,10 @@ func assembleOverview(view *AppView, acct string, metrics []InstanceMetrics, ver
st.InstanceExpected++
if rt.unknown {
unknownInstances++
+ } else if rt.Status == "failed" {
+ // Failed (an instance held down after a failed build) wins
+ // over a reading: a sample from before the failure is not
+ // health. Counted, and neither reporting nor asleep.
} else if reporting[rt.Host] || rt.boxAwake {
st.InstanceReporting++
} else if rt.Hibernate && rt.Status != "failed" {
@@ -187,6 +195,8 @@ func assembleOverview(view *AppView, acct string, metrics []InstanceMetrics, ver
st.DomainTotal++
if domainNeedsAttention(view.Domains[i]) {
st.DomainAttention++
+ } else if rt.remote && view.Domains[i].DNS == "" && view.Domains[i].TLS == "" {
+ st.DomainUnknown++
}
}
}
diff --git a/internal/console/remoteinstances.go b/internal/console/remoteinstances.go
index 9a8bd3f98..785f249cb 100644
--- a/internal/console/remoteinstances.go
+++ b/internal/console/remoteinstances.go
@@ -221,16 +221,18 @@ func foldFleetReports(boxes []status.Box, complete bool, now time.Time) fleetRep
}
// pick is the one box report a remote row of acct/app joins for host, or
-// nil. A report whose rollout names another tenant is never joined: a fresh
-// snapshot may predate the host changing hands. Among the rest, a report
-// that names this tenant beats one that names none (an older box), then the
-// freshest wins, then the lower box label, so the choice is stable. Two
-// boxes reporting one host is a move in flight; the page shows one row.
+// nil. Only a report whose rollout names this account and app is joined:
+// one naming another tenant may predate the host changing hands, and one
+// naming no tenant (a box without a rollout report) could be anyone's, so
+// it contributes nothing at all, not a version, a size, a domain or a
+// reading. Among the rest the freshest wins, then the lower box label, so
+// the choice is stable. Two boxes reporting one host is a move in flight;
+// the page shows one row.
func (f fleetReports) pick(host, acct, app string) *hostReport {
var best *hostReport
for i := range f.byHost[host] {
r := &f.byHost[host][i]
- if r.tenantKnown && (r.account != acct || r.app != app) {
+ if !r.tenantKnown || r.account != acct || r.app != app {
continue
}
if best == nil || betterReport(r, best) {
@@ -253,6 +255,11 @@ func (f fleetReports) tenantReports(host, acct, app string) []hostReport {
return out
}
+// seen reports whether any fresh box report names host at all, whoever
+// it says the host belongs to: a host some box serves is not "not minted
+// anywhere", even when the report cannot be joined.
+func (f fleetReports) seen(host string) bool { return len(f.byHost[host]) > 0 }
+
func betterReport(a, b *hostReport) bool {
if a.tenantKnown != b.tenantKnown {
return a.tenantKnown
@@ -299,7 +306,7 @@ type remoteRows struct {
// host's own carlos-exec@ and carlos-app@ units and nothing a record names.
// Restartable is false: the browser restart door acts on the console box's
// registry only.
-func remoteRoute(rec provision.Record, rep *hostReport, complete bool, acct string, dns DNSTargets) (RouteView, DomainView) {
+func remoteRoute(rec provision.Record, rep *hostReport, f fleetReports, acct string, dns DNSTargets) (RouteView, DomainView) {
kind := rec.Kind
if kind == "" {
kind = "instance"
@@ -332,8 +339,6 @@ func remoteRoute(rec provision.Record, rep *hostReport, complete bool, acct stri
rv.dbBytes = rep.dbBytes
rv.aliases = rep.aliases
switch {
- case !rep.tenantKnown:
- rv.unknown = true
case rep.down:
// Held down after a failed hold-mode build: the local rows'
// word for an instance that will not start, "Failed".
@@ -358,7 +363,7 @@ func remoteRoute(rec provision.Record, rep *hostReport, complete bool, acct stri
dv.Guidance = domainGuidance(rec.Host, dns)
}
}
- case complete && !fleetPlaced:
+ case f.complete && !fleetPlaced && !f.seen(rec.Host):
rv.Status = "pending"
default:
rv.unknown = true
@@ -441,116 +446,108 @@ func (s *Server) assembleApps(ctx context.Context, acct string, apps []string) (
return Assemble(s.cfg.Registry, s.cfg.Releases, s.cfg.ReleasePub, acct, apps, s.dnsTargets(), s.remoteSource(ctx, acct))
}
-// settleCandidate is a record (instance or sidecar) of the app that is on
-// another channel than the one being retired: the host it names and the
-// channel its record says now.
-type settleCandidate struct{ host, channel string }
+// errRetireUnsettled is channelHosts' answer when no record names the
+// channel but the app has not settled long enough for that to mean nobody
+// follows it.
+var errRetireUnsettled = errors.New("the app's instances have not settled")
-// unsettledFollowers is the canary-retire guard's answer for records that
-// are on another channel now but may have been moved off the retiring one
-// moments ago. A channel move writes the record and bumps the serial; the
-// box converges its route a few seconds later, and until then it still
-// follows the old channel. Box reports do not carry a host's channel, so
-// the evidence is time and builds:
+// retireUnsettled is the canary-retire guard's one conservative rule for an
+// app with no follower by record. Box reports carry no channel, so nothing
+// can prove a box has left a channel; instead the retire waits until the
+// app has been still. It returns errRetireUnsettled when:
//
-// - a record last modified more than channelSettle ago is settled: boxes
-// converge record changes within seconds of the serial bump, and a box
-// that has not done so in channelSettle (three status snapshot periods,
-// the fleet's staleness rule, status.BoxStale) is one the fleet already
-// treats as dark;
-// - a record modified within it is settled only when every fresh report
-// naming this account and app shows the host on its new channel's
-// build, and that build differs from the retiring channel's (otherwise
-// the reports cannot tell the two channels apart).
+// - any instance or sidecar record of the app was created or changed in
+// the last channelSettle, or is missing from the modification-time
+// listing (deleted since it was read);
+// - any was deleted in the last channelSettle: every member deletion goes
+// through the console's instance and sidecar delete doors, which audit
+// it, so the console's own audit log dates it (an unreadable log, or
+// one too busy to look back that far, counts as a recent deletion);
+// - the box reports cannot all be read; or
+// - a fresh box report names this account and app for a host no record
+// names: a route still up after its record was deleted, or a hand route
+// on another box, either of which could be following the channel.
//
-// Whatever a record's age, any fresh tenant-named report showing its host
-// on the retiring channel's build, which its new channel does not point at,
-// is evidence it has not converged, and holds the retire too. Every such
-// report counts, not only the one the pages show (a move in flight has two). (When the two
-// channels point at one build, no report can tell them apart; then only
-// the window decides.) Everything else is settled. Only hosts on other
-// boxes are candidates: a host with a row in the console box's registry has
-// its channel read off that row. Fails closed: an unreadable retiring
-// pointer, a store that cannot list modification times (both real stores
-// can) or a failed listing is an error whenever there is a candidate, and a
-// candidate missing from the modification-time listing (deleted since it
-// was read) counts as changed within the window.
-func (s *Server) unsettledFollowers(ctx context.Context, acct, app, channel string, others map[string]settleCandidate) ([]string, error) {
- if len(others) == 0 {
- return nil, nil
- }
- retiring, err := release.Channel(ctx, s.cfg.Releases, s.cfg.ReleasePub, acct, app, channel)
- switch {
- case errors.Is(err, os.ErrNotExist):
- return nil, nil // no pointer: there is nothing to strand
- case err != nil:
- return nil, fmt.Errorf("the %s pointer of %s/%s: %w", channel, acct, app, err)
+// Records of hosts on the console's own box count like any other: a local
+// route says where one copy of a host is, not that no other copy exists.
+// Other errors (no modification times, a failed listing) fail closed too.
+func (s *Server) retireUnsettled(ctx context.Context, acct, app string, keys, hosts map[string]bool) error {
+ now := time.Now()
+ unsettled := func(format string, a ...any) error {
+ return fmt.Errorf("%w: "+format, append([]any{errRetireUnsettled}, a...)...)
}
ml, ok := s.cfg.Releases.(release.ModLister)
if !ok {
- return nil, errors.New("the deployment store cannot list modification times, so a recent channel move cannot be ruled out")
+ return errors.New("the deployment store cannot list modification times, so a recent change cannot be ruled out")
}
- now := time.Now()
- mods := map[string]time.Time{}
+ listed := map[string]bool{}
for _, prefix := range []string{provision.RecordsPrefix(acct, app), provision.SidecarsPrefix(acct, app)} {
objs, err := ml.ListMod(ctx, prefix)
if err != nil {
- return nil, fmt.Errorf("record modification times of %s/%s: %w", acct, app, err)
+ return fmt.Errorf("record modification times of %s/%s: %w", acct, app, err)
}
for _, o := range objs {
- mods[o.Key] = o.Mod
+ if !keys[o.Key] {
+ continue
+ }
+ listed[o.Key] = true
+ if now.Sub(o.Mod) < channelSettle {
+ return unsettled("%s changed %s ago", o.Key, now.Sub(o.Mod).Round(time.Second))
+ }
}
}
- versions := map[string]string{}
- version := func(ch string) string {
- if ch == "" {
- ch = "stable"
+ for key := range keys {
+ if !listed[key] {
+ return unsettled("%s has no modification time (deleted since it was read)", key)
}
- if v, ok := versions[ch]; ok {
- return v
- }
- v := "" // unreadable: matches no report
- if p, err := release.Channel(ctx, s.cfg.Releases, s.cfg.ReleasePub, acct, app, ch); err == nil && p != nil {
- v = p.Version
- }
- versions[ch] = v
- return v
+ }
+ if err := s.recentRecordDeletion(acct, app, now); err != nil {
+ return err
}
boxes, complete := s.pageBoxReports(ctx)
- reports := foldFleetReports(boxes, complete, now)
- var out []string
- for key, c := range others {
- moved := version(c.channel)
- // Every fresh report naming this tenant counts: during a move two
- // boxes may report the host, and the one still on the old channel
- // is the one that matters.
- stillOld, converged := false, false
- if moved != retiring.Version {
- reps := reports.tenantReports(c.host, acct, app)
- converged = len(reps) > 0
- for _, r := range reps {
- if r.version == retiring.Version {
- stillOld = true
- }
- if r.version == "" || r.version != moved {
- converged = false
- }
+ if !complete {
+ return unsettled("not every box report could be read")
+ }
+ f := foldFleetReports(boxes, complete, now)
+ for host, reps := range f.byHost {
+ if hosts[host] {
+ continue
+ }
+ for _, r := range reps {
+ if r.tenantKnown && r.account == acct && r.app == app {
+ return unsettled("box %s still serves %s, which no record names", r.box, host)
}
}
- mod, listed := mods[key]
- recent := !listed || now.Sub(mod) < channelSettle
- switch {
- case stillOld:
- // A box still runs the retiring channel's build, which the new
- // channel does not point at: whatever the record's age, it has
- // not converged.
- out = append(out, c.host)
- case recent && !converged:
- // Changed (or of unknown age) within the window, and not every
- // report shows it on its new channel's own build yet.
- out = append(out, c.host)
+ }
+ return nil
+}
+
+// retireAuditWindow is how many of an app's most recent audit rows the
+// deletion check reads; if all of them are inside channelSettle it cannot
+// see past them, and says the app has not settled.
+const retireAuditWindow = 500
+
+// recentRecordDeletion is errRetireUnsettled when the console's audit log
+// shows an instance or sidecar of acct/app deleted within channelSettle.
+func (s *Server) recentRecordDeletion(acct, app string, now time.Time) error {
+ a, err := s.store.AccountBySqid(acct)
+ if err != nil || a == nil {
+ return fmt.Errorf("%w: the account's audit log cannot be read: %v", errRetireUnsettled, err)
+ }
+ events, err := s.store.Events(a.ID, app, retireAuditWindow)
+ if err != nil {
+ return fmt.Errorf("%w: the app's audit log cannot be read: %v", errRetireUnsettled, err)
+ }
+ for _, e := range events {
+ if now.Sub(e.CreatedAt) >= channelSettle {
+ return nil // newest first: nothing older can be recent
+ }
+ if e.Action == "instance-delete" || e.Action == "sidecar-delete" {
+ return fmt.Errorf("%w: %s deleted %s ago", errRetireUnsettled, e.Target, now.Sub(e.CreatedAt).Round(time.Second))
}
}
- sort.Strings(out)
- return out, nil
+ if len(events) >= retireAuditWindow {
+ return fmt.Errorf("%w: the audit log is too busy to rule out a recent deletion", errRetireUnsettled)
+ }
+ return nil
}
diff --git a/internal/console/remoteinstances_round1_test.go b/internal/console/remoteinstances_round1_test.go
index 0beef31a1..c1092aa57 100644
--- a/internal/console/remoteinstances_round1_test.go
+++ b/internal/console/remoteinstances_round1_test.go
@@ -122,7 +122,7 @@ func TestRemoteUnknownTenantReportHealth(t *testing.T) {
{Host: "r.example.com", App: "shop", Account: "a", Hibernate: &no, Addr: "127.0.0.1:1"},
{Host: "s.example.com", App: "shop", Account: "a", Kind: "static"},
} {
- rv, dv := remoteRoute(rec, f.pick(rec.Host, "a", "shop"), f.complete, "a", DNSTargets{})
+ rv, dv := remoteRoute(rec, f.pick(rec.Host, "a", "shop"), f, "a", DNSTargets{})
routes, domains = append(routes, rv), append(domains, dv)
}
view := &AppView{Routes: routes, Domains: domains}
diff --git a/internal/console/remoteinstances_round2_test.go b/internal/console/remoteinstances_round2_test.go
index 8c3940304..7245c6812 100644
--- a/internal/console/remoteinstances_round2_test.go
+++ b/internal/console/remoteinstances_round2_test.go
@@ -5,18 +5,13 @@ package console
import (
"context"
- "errors"
"net/http"
- "net/url"
- "os"
- "path/filepath"
"strings"
"testing"
"time"
"github.com/carlosframework/platform/internal/metrics"
"github.com/carlosframework/platform/internal/provision"
- "github.com/carlosframework/platform/internal/registry"
"github.com/carlosframework/platform/internal/release"
"github.com/carlosframework/platform/internal/status"
)
@@ -182,7 +177,7 @@ func TestRemoteTransientIsNotAsleep(t *testing.T) {
// neither "All good" nor "Served", and its account-home row can't tell.
func TestRemoteUnknownStaticIsNotServed(t *testing.T) {
f := foldFleetReports(nil, false, time.Now())
- rv, dv := remoteRoute(provision.Record{Host: "s.example.com", App: "shop", Account: "a", Kind: "static"}, nil, f.complete, "a", DNSTargets{})
+ rv, dv := remoteRoute(provision.Record{Host: "s.example.com", App: "shop", Account: "a", Kind: "static"}, nil, f, "a", DNSTargets{})
view := &AppView{App: "shop", Routes: []RouteView{rv}, Domains: []DomainView{dv}}
if st := assembleOverview(view, "a", []InstanceMetrics{}, nil, boxJoin{}); st.VerdictLabel != "Can't tell right now" || st.InstanceUnknown != 1 {
t.Fatalf("static unknown overview = %q (unknown %d)", st.VerdictLabel, st.InstanceUnknown)
@@ -192,97 +187,6 @@ func TestRemoteUnknownStaticIsNotServed(t *testing.T) {
}
}
-// P2: retiring canary/rc while a remote follower has been moved to another
-// channel in its record but its box has not converged yet (B's reconcile is
-// paused). The retire is refused until B's report shows the host on its new
-// channel's build, and, separately, once the move is older than the settle
-// window.
-func TestRetireCanaryWaitsForRemoteConvergence(t *testing.T) {
- tb := newTwoBoxes(t)
- ds := tb.fx.rel.(*deletableStore)
- shipAndPromote(t, tb.fx, tb.sqid, "shop", "v4", "canary/rc")
- shipAndPromote(t, tb.fx, tb.sqid, "shop", "v5", "canary/next")
- tb.create(t, tb.token, tb.sqid, "shop", remoteHost, "uk", "canary/rc")
- tb.reconcile(t, "v4")
- report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096)
- // Move the record; B does not reconcile.
- if status, _, out := rawReq(t, http.MethodPost, instancesURL(tb.fx, tb.sqid, "shop")+"/"+remoteHost+"/channel", tb.token,
- `{"channel":"canary/next"}`); status != http.StatusOK {
- t.Fatalf("channel move = %d %s", status, out)
- }
- if rt, _ := tb.regB.Get(remoteHost); rt == nil || rt.Channel != "canary/rc" {
- t.Fatalf("fixture: B's route = %+v, want still on canary/rc", rt)
- }
- csrf := sessionToken(t, tb.fx, tb.browser)
- retire := func() string {
- status, loc, body := postForm(t, tb.browser, tb.fx.ts.URL+"/a/"+tb.sqid+"/apps/shop/canary/retire",
- url.Values{"csrf": {csrf}, "name": {"rc"}, "confirmed": {"1"}})
- if status != http.StatusSeeOther {
- t.Fatalf("retire = %d %s", status, body)
- }
- _, _, page := get(t, tb.browser, tb.fx.ts.URL+loc)
- return page
- }
- pointer := func() error {
- _, _, err := tb.fx.rel.Get(context.Background(), release.ChannelKey(tb.sqid, "shop", "canary/rc"))
- return err
- }
- tb.fx.srv.boxReports.expire()
- if page := retire(); !strings.Contains(page, "still has a host ("+remoteHost+") following it") {
- t.Fatalf("retire was not refused for an unconverged remote follower:\n%s", page)
- }
- if err := pointer(); err != nil {
- t.Fatalf("canary/rc was retired while B still followed it: %v", err)
- }
-
- // The move is older than the settle window, but B's fresh report still
- // shows the retiring channel's build (v4, not next's v5): record age is
- // not convergence, so the retire stays refused.
- path := filepath.Join(ds.root, provision.RecordKey(tb.sqid, "shop", remoteHost))
- old := time.Now().Add(-channelSettle - time.Minute)
- if err := os.Chtimes(path, old, old); err != nil {
- t.Fatal(err)
- }
- if page := retire(); !strings.Contains(page, "still has a host ("+remoteHost+") following it") {
- t.Fatalf("retire after the window while B still runs the retiring build:\n%s", page)
- }
- // B converges and reports the new build: the retire goes ahead.
- tb.reconcile(t, "")
- if err := tb.regB.SetVersions(remoteHost, "v5", "v4"); err != nil {
- t.Fatal(err)
- }
- report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096)
- tb.fx.srv.boxReports.expire()
- if page := retire(); !strings.Contains(page, "Retired canary rc") {
- t.Fatalf("retire once B converged:\n%s", page)
- }
-}
-
-// P2: the same unconverged follower, then B converges (reconcile, adopt the
-// new build, report): the report's build is the evidence, and the retire
-// goes ahead inside the window.
-func TestRetireCanaryAfterRemoteConvergence(t *testing.T) {
- tb := newTwoBoxes(t)
- shipAndPromote(t, tb.fx, tb.sqid, "shop", "v4", "canary/rc")
- shipAndPromote(t, tb.fx, tb.sqid, "shop", "v5", "canary/next")
- tb.create(t, tb.token, tb.sqid, "shop", remoteHost, "uk", "canary/rc")
- tb.reconcile(t, "v4")
- if status, _, out := rawReq(t, http.MethodPost, instancesURL(tb.fx, tb.sqid, "shop")+"/"+remoteHost+"/channel", tb.token,
- `{"channel":"canary/next"}`); status != http.StatusOK {
- t.Fatalf("channel move = %d %s", status, out)
- }
- tb.reconcile(t, "")
- if err := tb.regB.SetVersions(remoteHost, "v5", "v4"); err != nil {
- t.Fatal(err)
- }
- report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096)
- tb.fx.srv.boxReports.expire()
- hosts, err := tb.fx.srv.channelHosts(context.Background(), tb.sqid, "shop", "canary/rc")
- if err != nil || len(hosts) != 0 {
- t.Fatalf("followers of canary/rc after B converged = %v %v, want none", hosts, err)
- }
-}
-
// P1: a remote row with no ownership start (a record without created_at)
// joins no readings, even from its accepted box.
func TestRemoteRowWithoutStartHasNoReadings(t *testing.T) {
@@ -314,29 +218,6 @@ func TestRemoteInstancesListIgnoresPreviousTenantSample(t *testing.T) {
}
}
-// P2: when the retiring channel and the new one point at the same build, a
-// report showing that build cannot tell them apart; only the settle window
-// lets the retire through.
-func TestRetireCanaryEqualBuildsWaitForWindow(t *testing.T) {
- tb := newTwoBoxes(t)
- shipAndPromote(t, tb.fx, tb.sqid, "shop", "v4", "canary/rc")
- if err := release.Promote(context.Background(), tb.fx.rel, tb.fx.priv, tb.sqid, "shop", "canary/next", "v4"); err != nil {
- t.Fatal(err)
- }
- tb.create(t, tb.token, tb.sqid, "shop", remoteHost, "uk", "canary/rc")
- tb.reconcile(t, "v4")
- if status, _, out := rawReq(t, http.MethodPost, instancesURL(tb.fx, tb.sqid, "shop")+"/"+remoteHost+"/channel", tb.token,
- `{"channel":"canary/next"}`); status != http.StatusOK {
- t.Fatalf("channel move = %d %s", status, out)
- }
- report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096) // B still on rc, at v4
- tb.fx.srv.boxReports.expire()
- hosts, err := tb.fx.srv.channelHosts(context.Background(), tb.sqid, "shop", "canary/rc")
- if err != nil || len(hosts) != 1 || hosts[0] != remoteHost {
- t.Fatalf("followers of canary/rc = %v %v, want the unconverged host", hosts, err)
- }
-}
-
// Codex round 2 (census review of d09ea830), P1: a provisioned local row
// whose record cannot be read has no known ownership start, so it shows no
// readings rather than the whole window.
@@ -374,106 +255,3 @@ func (s listModHiding) ListMod(ctx context.Context, prefix string) ([]release.Ke
}
return out, err
}
-
-// pointerFailing fails reads of one channel pointer.
-type pointerFailing struct {
- *deletableStore
- key string
-}
-
-func (s pointerFailing) Get(ctx context.Context, key string) ([]byte, string, error) {
- if key == s.key {
- return nil, "", errors.New("boom")
- }
- return s.deletableStore.Get(ctx, key)
-}
-
-// Codex round 2, P2: a candidate with no modification time is not settled,
-// and an unreadable retiring pointer fails the check closed.
-func TestRetireGuardUnknownsFailClosed(t *testing.T) {
- tb := newTwoBoxes(t)
- ds := tb.fx.rel.(*deletableStore)
- shipAndPromote(t, tb.fx, tb.sqid, "shop", "v4", "canary/rc")
- tb.create(t, tb.token, tb.sqid, "shop", remoteHost, "uk", "stable")
- tb.reconcile(t, "v3")
- old := time.Now().Add(-channelSettle - time.Minute)
- if err := os.Chtimes(filepath.Join(ds.root, provision.RecordKey(tb.sqid, "shop", remoteHost)), old, old); err != nil {
- t.Fatal(err)
- }
- // No report of B: nothing shows the host on either build, so only the
- // record's age speaks for it.
- tb.fx.srv.boxReports.expire()
- if hosts, err := tb.fx.srv.channelHosts(context.Background(), tb.sqid, "shop", "canary/rc"); err != nil || len(hosts) != 0 {
- t.Fatalf("fixture: settled host = %v %v", hosts, err)
- }
- tb.fx.srv.cfg.Releases = listModHiding{ds, provision.RecordKey(tb.sqid, "shop", remoteHost)}
- if hosts, err := tb.fx.srv.channelHosts(context.Background(), tb.sqid, "shop", "canary/rc"); err == nil && len(hosts) == 0 {
- t.Fatal("a record missing from the modification-time listing was treated as settled")
- }
- tb.fx.srv.cfg.Releases = pointerFailing{ds, release.ChannelKey(tb.sqid, "shop", "canary/rc")}
- if hosts, err := tb.fx.srv.channelHosts(context.Background(), tb.sqid, "shop", "canary/rc"); err == nil {
- t.Fatalf("an unreadable retiring pointer = %v, nil error", hosts)
- }
-}
-
-// Codex census review of 050a3a7e, P1: during a move two fresh boxes report
-// the host for this account. The fresher shows the new channel's build;
-// the other still runs the retiring one. Every matching report counts, so
-// the retire is refused whatever the record's age.
-func TestRetireGuardConsidersEveryReport(t *testing.T) {
- tb := newTwoBoxes(t)
- ds := tb.fx.rel.(*deletableStore)
- shipAndPromote(t, tb.fx, tb.sqid, "shop", "v4", "canary/rc")
- shipAndPromote(t, tb.fx, tb.sqid, "shop", "v5", "canary/next")
- tb.create(t, tb.token, tb.sqid, "shop", remoteHost, "uk", "canary/next")
- tb.reconcile(t, "v5")
- old := time.Now().Add(-channelSettle - time.Minute)
- if err := os.Chtimes(filepath.Join(ds.root, provision.RecordKey(tb.sqid, "shop", remoteHost)), old, old); err != nil {
- t.Fatal(err)
- }
- // Box C still carries the host on canary/rc at v4 (the source of a move
- // that has not let go of it), reporting a little earlier than B.
- regC, err := registry.Open(filepath.Join(t.TempDir(), "registry-c.db"))
- if err != nil {
- t.Fatal(err)
- }
- t.Cleanup(func() { regC.Close() })
- if err := regC.Upsert(registry.Route{Host: remoteHost, Kind: "instance", App: "shop", Account: tb.sqid,
- Channel: "canary/rc", Version: "v4", Provisioned: true, Status: "ready"}); err != nil {
- t.Fatal(err)
- }
- report(t, tb.fx.rel, regC, "box-c", "uk", time.Now().Add(-time.Minute), nil, 4096)
- report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096)
- tb.fx.srv.boxReports.expire()
- hosts, err := tb.fx.srv.channelHosts(context.Background(), tb.sqid, "shop", "canary/rc")
- if err != nil || len(hosts) != 1 || hosts[0] != remoteHost {
- t.Fatalf("followers of canary/rc = %v %v, want the host box C still runs on rc's build", hosts, err)
- }
-}
-
-// Within the window, convergence needs every matching report on the new
-// channel's build: one box on it and another on some third build is not
-// settled.
-func TestRetireGuardConvergenceNeedsEveryReport(t *testing.T) {
- tb := newTwoBoxes(t)
- shipAndPromote(t, tb.fx, tb.sqid, "shop", "v4", "canary/rc")
- shipAndPromote(t, tb.fx, tb.sqid, "shop", "v5", "canary/next")
- tb.create(t, tb.token, tb.sqid, "shop", remoteHost, "uk", "canary/next")
- tb.reconcile(t, "v5")
- regC, err := registry.Open(filepath.Join(t.TempDir(), "registry-c.db"))
- if err != nil {
- t.Fatal(err)
- }
- t.Cleanup(func() { regC.Close() })
- if err := regC.Upsert(registry.Route{Host: remoteHost, Kind: "instance", App: "shop", Account: tb.sqid,
- Channel: "stable", Version: "v3", Provisioned: true, Status: "ready"}); err != nil {
- t.Fatal(err)
- }
- report(t, tb.fx.rel, regC, "box-c", "uk", time.Now().Add(-time.Minute), nil, 4096)
- report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096)
- tb.fx.srv.boxReports.expire()
- hosts, err := tb.fx.srv.channelHosts(context.Background(), tb.sqid, "shop", "canary/rc")
- if err != nil || len(hosts) != 1 || hosts[0] != remoteHost {
- t.Fatalf("followers of canary/rc = %v %v, want the host not every report shows converged", hosts, err)
- }
-}
diff --git a/internal/console/remoteinstances_round3_test.go b/internal/console/remoteinstances_round3_test.go
new file mode 100644
index 000000000..6ac0192cc
--- /dev/null
+++ b/internal/console/remoteinstances_round3_test.go
@@ -0,0 +1,271 @@
+package console
+
+// Round 3 review fixes (Astra, 18b5884b).
+
+import (
+ "context"
+ "errors"
+ "net/http"
+ "net/url"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/metrics"
+ "github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/status"
+)
+
+// P1: a box report with no tenant identity for the host (no rollout entry)
+// contributes nothing to this account's row: no version, size, domains,
+// certificate date or readings. The host's state is unknown.
+func TestRemoteUnidentifiedReportContributesNothing(t *testing.T) {
+ tb := newTwoBoxes(t)
+ tb.create(t, tb.token, tb.sqid, "shop", remoteHost, "uk", "")
+ tb.reconcile(t, "v3")
+ certAt := time.Date(2027, 1, 15, 0, 0, 0, 0, time.UTC).Unix()
+ if err := tb.regB.SetDNSStatus(remoteHost, "pointing", time.Now().Unix()); err != nil {
+ t.Fatal(err)
+ }
+ if err := tb.regB.SetCertExpiresAt(remoteHost, certAt); err != nil {
+ t.Fatal(err)
+ }
+ if err := tb.regB.UpsertAlias(registry.RouteAlias{Alias: "www.shop-store.example", Host: remoteHost,
+ Account: tb.sqid, App: "shop", DNSStatus: "pointing", CertExpiresAt: certAt}); err != nil {
+ t.Fatal(err)
+ }
+ routes, err := tb.regB.List()
+ if err != nil {
+ t.Fatal(err)
+ }
+ aliases, err := tb.regB.ListAliases()
+ if err != nil {
+ t.Fatal(err)
+ }
+ b := status.CollectBox(routes, status.Probes{MachineID: "box-b", Region: "uk", Aliases: aliases,
+ DBBytes: func(string) *int64 { n := int64(9216); return &n }}, time.Now()) // no rollout report
+ if err := status.WriteBox(context.Background(), tb.fx.rel, b); err != nil {
+ t.Fatal(err)
+ }
+ sweep(t, tb.fx.rel, status.Label("box-b"), map[string]metrics.UnitSample{
+ "carlos-exec@" + remoteHost: {CPUFrac: p(0.66), MemBytes: pi64(7 << 20)},
+ })
+ row := instanceRow(t, tb.page(t, "/apps/shop/instances"), remoteHost)
+ if strings.Contains(row, "v3") || strings.Contains(row, "66%") || !strings.Contains(row, "Can&#39;t tell right now") {
+ t.Fatalf("Running row joined an unidentified report: %s", row)
+ }
+ for path, bad := range map[string][]string{
+ "/apps/shop": {"9.0 KB", "66%", "DNS &amp; certs OK"},
+ "/apps/shop/instances/" + remoteHost: {"www.shop-store.example", "renews 2027-01-15", "66%"},
+ "/apps/shop/settings/domains": {"renews 2027-01-15"},
+ } {
+ body := tb.page(t, path)
+ for _, b := range bad {
+ if strings.Contains(body, b) {
+ t.Fatalf("%s shows %q from a report with no tenant identity:\n%s", path, b, body)
+ }
+ }
+ }
+}
+
+// Round 2's held-down fix, completed: a metrics sample from before the
+// failure must not count the instance as reporting.
+func TestRemoteHeldDownWithSampleIsNotAllGood(t *testing.T) {
+ tb := newTwoBoxes(t)
+ tb.create(t, tb.token, tb.sqid, "shop", remoteHost, "uk", "")
+ tb.reconcile(t, "v3")
+ heldReport(t, tb, func(hr *status.HostRollout) {
+ hr.Attempt, hr.AttemptBuild, hr.HeldBy, hr.Reason = status.AttemptDown, "v4", "v4", status.ReasonExit
+ })
+ sweep(t, tb.fx.rel, status.Label("box-b"), map[string]metrics.UnitSample{
+ "carlos-exec@" + remoteHost: {CPUFrac: p(0.27), MemBytes: pi64(3 << 20)},
+ })
+ if ov := tb.page(t, "/apps/shop"); strings.Contains(ov, "All good") || !strings.Contains(ov, "Needs attention") {
+ t.Fatalf("overview for a held-down instance with a reading:\n%s", ov)
+ }
+}
+
+// ageRecords backdates every instance and sidecar record of the app past
+// the settle window, as if nothing had changed for a while.
+func ageRecords(t *testing.T, tb *twoBoxes) {
+ t.Helper()
+ root := tb.fx.rel.(*deletableStore).root
+ old := time.Now().Add(-channelSettle - time.Minute)
+ for _, prefix := range []string{provision.RecordsPrefix(tb.sqid, "shop"), provision.SidecarsPrefix(tb.sqid, "shop")} {
+ keys, err := tb.fx.rel.List(context.Background(), prefix)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, k := range keys {
+ if err := os.Chtimes(filepath.Join(root, k), old, old); err != nil {
+ t.Fatal(err)
+ }
+ }
+ }
+}
+
+// retireRC posts the confirmed retire of canary/rc and returns the page it
+// lands on.
+func retireRC(t *testing.T, tb *twoBoxes) string {
+ t.Helper()
+ status, loc, body := postForm(t, tb.browser, tb.fx.ts.URL+"/a/"+tb.sqid+"/apps/shop/canary/retire",
+ url.Values{"csrf": {sessionToken(t, tb.fx, tb.browser)}, "name": {"rc"}, "confirmed": {"1"}})
+ if status != http.StatusSeeOther {
+ t.Fatalf("retire = %d %s", status, body)
+ }
+ _, _, page := get(t, tb.browser, tb.fx.ts.URL+loc)
+ return page
+}
+
+func rcPointer(t *testing.T, tb *twoBoxes) bool {
+ t.Helper()
+ _, _, err := tb.fx.rel.Get(context.Background(), release.ChannelKey(tb.sqid, "shop", "canary/rc"))
+ return err == nil
+}
+
+const notSettled = "Could not verify no hosts follow this channel — try again."
+
+// P2 #2-#4 (one rule): a remote follower is moved off canary/rc and its box
+// has not reconciled (B paused). No record names rc, but a record changed
+// within the window, so the retire is refused, whatever B's report says.
+// Once the app has been still for the window it goes through.
+func TestRetireWaitsAfterChannelChange(t *testing.T) {
+ tb := newTwoBoxes(t)
+ shipAndPromote(t, tb.fx, tb.sqid, "shop", "v4", "canary/rc")
+ shipAndPromote(t, tb.fx, tb.sqid, "shop", "v5", "canary/next")
+ tb.create(t, tb.token, tb.sqid, "shop", remoteHost, "uk", "canary/rc")
+ tb.reconcile(t, "v4")
+ if status, _, out := rawReq(t, http.MethodPost, instancesURL(tb.fx, tb.sqid, "shop")+"/"+remoteHost+"/channel", tb.token,
+ `{"channel":"canary/next"}`); status != http.StatusOK {
+ t.Fatalf("channel move = %d %s", status, out)
+ }
+ // B reports the host on canary/next's build even though it has not
+ // reconciled: a build is no proof of a channel any more.
+ if err := tb.regB.SetVersions(remoteHost, "v5", "v4"); err != nil {
+ t.Fatal(err)
+ }
+ report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096)
+ tb.fx.srv.boxReports.expire()
+ if page := retireRC(t, tb); !strings.Contains(page, notSettled) || !rcPointer(t, tb) {
+ t.Fatalf("retire right after a channel change was not refused:\n%s", page)
+ }
+ ageRecords(t, tb)
+ if page := retireRC(t, tb); !strings.Contains(page, "Retired canary rc") {
+ t.Fatalf("retire once the app was still for the window:\n%s", page)
+ }
+}
+
+// P2 #3: a recently changed record of a host on the console's own box
+// counts too; a local route does not short-circuit a remote copy.
+func TestRetireWaitsAfterLocalHostChange(t *testing.T) {
+ tb := newTwoBoxes(t)
+ shipAndPromote(t, tb.fx, tb.sqid, "shop", "v4", "canary/rc")
+ shipAndPromote(t, tb.fx, tb.sqid, "shop", "v5", "canary/next")
+ tb.create(t, tb.token, tb.sqid, "shop", localHost, "ie", "canary/rc")
+ tb.reconcile(t, "v4")
+ if status, _, out := rawReq(t, http.MethodPost, instancesURL(tb.fx, tb.sqid, "shop")+"/"+localHost+"/channel", tb.token,
+ `{"channel":"canary/next"}`); status != http.StatusOK {
+ t.Fatalf("channel move = %d %s", status, out)
+ }
+ tb.reconcile(t, "") // the console's box converges; another copy may not have
+ report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096)
+ tb.fx.srv.boxReports.expire()
+ if page := retireRC(t, tb); !strings.Contains(page, notSettled) || !rcPointer(t, tb) {
+ t.Fatalf("retire right after a local host's channel change was not refused:\n%s", page)
+ }
+}
+
+// P2 #5: the only remote follower's record is deleted, and its box has not
+// reconciled the deletion. Through the delete door, the audit log dates the
+// deletion; behind the console's back (a direct bucket delete), the box's
+// report still serving a host no record names holds the retire, until the
+// box drops the route.
+func TestRetireWaitsAfterDeletion(t *testing.T) {
+ tb := newTwoBoxes(t)
+ shipAndPromote(t, tb.fx, tb.sqid, "shop", "v4", "canary/rc")
+ tb.create(t, tb.token, tb.sqid, "shop", remoteHost, "uk", "canary/rc")
+ tb.reconcile(t, "v4")
+ report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096)
+ if status, _, out := rawReq(t, http.MethodDelete, instancesURL(tb.fx, tb.sqid, "shop")+"/"+remoteHost, tb.token, ""); status != http.StatusOK {
+ t.Fatalf("delete = %d %s", status, out)
+ }
+ tb.fx.srv.boxReports.expire()
+ hosts, err := tb.fx.srv.channelHosts(context.Background(), tb.sqid, "shop", "canary/rc")
+ if !errorsIsUnsettled(err) || len(hosts) != 0 {
+ t.Fatalf("after a delete through the door = %v %v, want unsettled", hosts, err)
+ }
+ if !strings.Contains(err.Error(), "deleted") {
+ t.Fatalf("unsettled for the wrong reason: %v", err)
+ }
+}
+
+func TestRetireWaitsForRouteOfDeletedRecord(t *testing.T) {
+ tb := newTwoBoxes(t)
+ shipAndPromote(t, tb.fx, tb.sqid, "shop", "v4", "canary/rc")
+ tb.create(t, tb.token, tb.sqid, "shop", remoteHost, "uk", "canary/rc")
+ tb.reconcile(t, "v4")
+ report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096)
+ // Deleted behind the console's back: no audit row.
+ if err := tb.fx.rel.Delete(context.Background(), provision.RecordKey(tb.sqid, "shop", remoteHost)); err != nil {
+ t.Fatal(err)
+ }
+ tb.fx.srv.boxReports.expire()
+ if page := retireRC(t, tb); !strings.Contains(page, notSettled) || !rcPointer(t, tb) {
+ t.Fatalf("retire while box B still serves the deleted record's host:\n%s", page)
+ }
+ tb.reconcile(t, "") // B drops the route
+ report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096)
+ tb.fx.srv.boxReports.expire()
+ if page := retireRC(t, tb); !strings.Contains(page, "Retired canary rc") {
+ t.Fatalf("retire once B dropped the route:\n%s", page)
+ }
+}
+
+// P2 #2: a box report that cannot be read refuses the retire.
+func TestRetireRefusedOnIncompleteReports(t *testing.T) {
+ tb := newTwoBoxes(t)
+ shipAndPromote(t, tb.fx, tb.sqid, "shop", "v4", "canary/rc")
+ tb.create(t, tb.token, tb.sqid, "shop", remoteHost, "uk", "stable")
+ tb.reconcile(t, "v3")
+ report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096)
+ ageRecords(t, tb)
+ if _, err := tb.fx.rel.Put(context.Background(), "status/boxes/broken.json", []byte("{not json"), ""); err != nil {
+ t.Fatal(err)
+ }
+ tb.fx.srv.boxReports.expire()
+ if page := retireRC(t, tb); !strings.Contains(page, notSettled) || !rcPointer(t, tb) {
+ t.Fatalf("retire with an unreadable box report:\n%s", page)
+ }
+ if err := tb.fx.rel.Delete(context.Background(), "status/boxes/broken.json"); err != nil {
+ t.Fatal(err)
+ }
+ tb.fx.srv.boxReports.expire()
+ if page := retireRC(t, tb); !strings.Contains(page, "Retired canary rc") {
+ t.Fatalf("retire with every report read and a still app:\n%s", page)
+ }
+}
+
+// A record missing from the modification-time listing (deleted since it
+// was read) is not settled.
+func TestRetireRefusedOnRecordWithoutModTime(t *testing.T) {
+ tb := newTwoBoxes(t)
+ ds := tb.fx.rel.(*deletableStore)
+ tb.create(t, tb.token, tb.sqid, "shop", remoteHost, "uk", "stable")
+ tb.reconcile(t, "v3")
+ report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096)
+ ageRecords(t, tb)
+ tb.fx.srv.boxReports.expire()
+ if _, err := tb.fx.srv.channelHosts(context.Background(), tb.sqid, "shop", "canary/rc"); err != nil {
+ t.Fatalf("fixture: a still app = %v", err)
+ }
+ tb.fx.srv.cfg.Releases = listModHiding{ds, provision.RecordKey(tb.sqid, "shop", remoteHost)}
+ if _, err := tb.fx.srv.channelHosts(context.Background(), tb.sqid, "shop", "canary/rc"); !errorsIsUnsettled(err) {
+ t.Fatalf("a record missing from the modification-time listing = %v, want unsettled", err)
+ }
+}
+
+func errorsIsUnsettled(err error) bool { return errors.Is(err, errRetireUnsettled) }
diff --git a/internal/console/remoteinstances_test.go b/internal/console/remoteinstances_test.go
index 196ac5f04..899c712d7 100644
--- a/internal/console/remoteinstances_test.go
+++ b/internal/console/remoteinstances_test.go
@@ -439,8 +439,10 @@ func TestRemoteReportNamingAnotherTenant(t *testing.T) {
if rep := f.pick("h.example.com", "other", "shop"); rep == nil || rep.version != "v7" || !rep.awake {
t.Fatalf("the named tenant's own report = %+v", rep)
}
- rv, dv := remoteRoute(provision.Record{Host: "h.example.com", App: "shop", Account: "mine"}, f.pick("h.example.com", "mine", "shop"), true, "mine", DNSTargets{})
- if rv.Version != "" || rv.dbBytes != nil || rv.boxAwake || rv.Status != "pending" || dv.TLS != "" || dv.Guidance != "" {
+ rv, dv := remoteRoute(provision.Record{Host: "h.example.com", App: "shop", Account: "mine"}, f.pick("h.example.com", "mine", "shop"), f, "mine", DNSTargets{})
+ // The host is served (by someone else), so it is not "not minted
+ // anywhere" either: unknown, with nothing joined.
+ if rv.Version != "" || rv.dbBytes != nil || rv.boxAwake || rv.Status != "" || !rv.unknown || dv.TLS != "" || dv.Guidance != "" {
t.Fatalf("row from a refused report = %+v %+v", rv, dv)
}
}
@@ -453,13 +455,13 @@ func TestRemoteReportStaleAndMoving(t *testing.T) {
stale := status.Box{GeneratedAt: now.Add(-time.Hour), Label: "old", Metrics: &status.BoxMetrics{
RouteVersions: map[string]string{"h.example.com": "v1"}}}
f := foldFleetReports([]status.Box{stale}, true, now)
- rv, _ := remoteRoute(provision.Record{Host: "h.example.com", App: "shop", Account: "a"}, f.pick("h.example.com", "a", "shop"), f.complete, "a", DNSTargets{})
+ rv, _ := remoteRoute(provision.Record{Host: "h.example.com", App: "shop", Account: "a"}, f.pick("h.example.com", "a", "shop"), f, "a", DNSTargets{})
if rv.Version != "" || rv.Status != "pending" {
t.Fatalf("a stale report was joined: %+v", rv)
}
// Incomplete read: not "Setting up", and the overview can't tell.
f = foldFleetReports([]status.Box{stale}, false, now)
- rv, dv := remoteRoute(provision.Record{Host: "h.example.com", App: "shop", Account: "a"}, f.pick("h.example.com", "a", "shop"), f.complete, "a", DNSTargets{})
+ rv, dv := remoteRoute(provision.Record{Host: "h.example.com", App: "shop", Account: "a"}, f.pick("h.example.com", "a", "shop"), f, "a", DNSTargets{})
if rv.Status != "" {
t.Fatalf("an incomplete read vouched for absence: %+v", rv)
}
@@ -560,20 +562,9 @@ func TestChannelHostsCountsRemoteFollowers(t *testing.T) {
if err != nil || len(hosts) != 1 || hosts[0] != remoteHost {
t.Fatalf("canary/rc followers = %v %v, want [%s]", hosts, err, remoteHost)
}
- // The remote record was written seconds ago and no report of its box
- // shows it on its own channel's build yet, so it may have been moved
- // off stable: a possible follower until it settles (unsettledFollowers).
- hosts, err = tb.fx.srv.channelHosts(context.Background(), tb.sqid, "shop", "stable")
- if err != nil || strings.Join(hosts, ",") != localHost+","+remoteHost {
- t.Fatalf("stable followers = %v %v, want the local follower and the unsettled remote record", hosts, err)
- }
- old := time.Now().Add(-channelSettle - time.Minute)
- if err := os.Chtimes(filepath.Join(tb.fx.rel.(*deletableStore).root, provision.RecordKey(tb.sqid, "shop", remoteHost)), old, old); err != nil {
- t.Fatal(err)
- }
hosts, err = tb.fx.srv.channelHosts(context.Background(), tb.sqid, "shop", "stable")
if err != nil || len(hosts) != 1 || hosts[0] != localHost {
- t.Fatalf("stable followers once settled = %v %v, want [%s] once", hosts, err, localHost)
+ t.Fatalf("stable followers = %v %v, want [%s] once", hosts, err, localHost)
}
// A sidecar following a canary from another region counts too.
if err := provision.PutSidecarManifest(context.Background(), tb.fx.rel, tb.sqid, "shop", provision.SidecarManifest{
diff --git a/internal/console/server.go b/internal/console/server.go
index bbde1cf43..dc3c82b99 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -5152,32 +5152,35 @@ func (s *Server) handleFastTrack(w http.ResponseWriter, r *http.Request) {
// name becomes a channel path segment and an on-box state file name.
var canaryNameRe = regexp.MustCompile(`^[a-z][a-z0-9-]{0,31}$`)
-// channelSettle is how long after an instance or sidecar record last changed
-// the canary-retire guard keeps treating it as a possible follower of the
-// channel being retired, unless its box's report shows it already on its
-// new channel's build.
+// channelSettle is how long after any instance or sidecar record of an app
+// was created, changed or deleted the canary-retire guard refuses to call
+// a channel unfollowed (retireUnsettled). Boxes converge record changes
+// within seconds of the serial bump; a box that has not done so in three
+// status snapshot periods is one the fleet's own staleness rule
+// (status.BoxStale) already treats as dark. Paul accepted the wait.
const channelSettle = 15 * time.Minute
// channelHosts lists the hosts that follow app's channel, and reports
-// whether that could be checked at all. Two sources, because a follower can
-// live on any box:
+// whether that could be checked at all. The followers are every route in
+// the console box's registry of an app by this NAME (any account:
+// over-counting here only ever refuses a retire) and every instance and
+// sidecar record of acct/app that names the channel, read strictly and live
+// (not through the record view: a record written without its change-index
+// bump is missing from a snapshot until the backstop, and this is the one
+// reader whose "nobody" deletes something). A follower whose route is on
+// another box is in no registry this console can see, so without the
+// records a canary followed only from another region would read as
+// unfollowed.
//
-// - the console box's registry: every route of an app by this NAME (any
-// account: over-counting here only ever refuses a retire), as before;
-// - acct/app's instance and sidecar records in the bucket, read strictly
-// and live (not through the record view: a record written without its
-// change-index bump is missing from a snapshot until the backstop, and
-// this is the one reader whose "nobody" deletes something). A follower
-// whose route is on another box is in no registry this console can see,
-// so without the records a canary followed only from another region
-// would read as unfollowed, be retired, and strand that host.
+// With no follower, the answer is still only "nobody" when the app has
+// settled (retireUnsettled): a box may still be running a host on the
+// channel after its record moved off it or was deleted, and box reports do
+// not carry a host's channel. Otherwise the error is errRetireUnsettled.
//
-// The two call sites treat the error differently: handleNewCanary's use is
+// The two call sites treat errors differently: handleNewCanary's use is
// cosmetic (which URL to show in a success flash) and downgrades an error to
// "no hosts", but handleRetireCanary's use is load-bearing, a canary with
-// followers must never be deleted, so it fails CLOSED: an unreadable
-// registry, a failed listing, a record that will not read or parse, or more
-// records than the cap is an error, never "nobody follows this channel".
+// followers must never be deleted, so it fails CLOSED on every error.
func (s *Server) channelHosts(ctx context.Context, acct, app, channel string) ([]string, error) {
reg, err := openRegistry(s.cfg.Registry)
if err != nil {
@@ -5189,7 +5192,6 @@ func (s *Server) channelHosts(ctx context.Context, acct, app, channel string) ([
}
var out []string
seen := map[string]bool{}
- local := make(map[string]bool, len(routes))
add := func(host string) {
if !seen[host] {
seen[host] = true
@@ -5197,7 +5199,6 @@ func (s *Server) channelHosts(ctx context.Context, acct, app, channel string) ([
}
}
for _, rt := range routes {
- local[rt.Host] = true
if rt.App == app && rt.Channel == channel {
add(rt.Host)
}
@@ -5214,18 +5215,16 @@ func (s *Server) channelHosts(ctx context.Context, acct, app, channel string) ([
if len(unreadable) > 0 {
return nil, fmt.Errorf("instance records of %s/%s: %d will not read", acct, app, len(unreadable))
}
- // Records on another channel now may have been moved off this one
- // moments ago, with their box not converged yet (unsettledFollowers).
- others := map[string]settleCandidate{}
+ // keys is every record this app has now, instance and sidecar, by its
+ // bucket key, and hosts every host they name: retireUnsettled weighs
+ // both against the modification times and the box reports.
+ keys := map[string]bool{}
+ hosts := map[string]bool{}
for _, rec := range recs {
+ keys[provision.RecordKey(acct, app, rec.Host)] = true
+ hosts[rec.Host] = true
if rec.Channel == channel {
add(rec.Host)
- continue
- }
- if !local[rec.Host] {
- // A host with a row here has its channel read off that row
- // above; only a host on another box needs the settle rule.
- others[provision.RecordKey(acct, app, rec.Host)] = settleCandidate{host: rec.Host, channel: rec.Channel}
}
}
// Sidecar records are read here rather than through
@@ -5234,11 +5233,11 @@ func (s *Server) channelHosts(ctx context.Context, acct, app, channel string) ([
// still running until its box converges, so a listed record that will
// not read, for any reason, refuses the retire too.
prefix := provision.SidecarsPrefix(acct, app)
- keys, err := s.cfg.Releases.List(ctx, prefix)
+ sideKeys, err := s.cfg.Releases.List(ctx, prefix)
if err != nil {
return nil, fmt.Errorf("sidecar records of %s/%s: %w", acct, app, err)
}
- for _, key := range keys {
+ for _, key := range sideKeys {
rest, ok := strings.CutPrefix(key, prefix)
if !ok || rest == "" || strings.Contains(rest, "/") {
continue
@@ -5251,22 +5250,19 @@ func (s *Server) channelHosts(ctx context.Context, acct, app, channel string) ([
if err != nil {
return nil, fmt.Errorf("sidecar record %s: %w", key, err)
}
+ keys[key] = true
+ hosts[rec.Host] = true
if rec.Channel == channel {
add(rec.Host)
- continue
- }
- if !local[rec.Host] {
- others[key] = settleCandidate{host: rec.Host, channel: rec.Channel}
}
}
- unsettled, err := s.unsettledFollowers(ctx, acct, app, channel, others)
- if err != nil {
- return nil, err
+ if len(out) > 0 {
+ return out, nil
}
- for _, host := range unsettled {
- add(host)
+ if err := s.retireUnsettled(ctx, acct, app, keys, hosts); err != nil {
+ return nil, err
}
- return out, nil
+ return nil, nil
}
// handleNewCanary creates a canary: a brand-new canary/<name> channel
@@ -5457,6 +5453,14 @@ func (s *Server) handleRetireCanary(w http.ResponseWriter, r *http.Request) {
checkCtx, cancelCheck := context.WithTimeout(r.Context(), 15*time.Second)
hosts, err := s.channelHosts(checkCtx, acct.Sqid, app, channel)
cancelCheck()
+ if errors.Is(err, errRetireUnsettled) {
+ // Nobody follows the channel by any record, but the app changed too
+ // recently (or a box still serves a host with no record) for that
+ // to be the whole story yet.
+ log.Printf("console: retire %s %s: %v", app, channel, err)
+ back("err", "Could not verify no hosts follow this channel — try again.")
+ return
+ }
if err != nil {
log.Printf("console: retire %s %s: check followers: %v", app, channel, err)
s.renderMessage(w, r, http.StatusInternalServerError, "Error",
diff --git a/internal/console/templates/app_overview.html b/internal/console/templates/app_overview.html
index 05508285b..3654ded31 100644
--- a/internal/console/templates/app_overview.html
+++ b/internal/console/templates/app_overview.html
@@ -49,7 +49,7 @@
<a class="tile" href="{{$.Nav}}/apps/{{$.AppName}}/settings/domains">
<h2>Web addresses</h2>
<p class="tile-value">{{.DomainTotal}}</p>
- <p class="tile-detail">{{if eq .DomainTotal 0}}one appears after your first deploy{{else if .DomainAttention}}<span class="error">{{.DomainAttention}} need{{if eq .DomainAttention 1}}s{{end}} attention</span>{{else}}DNS &amp; certs OK{{end}}</p>
+ <p class="tile-detail">{{if eq .DomainTotal 0}}one appears after your first deploy{{else if .DomainAttention}}<span class="error">{{.DomainAttention}} need{{if eq .DomainAttention 1}}s{{end}} attention</span>{{else if .DomainUnknown}}no data right now{{else}}DNS &amp; certs OK{{end}}</p>
</a>
<a class="tile" href="{{$.Nav}}/apps/{{$.AppName}}/releases">
<h2>{{$.DeploymentsCopy.History}}</h2>
diff --git a/internal/console/view.go b/internal/console/view.go
index 0bb6ae27f..ade7e342f 100644
--- a/internal/console/view.go
+++ b/internal/console/view.go
@@ -725,7 +725,7 @@ func addRemoteRows(remote *remoteRows, acct, app string, localHosts map[string]b
}
continue
}
- rv, dv := remoteRoute(rec, remote.reports.pick(rec.Host, acct, app), remote.reports.complete, acct, dns)
+ rv, dv := remoteRoute(rec, remote.reports.pick(rec.Host, acct, app), remote.reports, acct, dns)
routes = append(routes, rv)
domains = append(domains, dv)
added = true
diff --git a/internal/provision/console_remote_instances_census_test.go b/internal/provision/console_remote_instances_census_test.go
index 16cd38429..34492136d 100644
--- a/internal/provision/console_remote_instances_census_test.go
+++ b/internal/provision/console_remote_instances_census_test.go
@@ -17,12 +17,12 @@ package provision
// GetSidecarRecord, refusing on any read error, to count followers on
// other boxes; it reads, never writes: key-site, like
// Server.checkSidecars.
-// - Round 2 review: Server.channelHosts also builds RecordKey for the
-// app's records on other boxes, to match them against their listed
-// modification times; Server.unsettledFollowers is new and lists
-// RecordsPrefix and SidecarsPrefix with modification times (ListMod)
-// and reads channel pointers and box reports. Neither writes anything:
-// key-site.
+// - Round 3 review: Server.channelHosts builds RecordKey for each of the
+// app's records, to match them against their listed modification
+// times; Server.retireUnsettled (replacing round 2's
+// unsettledFollowers) lists RecordsPrefix and SidecarsPrefix with
+// modification times (ListMod) and reads the console audit log and the
+// box reports. Neither writes anything: key-site.
// - Server.pageRecords is new (round 1 review): the app pages' record
// reader. It lists RecordsPrefix for the viewed account's app and reads
// each record not already a local row with GetRecord, through the
@@ -32,8 +32,8 @@ func consoleRemoteInstancesWriteCensusInventory() []censusEntry {
entries := append([]censusEntry(nil), edgeRateLimitWriteCensusInventory()...)
replacements := []censusEntry{
{"internal/console/instancepage.go", "Server.handleAppInstance", "key-site", "lit:instances", "07f5c01659b0d453d5996abb6a6e9493f74c7df97e3cddfe0f765b6f316de4a7"},
- {"internal/console/server.go", "Server.channelHosts", "key-site", "key:RecordKey,key:SidecarsPrefix", "56baa86331ca8e5e19b7a765bcca5fbd9250319a4eaf25b1ee4d71c5bca0fbed"},
- {"internal/console/remoteinstances.go", "Server.unsettledFollowers", "key-site", "key:RecordsPrefix,key:SidecarsPrefix", "70b3ee51e7810e0f180a99ed9c7de463ca418d80881b2abe102858d85902be77"},
+ {"internal/console/server.go", "Server.channelHosts", "key-site", "key:RecordKey,key:SidecarsPrefix", "966e1fb668d3910ccb102845f1c5c91a1aa2cfa857bbf0ca11d850945259c682"},
+ {"internal/console/remoteinstances.go", "Server.retireUnsettled", "key-site", "key:RecordsPrefix,key:SidecarsPrefix", "622db1c4651b4a4ce4d5eef89e2734982db7ea61fe6a7ad4129b364ee30fb071"},
{"internal/console/remoteinstances.go", "Server.pageRecords", "key-site", "key:RecordsPrefix", "b03ec08af6e2eedc5b2fa269751b5fa3465c2e728c93a6c97964ebabb15362a4"},
}
for _, r := range replacements {
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index cfa9c1c2a..d05f3ef16 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -23,4 +23,4 @@ plan14-root-reads-plans-4a-store.tsv 72dc835c04caf5b2b49cc6ecbfd865bb3123b997ee9
plan14-root-reads-plans-4-notices-grace.tsv 43e430a3b3edf9333bfe2c64f24ca9e4c04475dc45ae4983d4e8bcab6a9c0bc4
plan14-root-reads-design-edge-rate-limit-358-decisions.tsv a067dcd9e32e6be2b7dd9c6a8256d1252ac4c737fd058c430823e382add340c4
plan14-root-reads-design-edge-rate-limit-358.tsv 0c4eabfe38e12b098285bdeb5ceb0b16e5333928f5b02e160a6b16b5fd9ce1e0
-plan14-root-reads-console-remote-instances.tsv 6fc23039029e8ec93637ea4ac7b5718e0add91c4c4595e54ce42621dc1d35ba6
+plan14-root-reads-console-remote-instances.tsv 660d053abfe5f3136aaa853f325bb638bda1221f243b6a75c57978b739b51aae
diff --git a/internal/provision/testdata/plan14-root-reads-console-remote-instances.tsv b/internal/provision/testdata/plan14-root-reads-console-remote-instances.tsv
index 3fc49122d..dc7989785 100644
--- a/internal/provision/testdata/plan14-root-reads-console-remote-instances.tsv
+++ b/internal/provision/testdata/plan14-root-reads-console-remote-instances.tsv
@@ -1,23 +1,23 @@
# Census overlay console-remote-instances, written by census-propose (#369). census-ruling-console-remote-instances, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-console-remote-instances.md.
-# 7 body, 3 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 8 body, 2 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
@legacy d0a3ae6c1eb6795c3810264874e4f1363432cbdd3aae6398e30422c7169a3726 internal/console/accountfleet.go Server.assembleAccountFleet legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Fleet tab: the shared-fleet app count also reads the account's own instance records (per app of the account, under its own prefix, region not a fleet placement); the registry read is unchanged. registry:Account@2350,registry:Account@4421,registry:App@2476,registry:Name@4814,registry:Region@2437,whole:Fleet@4006,whole:Fleet@4408,whole:Fleet@4522,whole:Route@2335 1b5ecf4066d067d721683d273e768d834df0bb9cb3cf5ff90648b1e6842bacc8
@legacy ab2c0cc1b9d16b0522527bc6b8cbf9927f78d0621057469bbc98bccd254fb40e internal/console/apiinstances.go Server.healthByHost legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Takes an awake set, a box pin per host and an ownership start per host from the caller (readings only from that box and only from samples at or after the start, via ownerAppMetricsFrom); registry reads unchanged. registry:Backing@1253,registry:Hibernate@1175,registry:Kind@1158,registry:Provisioned@1228,registry:Status@1035,registry:Unit@1244,registry:Unit@381,registry:Unit@416,whole:Route@1012,whole:Route@229,whole:Route@272,whole:Route@338 b6d1d75b2228a97cba475d87730c7cae3f48774ed973083dff0ef798263e613d
@legacy a7ae52378a61d71162c98d6bfe643f3090fab3eb6bbb5ceb4092516fb7b59912 internal/console/apiroutes.go Server.handleAPIRoutes legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Passes nil for healthByHost's new awake, box-pin and ownership-start arguments; nothing else. registry:Account@4614,registry:App@1646,registry:App@2114,registry:App@4553,registry:Backing@2274,registry:Canary@2412,registry:Channel@2134,registry:Environment@2159,registry:Hibernate@2233,registry:Host@1730,registry:Host@2056,registry:Host@2212,registry:Host@2368,registry:Host@4686,registry:Host@4766,registry:Kind@2071,registry:Platform@2397,registry:Prefix@4782,registry:Provisioned@2299,registry:Replication@2331,registry:Status@2183,registry:Target@4800,registry:Unit@2253,whole:Route@1635,whole:Route@1684,whole:Route@1721,whole:Route@1741,whole:Route@1861,whole:Route@1973,whole:Route@2004,whole:Route@2104,whole:Route@4677,whole:RoutePath@3619 2b37acd8b5b5ddf6dcebaac0588bf44ed750b9fad749eb8cc46bd69875d774a4
@legacy 68455015fbe9d2db598f2616aa59f01bda880869dbee9d7b61b65506624f6e42 internal/console/instancepage.go Server.handleAppInstance legacy accepted-legacy accepted-legacy;rev3=merge-ruling-2;basis=Instance page adds updates view from rollout join; browser rendering remains legacy.;rev3=census-ruling-console-remote-instances;basis=A remote row (no local registry row) takes its aliases from its box report; local rows read ListAliases as before. file:Query@2672,registry:Account@2444,registry:Alias@2544,registry:App@2474,registry:Host@2422,whole:RouteAlias@2405 07f5c01659b0d453d5996abb6a6e9493f74c7df97e3cddfe0f765b6f316de4a7
@legacy aa852aec334f46af0b4bb16f7f81afa3d4690f0f12c6c80b2ab5cff4837367aa internal/console/metricsview.go buildUnitRows legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-console-remote-instances;basis=Each unit row also keeps its raw per-sample readings (float32 CPU, int64 memory) so an owner's graph can be redrawn from only their samples; reads nothing new. file:ReadBytes@315,file:ReadBytes@327 e7f942ea8d32626b6ead3313deec26c458a7d7c296e7120c7384dfc5f416c378
-@legacy 6942f141db3bdd170160d0f7fbb9416bdf417ee5944c3becfb580b1646f52064 internal/console/templates/app_overview.html external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-console-remote-instances;basis=Running tile: does not claim Served when a static route's state is unknown, and reads the existing 'no data right now' when every instance's state is unknown; display only. file:external@0 e853a6756a7b2fc841ccb7d290f39e8bda12d3869f4b215531004126ab49efe7
-@legacy dd950cb96d11e4f21b83d9e4b1f590f2bbee9bb9c3bc7d27974a085fcee3bda9 internal/console/apiinstances.go Server.instanceHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Records with no local registry row get health only from a box report naming the record's own account and app (held down: Failed; transient or no tenant: Can't tell right now), readings pinned to that box and bounded by each record's created_at. Builds registry.Route literals from the record; reads no registry for them. registry:Account@1987,registry:Account@2007,registry:App@1948,registry:App@1964,registry:Host@839,registry:Unit@2117,registry:Unit@2159,whole:Route@1151,whole:Route@2054,whole:Route@2075,whole:Route@2854,whole:Route@3654,whole:Route@4134,whole:Route@4187,whole:Route@4302,whole:Route@792,whole:Route@821,whole:Route@832,whole:Route@850 e69364d7fdaa2f8606a32c5587b4f31293695dba9d920ae75246556b8d281941
-@legacy 2ee564cdf6efed16dd08b8f3763e0ccd6cf2ebd5bd446394db6d0bd729541e56 internal/console/server.go Server.channelHosts legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Canary-retire guard also counts the account's instance records (ListRecordsStrict) and sidecar records (listed, then each read with GetSidecarRecord; any read error refuses), and records on other boxes that changed within channelSettle (or have no modification time) unless their box report shows the new channel's build, or whose box report still shows the retiring channel's build at any age (unsettledFollowers); it notes which hosts have a local registry row (rt.Host) so only remote hosts are candidates. Fails closed, including on an unreadable retiring pointer. registry:App@493,registry:Channel@510,registry:Host@472,registry:Host@541,whole:Route@324,whole:Route@455 56baa86331ca8e5e19b7a765bcca5fbd9250319a4eaf25b1ee4d71c5bca0fbed
-@legacy d0891ad263e0efcbdd5b9c670366ba3c31e676d0838ce99f61221e8872c327e6 internal/console/view.go Assemble legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Collects the set of local registry hosts (rt.Host) so a record host the registry has gets no remote row (its record's created_at bounds the local row's metrics history); adds rows from the account's records and box reports when given a remote source. registry:App@1716,registry:App@1739,registry:App@2117,registry:App@2147,registry:Backing@2017,registry:Caps@1385,registry:Channel@960,registry:Environment@1942,registry:Hibernate@1859,registry:Host@1768,registry:Host@861,registry:Kind@1783,registry:Platform@1889,registry:Provisioned@2042,registry:Status@1800,registry:Unit@1999,registry:Version@1823,whole:Route@2092,whole:Route@2167,whole:Route@810,whole:Route@839,whole:Route@910 120ae8c042523f872fd1c19357b8bb830e4afe9da1e38ad202df2ada3ad52ada
+@legacy 6366e141d2beaefbc50930cded49314ca0242bfef8403f80351ccbdeeab8908f internal/console/server.go Server.channelHosts legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Canary-retire guard also counts the account's instance records (ListRecordsStrict) and sidecar records (listed, then each read with GetSidecarRecord; any read error refuses) naming the channel; with none, it refuses unless the app has settled (retireUnsettled: no record created, changed or deleted within channelSettle, every box report read, no box serving a host of the app that no record names). The registry read is as on main. Fails closed. registry:App@424,registry:Channel@441,registry:Host@472,whole:Route@410 966e1fb668d3910ccb102845f1c5c91a1aa2cfa857bbf0ca11d850945259c682
+@legacy 9c63018a0c60a52c55b2ef0159bc58cbf0f191e0166a53adf58feff954c6935e internal/console/templates/app_overview.html external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-console-remote-instances;basis=Running tile does not claim Served when a route's state is unknown and reads the existing 'no data right now' when every instance's state is unknown; Web addresses tile reads 'no data right now' instead of 'DNS & certs OK' for a domain with no reading; display only. file:external@0 2a112ff768c300894881b858e61465841c87810ca7cb1d98a0fe2a54155a0ca1
+@legacy 73dedec8e8eba8cad40da63a9dcd22d01688bcc8d89f8f5b2fd8f7080f04d46f internal/console/apiinstances.go Server.instanceHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Records with no local registry row get health only from a box report naming the record's own account and app (held down: Failed; transient, unidentified or unread: Can't tell right now), readings pinned to that box and bounded by each record's created_at. Builds registry.Route literals from the record; reads no registry for them. registry:Account@1987,registry:Account@2007,registry:App@1948,registry:App@1964,registry:Host@839,registry:Unit@2117,registry:Unit@2159,whole:Route@1151,whole:Route@2054,whole:Route@2075,whole:Route@2854,whole:Route@3646,whole:Route@4126,whole:Route@4179,whole:Route@4294,whole:Route@792,whole:Route@821,whole:Route@832,whole:Route@850 f2b042a95c77b07f0bcd1c11f099769a7ad3c1a230c521af71c6bf5cb7685897
+@legacy c4f85bcfbab5b09688918bfefae1eff1b8bf54e2659428cf33c2d4bafc9729ab internal/console/view.go Assemble legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Collects the set of local registry hosts (rt.Host) so a record host the registry has gets no remote row (its record's created_at bounds the local row's metrics history); adds rows from the account's records and tenant-named box reports when given a remote source. registry:App@1716,registry:App@1739,registry:App@2117,registry:App@2147,registry:Backing@2017,registry:Caps@1385,registry:Channel@960,registry:Environment@1942,registry:Hibernate@1859,registry:Host@1768,registry:Host@861,registry:Kind@1783,registry:Platform@1889,registry:Provisioned@2042,registry:Status@1800,registry:Unit@1999,registry:Version@1823,whole:Route@2092,whole:Route@2167,whole:Route@810,whole:Route@839,whole:Route@910 120ae8c042523f872fd1c19357b8bb830e4afe9da1e38ad202df2ada3ad52ada
internal/console/accountfleet.go Server.assembleAccountFleet legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Fleet tab: the shared-fleet app count also reads the account's own instance records (per app of the account, under its own prefix, region not a fleet placement); the registry read is unchanged. registry:Account@2350,registry:Account@4421,registry:App@2476,registry:Name@4814,registry:Region@2437,whole:Fleet@4006,whole:Fleet@4408,whole:Fleet@4522,whole:Route@2335 1b5ecf4066d067d721683d273e768d834df0bb9cb3cf5ff90648b1e6842bacc8
internal/console/apiinstances.go Server.healthByHost legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Takes an awake set, a box pin per host and an ownership start per host from the caller (readings only from that box and only from samples at or after the start, via ownerAppMetricsFrom); registry reads unchanged. registry:Backing@1253,registry:Hibernate@1175,registry:Kind@1158,registry:Provisioned@1228,registry:Status@1035,registry:Unit@1244,registry:Unit@381,registry:Unit@416,whole:Route@1012,whole:Route@229,whole:Route@272,whole:Route@338 b6d1d75b2228a97cba475d87730c7cae3f48774ed973083dff0ef798263e613d
internal/console/apiroutes.go Server.handleAPIRoutes legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Passes nil for healthByHost's new awake, box-pin and ownership-start arguments; nothing else. registry:Account@4614,registry:App@1646,registry:App@2114,registry:App@4553,registry:Backing@2274,registry:Canary@2412,registry:Channel@2134,registry:Environment@2159,registry:Hibernate@2233,registry:Host@1730,registry:Host@2056,registry:Host@2212,registry:Host@2368,registry:Host@4686,registry:Host@4766,registry:Kind@2071,registry:Platform@2397,registry:Prefix@4782,registry:Provisioned@2299,registry:Replication@2331,registry:Status@2183,registry:Target@4800,registry:Unit@2253,whole:Route@1635,whole:Route@1684,whole:Route@1721,whole:Route@1741,whole:Route@1861,whole:Route@1973,whole:Route@2004,whole:Route@2104,whole:Route@4677,whole:RoutePath@3619 2b37acd8b5b5ddf6dcebaac0588bf44ed750b9fad749eb8cc46bd69875d774a4
internal/console/instancepage.go Server.handleAppInstance legacy accepted-legacy accepted-legacy;rev3=merge-ruling-2;basis=Instance page adds updates view from rollout join; browser rendering remains legacy.;rev3=census-ruling-console-remote-instances;basis=A remote row (no local registry row) takes its aliases from its box report; local rows read ListAliases as before. file:Query@2672,registry:Account@2444,registry:Alias@2544,registry:App@2474,registry:Host@2422,whole:RouteAlias@2405 07f5c01659b0d453d5996abb6a6e9493f74c7df97e3cddfe0f765b6f316de4a7
internal/console/metricsview.go buildUnitRows legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-console-remote-instances;basis=Each unit row also keeps its raw per-sample readings (float32 CPU, int64 memory) so an owner's graph can be redrawn from only their samples; reads nothing new. file:ReadBytes@315,file:ReadBytes@327 e7f942ea8d32626b6ead3313deec26c458a7d7c296e7120c7384dfc5f416c378
internal/console/metricsview.go type UnitRow diagnostic H3 schema-only;rev3=census-ruling-console-remote-instances;basis=Two unexported fields carrying those raw per-sample readings; schema only. file:ReadBytes@133 db66030c5353fee88e0826786a424e0fee88d3191004deff380d00086bef5d62
-internal/console/templates/app_overview.html external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-console-remote-instances;basis=Running tile: does not claim Served when a static route's state is unknown, and reads the existing 'no data right now' when every instance's state is unknown; display only. file:external@0 e853a6756a7b2fc841ccb7d290f39e8bda12d3869f4b215531004126ab49efe7
-internal/console/apiinstances.go Server.instanceHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Records with no local registry row get health only from a box report naming the record's own account and app (held down: Failed; transient or no tenant: Can't tell right now), readings pinned to that box and bounded by each record's created_at. Builds registry.Route literals from the record; reads no registry for them. registry:Account@1987,registry:Account@2007,registry:App@1948,registry:App@1964,registry:Host@839,registry:Unit@2117,registry:Unit@2159,whole:Route@1151,whole:Route@2054,whole:Route@2075,whole:Route@2854,whole:Route@3654,whole:Route@4134,whole:Route@4187,whole:Route@4302,whole:Route@792,whole:Route@821,whole:Route@832,whole:Route@850 e69364d7fdaa2f8606a32c5587b4f31293695dba9d920ae75246556b8d281941
-internal/console/server.go Server.channelHosts legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Canary-retire guard also counts the account's instance records (ListRecordsStrict) and sidecar records (listed, then each read with GetSidecarRecord; any read error refuses), and records on other boxes that changed within channelSettle (or have no modification time) unless their box report shows the new channel's build, or whose box report still shows the retiring channel's build at any age (unsettledFollowers); it notes which hosts have a local registry row (rt.Host) so only remote hosts are candidates. Fails closed, including on an unreadable retiring pointer. registry:App@493,registry:Channel@510,registry:Host@472,registry:Host@541,whole:Route@324,whole:Route@455 56baa86331ca8e5e19b7a765bcca5fbd9250319a4eaf25b1ee4d71c5bca0fbed
-internal/console/view.go Assemble legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Collects the set of local registry hosts (rt.Host) so a record host the registry has gets no remote row (its record's created_at bounds the local row's metrics history); adds rows from the account's records and box reports when given a remote source. registry:App@1716,registry:App@1739,registry:App@2117,registry:App@2147,registry:Backing@2017,registry:Caps@1385,registry:Channel@960,registry:Environment@1942,registry:Hibernate@1859,registry:Host@1768,registry:Host@861,registry:Kind@1783,registry:Platform@1889,registry:Provisioned@2042,registry:Status@1800,registry:Unit@1999,registry:Version@1823,whole:Route@2092,whole:Route@2167,whole:Route@810,whole:Route@839,whole:Route@910 120ae8c042523f872fd1c19357b8bb830e4afe9da1e38ad202df2ada3ad52ada
-@coverage internal/console 591c443ab2c56397233812d1f8f987efe934b603c1701ba8fc682e76b8bb8378
-@coverage internal/console/templates d953013575663fbd275b663ac3d9b46e99eb830b223b9e545ddec7580468d5db
+internal/console/server.go Server.channelHosts legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Canary-retire guard also counts the account's instance records (ListRecordsStrict) and sidecar records (listed, then each read with GetSidecarRecord; any read error refuses) naming the channel; with none, it refuses unless the app has settled (retireUnsettled: no record created, changed or deleted within channelSettle, every box report read, no box serving a host of the app that no record names). The registry read is as on main. Fails closed. registry:App@424,registry:Channel@441,registry:Host@472,whole:Route@410 966e1fb668d3910ccb102845f1c5c91a1aa2cfa857bbf0ca11d850945259c682
+internal/console/templates/app_overview.html external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-console-remote-instances;basis=Running tile does not claim Served when a route's state is unknown and reads the existing 'no data right now' when every instance's state is unknown; Web addresses tile reads 'no data right now' instead of 'DNS & certs OK' for a domain with no reading; display only. file:external@0 2a112ff768c300894881b858e61465841c87810ca7cb1d98a0fe2a54155a0ca1
+internal/console/apiinstances.go Server.instanceHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Records with no local registry row get health only from a box report naming the record's own account and app (held down: Failed; transient, unidentified or unread: Can't tell right now), readings pinned to that box and bounded by each record's created_at. Builds registry.Route literals from the record; reads no registry for them. registry:Account@1987,registry:Account@2007,registry:App@1948,registry:App@1964,registry:Host@839,registry:Unit@2117,registry:Unit@2159,whole:Route@1151,whole:Route@2054,whole:Route@2075,whole:Route@2854,whole:Route@3646,whole:Route@4126,whole:Route@4179,whole:Route@4294,whole:Route@792,whole:Route@821,whole:Route@832,whole:Route@850 f2b042a95c77b07f0bcd1c11f099769a7ad3c1a230c521af71c6bf5cb7685897
+internal/console/view.go Assemble legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Collects the set of local registry hosts (rt.Host) so a record host the registry has gets no remote row (its record's created_at bounds the local row's metrics history); adds rows from the account's records and tenant-named box reports when given a remote source. registry:App@1716,registry:App@1739,registry:App@2117,registry:App@2147,registry:Backing@2017,registry:Caps@1385,registry:Channel@960,registry:Environment@1942,registry:Hibernate@1859,registry:Host@1768,registry:Host@861,registry:Kind@1783,registry:Platform@1889,registry:Provisioned@2042,registry:Status@1800,registry:Unit@1999,registry:Version@1823,whole:Route@2092,whole:Route@2167,whole:Route@810,whole:Route@839,whole:Route@910 120ae8c042523f872fd1c19357b8bb830e4afe9da1e38ad202df2ada3ad52ada
+@coverage internal/console 09ddeb704f9055eb14c84f59d57e871521a4e90df7c8f2ee9d2c8205c0b971b5
+@coverage internal/console/templates 6e272e30e00be5785b3f364a947ea4ab86b2d96a0e8d21821b7812c45f0a636f