console remote instances: round 5, shrink (Astra, 59c2cd61)
By the coordinator's ruling, remove paths instead of patching them: 1. One accessor. Every page, API answer and check gets remote facts through remoteFacts(acct, app) (appFacts: host, complete, seen, unrecorded); nothing else folds or reads box reports for a remote host, and TestRemoteFactsOneAccessor parses the package to hold that. The instance page of a remote host runs none of the hostname-keyed box joins (layout, rollout, updates): closes the Unavailable-rollout leak. 2. The round 4 edges-file identity path is removed (edgesOwners, fromEdges, claims, live record confirmation). Identity is the record plus a rollout entry naming the same account and app, generated after the record's creation; anything else is unknown. Static sites and never-sleeping instances show the record's facts and "Can't tell right now". 3. Retire inventory: records, the console box's routes, and the box reports' hosts of the app; an incomplete read or a host of the app no record names refuses. Tests fail first on 59c2cd61; 8 mutants, 7 killed, 1 equivalent. Census re-proposed (approval classes only); record-write digests for handleAppInstance and retireUnsettled.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
14 files changed,
+341
−449
docs/superpowers/notes/census-proposal-console-remote-instances.md+4 −4docs/superpowers/notes/console-remote-instances.md+29 −0internal/console/apiinstances.go+7 −14internal/console/instancepage.go+9 −6internal/console/remoteinstances.go+120 −250internal/console/remoteinstances_round1_test.go+1 −1internal/console/remoteinstances_round2_test.go+1 −1internal/console/remoteinstances_round4_test.go+15 −118internal/console/remoteinstances_round5_test.go+118 −0internal/console/remoteinstances_test.go+22 −36internal/console/view.go+2 −7internal/provision/console_remote_instances_census_test.go+5 −4internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-console-remote-instances.tsv+7 −7
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 48d0fef01..1628ea2f9 100644 |
| --- a/docs/superpowers/notes/census-proposal-console-remote-instances.md |
| +++ b/docs/superpowers/notes/census-proposal-console-remote-instances.md |
| @@ -8,13 +8,13 @@ Ruling `census-ruling-console-remote-instances`. Every change below keeps the di |
| | `internal/console/apiinstances.go` `Server.healthByHost` | body | unchanged (12) | Takes an awake set, a box pin per host and an ownership window per host (since, until) from the caller: readings only from that box and only from samples inside the window, via ownerAppMetricsFrom; registry reads unchanged. | |
| | `internal/console/apiroutes.go` `Server.handleAPIRoutes` | body | unchanged (33) | Passes nil for healthByHost's new awake, box-pin and ownership-window arguments; nothing else. | |
| | `internal/console/claim_retire.go` `Server.retireClaimHostRecord` | body | unchanged (1) | Notes the app in the console's in-memory deletion log (noteRecordDeletion, which also invalidates the pages' held box reports) before retiring a record, for the canary-retire guard; the retire itself is unchanged. | |
| -| `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/instancepage.go` `Server.handleAppInstance` | body | unchanged (6) | A remote row (no local registry row) runs none of the hostname-keyed box joins (layout, rollout, updates): it shows only what its row brought through remoteFacts, aliases included. Local rows read layout, rollout join and 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/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). 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 (rollout entry or edges-file owner) naming the record's own account and app and generated after the record existed (held down: Failed; transient, unidentified or unread: Can't tell right now), readings pinned to that box and bounded by the record's created_at and the report's observation. 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. | |
| +| `internal/console/apiinstances.go` `Server.instanceHealth` | sites | +whole:Route ×4 | Records with no local registry row get health only from remoteFacts: a box report whose rollout entry names the record's own account and app, generated after the record was created (held down: Failed; transient, unidentified or unread: Can't tell right now), readings pinned to that box and bounded by the record's created_at and the report's generation. 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 remoteFacts when given a remote source. | |
| Envelopes re-pinned: `internal/console`, `internal/console/templates`. |
| @@ -34,6 +34,6 @@ Recorded dispositions, which each change must still satisfy: |
| - `internal/console/apiinstances.go` `Server.instanceHealth`: 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` → `91381ac20a7c806cdb36e7362850c6a45a196501e5768cbceef73fc3c0153102`. |
| +Seal: `0c4eabfe38e12b098285bdeb5ceb0b16e5333928f5b02e160a6b16b5fd9ce1e0` → `99d2ccf52f30915b0b7c7af61013a6046ddb03f165271dd3f2fe43d6c6bbc5f1`. |
| 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 0f0fe3bf7..627e15792 100644 |
| --- a/docs/superpowers/notes/console-remote-instances.md |
| +++ b/docs/superpowers/notes/console-remote-instances.md |
| @@ -350,3 +350,32 @@ Request budget change: the cached load also lists and reads |
| `control/edges/` (1 LIST plus 1 GET per box), at most once a minute |
| console-wide. |
| +## Round 5 review (Astra, 59c2cd61): shrink, by ruling |
| + |
| +Each round's P1 had come from the previous round's new path, so the |
| +coordinator ruled to remove paths rather than patch them. |
| + |
| +1. **One accessor.** Every page, API answer and check learns remote facts |
| + through `remoteFacts(acct, app)` (`appFacts`): `host(record)` is the one |
| + report that may be joined to a record, and `complete`, `seen` and |
| + `unrecorded` answer the rest. Nothing else folds or reads box reports |
| + for a remote host. `TestRemoteFactsOneAccessor` parses the package and |
| + fails on any other caller. The instance page of a remote host runs none |
| + of the hostname-keyed box joins (layout, rollout, updates), whose tenant |
| + rules are weaker; it shows what the row brought. |
| +2. **The edges-file identity path from round 4 is gone.** Identity is the |
| + record plus a box report entry (rollout) naming the same account and |
| + app, generated after the record's creation. Anything else is unknown. |
| + Static sites and instances that never sleep, which the rollout report |
| + does not cover, show the record's facts and "Can't tell right now" for |
| + live state. Their metadata (version, size, domains) does not join. |
| +3. **Retire inventory.** The records, the console box's routes, and the |
| + box reports' hosts of the app (by their rollout entries). Any unreadable |
| + or incomplete source refuses, and a box report naming a host of the app |
| + that no record names refuses. |
| + |
| +The round 4 notes above about the edges file, edges-only identities, |
| +`fromEdges` and live record confirmation describe code that no longer |
| +exists. The budget line for `control/edges/` is void: the cached load |
| +reads `status/boxes/` only, as before round 4. |
| + |
diff --git a/internal/console/apiinstances.go b/internal/console/apiinstances.go| index 35cb2db1b..31eb3efa0 100644 |
| --- a/internal/console/apiinstances.go |
| +++ b/internal/console/apiinstances.go |
| @@ -293,18 +293,18 @@ func (s *Server) instanceHealth(ctx context.Context, recs []provision.Record) ma |
| boxByHost := map[string]string{} |
| untilByHost := map[string]time.Time{} |
| if s.cfg.Releases != nil { |
| - var reports fleetReports |
| + var facts appFacts |
| loaded := false |
| for _, rec := range recs { |
| if _, local := byHost[rec.Host]; local { |
| continue |
| } |
| if !loaded { |
| - reports, loaded = foldFleet(s.pageFleet(ctx), time.Now()), true |
| + facts, loaded = s.remoteFacts(ctx, rec.Account, rec.App), true |
| } |
| - rep := reports.pick(rec.Host, rec.Account, rec.App, rec.CreatedAt) |
| + rep := facts.host(rec) |
| if rep == nil { |
| - if _, fleetPlaced := registry.FleetPlacement(rec.Region); reports.seen(rec.Host) || !reports.complete || fleetPlaced { |
| + if _, fleetPlaced := registry.FleetPlacement(rec.Region); facts.seen(rec.Host) || !facts.complete() || fleetPlaced { |
| out[rec.Host] = healthUnknown |
| } |
| continue |
| @@ -313,12 +313,8 @@ func (s *Server) instanceHealth(ctx context.Context, recs []provision.Record) ma |
| if kind == "" { |
| kind = "instance" |
| } |
| - // recs were read live a moment ago (ListRecordsComplete), which |
| - // is the confirmation an undated edges-file identity needs. |
| - if rep.transient || (rep.fromEdges && kind != "static") { |
| - // Starting or stopping on its box, or identified by the edges |
| - // file alone (whose readings cannot be dated to this owner): |
| - // not asleep, not up. |
| + if rep.transient { |
| + // Starting or stopping on its box: not asleep, not up. |
| out[rec.Host] = healthUnknown |
| continue |
| } |
| @@ -331,10 +327,7 @@ func (s *Server) instanceHealth(ctx context.Context, recs []provision.Record) ma |
| routeFor[rec.Host] = registry.Route{Host: rec.Host, Kind: kind, Status: status, |
| Hibernate: rec.HibernateOrDefault(), Provisioned: true} |
| boxByHost[rec.Host] = rep.box |
| - untilByHost[rec.Host] = rep.obsAt |
| - if rep.fromEdges { |
| - untilByHost[rec.Host] = time.Time{} // no readings |
| - } |
| + untilByHost[rec.Host] = rep.at |
| if rep.awake { |
| if awake == nil { |
| awake = map[string]bool{} |
diff --git a/internal/console/instancepage.go b/internal/console/instancepage.go| index 0a6fceda7..fa8f2e543 100644 |
| --- a/internal/console/instancepage.go |
| +++ b/internal/console/instancepage.go |
| @@ -281,7 +281,14 @@ func (s *Server) handleAppInstance(w http.ResponseWriter, r *http.Request) { |
| // error both leave the approved unknown text already set above, the |
| // same soft-degrade the alias lookup just below gives a broken registry. |
| detail.App, detail.Channel = p.AppName, selected.Channel |
| - if s.cfg.Releases != nil { |
| + if selected.remote { |
| + // An instance on another box: everything the page shows about it |
| + // came through remoteFacts when its row was built. The box joins |
| + // below (layout, rollout, updates) read reports by hostname with |
| + // their own, weaker tenant rules, so none of them runs for it; the |
| + // page shows the unknown layout and no rollout or updates section. |
| + detail.Aliases = append(detail.Aliases, selected.aliases...) |
| + } else if s.cfg.Releases != nil { |
| if boxes, _, err := s.systemBoxes(r.Context(), false); err == nil { |
| detail.Layout = layoutWordFor(boxes, host) |
| } |
| @@ -294,11 +301,7 @@ func (s *Server) handleAppInstance(w http.ResponseWriter, r *http.Request) { |
| // the Installed and Serving facts above come from one reading. |
| detail.Updates = s.updatesPage(r.Context(), acct, p.AppName, host, detail, join.update(host, acct.Sqid, p.AppName), p.Role == RoleOwner) |
| } |
| - if selected.remote { |
| - // An instance on another box: its custom domains are that box's |
| - // alias rows, from the one report the row joined (remoteinstances.go). |
| - detail.Aliases = append(detail.Aliases, selected.aliases...) |
| - } else if reg, err := openRegistry(s.cfg.Registry); err == nil { |
| + if reg, err := openRegistry(s.cfg.Registry); err == nil && !selected.remote { |
| if aliases, err := reg.ListAliases(); err == nil { |
| for _, alias := range aliases { |
| if alias.Host == host && alias.Account == acct.Sqid && alias.App == p.AppName { |
diff --git a/internal/console/remoteinstances.go b/internal/console/remoteinstances.go| index 4fb7d813e..0abbcac9c 100644 |
| --- a/internal/console/remoteinstances.go |
| +++ b/internal/console/remoteinstances.go |
| @@ -26,7 +26,6 @@ package console |
| import ( |
| "context" |
| - "encoding/json" |
| "errors" |
| "fmt" |
| "log" |
| @@ -62,9 +61,6 @@ type boxReportCache struct { |
| failed bool // the held read failed or was incomplete: boxReportFailTTL |
| boxes []status.Box |
| complete bool |
| - // owners is every box's edges file's word on who owns each host it |
| - // serves: box label -> host -> {account, app}, read with the reports. |
| - owners map[string]map[string][2]string |
| // gen counts invalidations: a load that began before one publishes its |
| // result to its own caller but does not hold it for later views. |
| gen uint64 |
| @@ -80,6 +76,16 @@ func (c *boxReportCache) clock() time.Time { |
| return time.Now() |
| } |
| +// invalidate drops the held read, so the next page view reads afresh. Every |
| +// console path that deletes a record calls it (noteRecordDeletion): a held |
| +// read may still name the deleted record's tenant for its host. |
| +func (c *boxReportCache) invalidate() { |
| + c.mu.Lock() |
| + defer c.mu.Unlock() |
| + c.valid = false |
| + c.gen++ |
| +} |
| + |
| // pageBoxReports returns every box's report, from the cache when it is |
| // young enough, and whether the read saw every box (status.LoadBoxesComplete). |
| // |
| @@ -93,35 +99,8 @@ func (c *boxReportCache) clock() time.Time { |
| // then gets whatever the cache held before, reported incomplete. The |
| // snapshots are shared and must not be changed. |
| func (s *Server) pageBoxReports(ctx context.Context) ([]status.Box, bool) { |
| - r := s.pageFleet(ctx) |
| - return r.boxes, r.complete |
| -} |
| - |
| -// fleetRead is one console-wide read: every box's status report, whether |
| -// all were read, every box's edges-file owners, and when the read finished |
| -// (the console's observation time for the owners). |
| -type fleetRead struct { |
| - boxes []status.Box |
| - complete bool |
| - owners map[string]map[string][2]string |
| - at time.Time |
| -} |
| - |
| -// invalidate drops the held read, so the next page view reads afresh. Every |
| -// console path that deletes a record calls it (noteRecordDeletion): a held |
| -// read may still name the deleted record's tenant for its host. |
| -func (c *boxReportCache) invalidate() { |
| - c.mu.Lock() |
| - defer c.mu.Unlock() |
| - c.valid = false |
| - c.gen++ |
| -} |
| - |
| -// pageFleet is pageBoxReports with the edges-file owners and the read's |
| -// time. |
| -func (s *Server) pageFleet(ctx context.Context) fleetRead { |
| if s.cfg.Releases == nil { |
| - return fleetRead{} |
| + return nil, false |
| } |
| c := &s.boxReports |
| for { |
| @@ -131,18 +110,18 @@ func (s *Server) pageFleet(ctx context.Context) fleetRead { |
| ttl = boxReportFailTTL |
| } |
| if c.valid && c.clock().Sub(c.at) < ttl { |
| - r := fleetRead{boxes: c.boxes, complete: c.complete, owners: c.owners, at: c.at} |
| + boxes, complete := c.boxes, c.complete |
| c.mu.Unlock() |
| - return r |
| + return boxes, complete |
| } |
| if wait := c.loading; wait != nil { |
| - held := fleetRead{boxes: c.boxes, owners: c.owners, at: c.at} |
| + held := c.boxes |
| c.mu.Unlock() |
| select { |
| case <-wait: |
| continue |
| case <-ctx.Done(): |
| - return held |
| + return held, false |
| } |
| } |
| done := make(chan struct{}) |
| @@ -152,59 +131,24 @@ func (s *Server) pageFleet(ctx context.Context) fleetRead { |
| loadCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), instanceStoreTimeout) |
| boxes, complete, err := status.LoadBoxesComplete(loadCtx, s.cfg.Releases) |
| + cancel() |
| if err != nil { |
| log.Printf("console: box reports for the app pages: %v", err) |
| boxes, complete = nil, false |
| } |
| - owners := edgesOwners(loadCtx, s.cfg.Releases) |
| - cancel() |
| c.mu.Lock() |
| - c.at, c.valid, c.failed, c.boxes, c.complete, c.owners = c.clock(), c.gen == gen, err != nil || !complete, boxes, complete, owners |
| - r := fleetRead{boxes: boxes, complete: complete, owners: owners, at: c.at} |
| + c.at, c.valid, c.failed, c.boxes, c.complete = c.clock(), c.gen == gen, err != nil || !complete, boxes, complete |
| c.loading = nil |
| close(done) |
| c.mu.Unlock() |
| - return r |
| - } |
| -} |
| - |
| -// edgesOwners reads every box's edges file (control/edges/<box>.json) and |
| -// returns, per box label, the account and app it publishes for each host it |
| -// serves. A box publishes them only when every route behind the hostname |
| -// agrees (internal/host's servedOwners), so a host split between apps, or |
| -// one in a file the console cannot read, has no owner here. Unlike the |
| -// rollout report, the edges file covers every route kind: static sites and |
| -// instances that never sleep included. Best effort: a failed read is no |
| -// owners, and the hosts it would have named stay unidentified. |
| -func edgesOwners(ctx context.Context, store release.Store) map[string]map[string][2]string { |
| - snap, err := readEdgesSnapshot(ctx, store) |
| - if err != nil { |
| - log.Printf("console: edges files for the app pages: %v", err) |
| - return nil |
| - } |
| - out := map[string]map[string][2]string{} |
| - for _, f := range snap.Files { |
| - for host, raw := range f.Hosts { |
| - var h struct { |
| - Account string `json:"account"` |
| - App string `json:"app"` |
| - } |
| - if json.Unmarshal(raw, &h) != nil || h.Account == "" || h.App == "" { |
| - continue |
| - } |
| - if out[f.Box] == nil { |
| - out[f.Box] = map[string][2]string{} |
| - } |
| - out[f.Box][host] = [2]string{h.Account, h.App} |
| - } |
| + return boxes, complete |
| } |
| - return out |
| } |
| // hostReport is one fresh box's word about one host it serves. |
| type hostReport struct { |
| box string |
| - at time.Time |
| + at time.Time // the report's generation |
| // version is the box's registry Version for the host (RouteVersions), |
| // the same column a local row's Version reads. |
| version string |
| @@ -214,34 +158,16 @@ type hostReport struct { |
| reading *status.AliasReading |
| // aliases are the custom domains this box routes to the host. |
| aliases []string |
| - // tenantKnown is whether the box names the host's account and app: its |
| - // rollout report does for the hosts the rollout manages, its edges file |
| - // for every route kind. obsAt is when that identity was observed: the |
| - // report's generation for a rollout entry, the console's read for an |
| - // edges-file entry (rewritten by the box on every change). awake is only |
| - // meaningful from a rollout entry. Two sources naming different tenants |
| - // give no identity at all. |
| - tenantKnown bool |
| - account, app string |
| - obsAt time.Time |
| - // fromEdges marks an identity taken from the edges file alone. The box |
| - // rewrites that file only when something changes, and publishes it |
| - // independently of its report, so nothing dates when it last held: such |
| - // a host joins the report's version, size, domains and status, never |
| - // metrics readings, and an instance's health stays unknown. |
| - fromEdges bool |
| - // claims is every tenant either source names for the host, agreeing |
| - // or not: the canary-retire guard's evidence of a possible follower. |
| - claims [][2]string |
| - awake bool |
| - // down is a failed hold-mode build that left the host with nothing |
| - // serving it (status.AttemptDown): its wakes are refused. transient is |
| - // a process mid-start or mid-stop: neither awake nor asleep. |
| + // tenantKnown is whether the box's rollout report names the host's |
| + // account and app, the only identity a report can carry for a host; |
| + // awake, down and transient are that entry's process state. |
| + tenantKnown bool |
| + account, app string |
| + awake bool |
| down, transient bool |
| } |
| -// fleetReports is every fresh box's word about every host, folded once per |
| -// page view from the cached reports. |
| +// fleetReports is every fresh box's word about every host. |
| type fleetReports struct { |
| byHost map[string][]hostReport |
| // complete is whether every box's report was read. Only a complete read |
| @@ -249,18 +175,11 @@ type fleetReports struct { |
| complete bool |
| } |
| -// foldFleetReports folds the box reports a page has into per-host reports. |
| -// Stale boxes are left out under the fleet's one staleness rule |
| -// (status.BoxStale), as every other box join does. |
| +// foldFleetReports folds box reports into per-host reports. Stale boxes are |
| +// left out under the fleet's one staleness rule (status.BoxStale), as every |
| +// other box join does. Only remoteFacts calls it. |
| func foldFleetReports(boxes []status.Box, complete bool, now time.Time) fleetReports { |
| - return foldFleet(fleetRead{boxes: boxes, complete: complete, at: now}, now) |
| -} |
| - |
| -// foldFleet is foldFleetReports over a whole read, edges-file owners |
| -// included. |
| -func foldFleet(read fleetRead, now time.Time) fleetReports { |
| - boxes := read.boxes |
| - f := fleetReports{byHost: map[string][]hostReport{}, complete: read.complete} |
| + f := fleetReports{byHost: map[string][]hostReport{}, complete: complete} |
| for _, b := range boxes { |
| m := b.Metrics |
| if m == nil || status.BoxStale(b, now, status.SnapshotPeriod) { |
| @@ -287,7 +206,7 @@ func foldFleet(read fleetRead, now time.Time) fleetReports { |
| if m.Rollout != nil { |
| for host, hr := range m.Rollout.Hosts { |
| r := get(host) |
| - r.tenantKnown, r.account, r.app, r.obsAt = hr.Account != "" && hr.App != "", hr.Account, hr.App, b.GeneratedAt |
| + r.tenantKnown, r.account, r.app = hr.Account != "" && hr.App != "", hr.Account, hr.App |
| r.awake = hr.Awake && !hr.Transient |
| r.down = hr.Attempt == status.AttemptDown |
| r.transient = hr.Transient |
| @@ -304,36 +223,6 @@ func foldFleet(read fleetRead, now time.Time) fleetReports { |
| r.aliases = append(r.aliases, name) |
| } |
| } |
| - // The edges file names owners for every route kind. It identifies a |
| - // host the rollout does not manage; where both speak, they must |
| - // agree, or the host has no identity to join. Either source's word is |
| - // kept (claims) for the canary-retire guard, which must count a |
| - // possible follower whatever the other source says. |
| - // |
| - // An edges-file identity is dated by this box's report, not by the |
| - // console's read: the box rewrites its edges file when a host |
| - // changes hands, and the report generated alongside is the latest |
| - // moment the console knows the box still said this owner. |
| - for host, r := range reps { |
| - if r.tenantKnown { |
| - r.claims = append(r.claims, [2]string{r.account, r.app}) |
| - } |
| - o, ok := read.owners[b.Label][host] |
| - if ok { |
| - r.claims = append(r.claims, o) |
| - } |
| - switch { |
| - case !ok: |
| - case !r.tenantKnown && r.account == "" && r.app == "": |
| - r.tenantKnown, r.account, r.app, r.obsAt, r.fromEdges = true, o[0], o[1], b.GeneratedAt, true |
| - // A rollout entry that named no tenant cannot be attributed: |
| - // its process state is not this owner's to show. |
| - r.down, r.transient, r.awake = false, false, false |
| - case r.account != o[0] || r.app != o[1]: |
| - r.tenantKnown = false |
| - r.account, r.app = "conflict", "conflict" |
| - } |
| - } |
| for host, r := range reps { |
| sort.Strings(r.aliases) |
| f.byHost[host] = append(f.byHost[host], *r) |
| @@ -342,103 +231,113 @@ func foldFleet(read fleetRead, now time.Time) fleetReports { |
| return f |
| } |
| -// pick is the one box report a remote row of acct/app joins for host, or |
| -// 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. |
| -// |
| -// since is the record's created_at: a report the box generated before the |
| -// record existed is about some earlier owner of the hostname, never this |
| -// one. Zero accepts any time (callers with no record). |
| -func (f fleetReports) pick(host, acct, app string, since time.Time) *hostReport { |
| +// appFacts is what the console may say about acct/app's instances on other |
| +// boxes, from one read of the box reports. remoteFacts builds it, and every |
| +// page, API answer and check that shows or decides anything about a remote |
| +// host goes through it: nothing else folds or picks box reports for a |
| +// remote host (TestRemoteFactsOneAccessor holds the package to that). |
| +type appFacts struct { |
| + acct, app string |
| + reports fleetReports |
| +} |
| + |
| +// remoteFacts is the one accessor for remote facts about acct/app. |
| +func (s *Server) remoteFacts(ctx context.Context, acct, app string) appFacts { |
| + boxes, complete := s.pageBoxReports(ctx) |
| + return appFacts{acct: acct, app: app, reports: foldFleetReports(boxes, complete, time.Now())} |
| +} |
| + |
| +// host is the one box report about rec's host that may be joined to it, or |
| +// nil. Identity is the record plus a report entry naming the same account |
| +// and app, generated after the record was created: a report naming another |
| +// tenant may predate the host changing hands, one naming no tenant could be |
| +// anyone's, and one generated before the record existed is about an earlier |
| +// owner of the hostname. Anything else is unknown, and contributes nothing: |
| +// not a version, a size, a domain, a state or a reading. Among the reports |
| +// that qualify the freshest wins, then the lower box label, so the choice is |
| +// stable; two boxes reporting one host is a move in flight. |
| +func (f appFacts) host(rec provision.Record) *hostReport { |
| + if rec.Account != f.acct || rec.App != f.app { |
| + return nil |
| + } |
| var best *hostReport |
| - for i := range f.byHost[host] { |
| - r := &f.byHost[host][i] |
| - if !r.tenantKnown || r.account != acct || r.app != app || r.at.Before(since) { |
| + for i := range f.reports.byHost[rec.Host] { |
| + r := &f.reports.byHost[rec.Host][i] |
| + if !r.tenantKnown || r.account != f.acct || r.app != f.app || !r.at.After(rec.CreatedAt) { |
| continue |
| } |
| - if best == nil || betterReport(r, best) { |
| + if best == nil || r.at.After(best.at) || (r.at.Equal(best.at) && r.box < best.box) { |
| best = r |
| } |
| } |
| return best |
| } |
| -// tenantReports is every fresh report of host whose rollout names acct and |
| -// app: the evidence a safety check weighs, all of it, where pick chooses one |
| -// report to show. |
| -func (f fleetReports) tenantReports(host, acct, app string) []hostReport { |
| - var out []hostReport |
| - for _, r := range f.byHost[host] { |
| - if r.tenantKnown && r.account == acct && r.app == app { |
| - out = append(out, r) |
| - } |
| - } |
| - return out |
| -} |
| +// complete is whether every box's report was read. |
| +func (f appFacts) complete() bool { return f.reports.complete } |
| -// 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 } |
| +// 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 nothing about it can be joined. |
| +func (f appFacts) seen(host string) bool { return len(f.reports.byHost[host]) > 0 } |
| -func betterReport(a, b *hostReport) bool { |
| - if a.tenantKnown != b.tenantKnown { |
| - return a.tenantKnown |
| +// unrecorded is a host a fresh box report names as this app's (by its |
| +// rollout entry) that no record names, and the box reporting it. |
| +func (f appFacts) unrecorded(recorded map[string]bool) (host, box string, ok bool) { |
| + hosts := make([]string, 0, len(f.reports.byHost)) |
| + for h := range f.reports.byHost { |
| + hosts = append(hosts, h) |
| } |
| - if !a.at.Equal(b.at) { |
| - return a.at.After(b.at) |
| + sort.Strings(hosts) |
| + for _, h := range hosts { |
| + if recorded[h] { |
| + continue |
| + } |
| + for _, r := range f.reports.byHost[h] { |
| + if r.tenantKnown && r.account == f.acct && r.app == f.app { |
| + return h, r.box, true |
| + } |
| + } |
| } |
| - return a.box < b.box |
| + return "", "", false |
| } |
| // remoteRows is what Assemble needs to add the account's instances on other |
| -// boxes: a record reader already scoped to the viewed account, and the |
| -// folded box reports. |
| +// boxes: a record reader and the remote facts, both scoped to the viewed |
| +// account. |
| type remoteRows struct { |
| - // confirm reports whether acct/app's record for host still exists, read |
| - // live from the bucket, with the given created_at. An identity from the |
| - // edges file alone is undated; a record that exists now, unchanged |
| - // since the report's generation, is what proves no successor can hold |
| - // the hostname, so such a join waits on it. nil confirms nothing. |
| - confirm func(app, host string, created time.Time) bool |
| // records reads app's records, skipping hosts in skip (the console |
| // box's registry hosts, which keep their local rows) without reading |
| // them. |
| records func(app string, skip map[string]bool) ([]provision.Record, error) |
| - reports fleetReports |
| + facts func(app string) appFacts |
| } |
| // remoteRoute folds one record that has no row in the console box's registry |
| -// into a RouteView and its parallel DomainView. |
| +// into a RouteView and its parallel DomainView, with rep the report |
| +// appFacts.host accepted for it (or nil). |
| // |
| -// Status: "ready" when a fresh box reports the host; "pending" (Setting up) |
| -// when every box was read and none does, which is a record whose route has |
| -// not been minted anywhere; "" otherwise. A record placed on a customer |
| -// fleet is never "pending": fleet boxes report elsewhere, so the platform's |
| -// reports cannot vouch for its absence. |
| +// Status: "ready" when an accepted report names the host; "pending" (Setting |
| +// up) when every box was read and none reports the host at all, which is a |
| +// record whose route has not been minted anywhere; "" otherwise. A record |
| +// placed on a customer fleet is never "pending": fleet boxes report |
| +// elsewhere, so the platform's reports cannot vouch for its absence. |
| // |
| -// unknown: the row's process state is known only from a report whose |
| -// rollout names this account and app (tenantKnown). Without one (no report |
| -// and nothing vouches for absence, or an older box's report that names no |
| -// tenant), the row says "Can't tell right now" rather than guessing Asleep, |
| -// Not responding or Serving. |
| +// unknown: with no accepted report, the row shows the record's facts and |
| +// says "Can't tell right now" for its live state, rather than guessing |
| +// Asleep, Not responding or Serving. That includes static sites and |
| +// instances that never sleep, which the rollout report does not cover. |
| // |
| -// metricsBox: readings join a remote row only from the box whose report |
| -// was accepted for it AND names this tenant. Any other box's samples of the |
| -// host (a box serving it for another account, a stale twin) are not this |
| -// row's. "" means the row joins no readings at all. |
| +// metricsBox and until: readings join a remote row only from the box whose |
| +// report was accepted, and only up to that report's generation (a later |
| +// sample may be a successor tenant's). "" joins no readings at all. |
| // |
| // Unit and Caps are deliberately empty. Unit feeds the metrics allowlist |
| // (appResourceMetrics), and the metrics boundary for a remote row is the |
| // 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, f fleetReports, acct string, dns DNSTargets) (RouteView, DomainView) { |
| +func remoteRoute(rec provision.Record, rep *hostReport, f appFacts, acct string, dns DNSTargets) (RouteView, DomainView) { |
| kind := rec.Kind |
| if kind == "" { |
| kind = "instance" |
| @@ -466,29 +365,21 @@ func remoteRoute(rec provision.Record, rep *hostReport, f fleetReports, acct str |
| switch { |
| case rep != nil: |
| rv.Status = "ready" |
| - rv.until = rep.obsAt |
| + rv.until = rep.at |
| rv.Version = rep.version |
| rv.box = rep.box |
| rv.dbBytes = rep.dbBytes |
| rv.aliases = rep.aliases |
| + rv.metricsBox = rep.box |
| switch { |
| - case rep.fromEdges: |
| - // Identified by the edges file alone: no readings (they cannot |
| - // be dated to this owner), and an instance's health is unknown. |
| - // A static site is served with no process, so ready is enough. |
| - // Checked first: nothing below may enable readings for it. |
| - rv.unknown = kind != "static" |
| case rep.down: |
| // Held down after a failed hold-mode build: the local rows' |
| // word for an instance that will not start, "Failed". |
| rv.Status = "failed" |
| - rv.metricsBox = rep.box |
| case rep.transient: |
| // Starting or stopping: not healthy sleep, and not up either. |
| rv.unknown = true |
| - rv.metricsBox = rep.box |
| default: |
| - rv.metricsBox = rep.box |
| rv.boxAwake = rep.awake |
| } |
| if rd := rep.reading; rd != nil { |
| @@ -502,7 +393,7 @@ func remoteRoute(rec provision.Record, rep *hostReport, f fleetReports, acct str |
| dv.Guidance = domainGuidance(rec.Host, dns) |
| } |
| } |
| - case f.complete && !fleetPlaced && !f.seen(rec.Host): |
| + case f.complete() && !fleetPlaced && !f.seen(rec.Host): |
| rv.Status = "pending" |
| default: |
| rv.unknown = true |
| @@ -563,33 +454,18 @@ func (s *Server) pageRecords(ctx context.Context, acct, app string, skip map[str |
| return recs, nil |
| } |
| -// confirmRecord is remoteRows.confirm for acct: one live GET of the record. |
| -func (s *Server) confirmRecord(ctx context.Context, acct, app, host string, created time.Time) bool { |
| - if s.cfg.Releases == nil { |
| - return false |
| - } |
| - cctx, cancel := context.WithTimeout(ctx, instanceStoreTimeout) |
| - defer cancel() |
| - rec, err := provision.GetRecord(cctx, s.cfg.Releases, acct, app, host) |
| - return err == nil && rec.CreatedAt.Equal(created) |
| -} |
| - |
| // remoteSource builds Assemble's remote input for one page view of acct. |
| func (s *Server) remoteSource(ctx context.Context, acct string) *remoteRows { |
| if s.cfg.Releases == nil { |
| return nil |
| } |
| - read := s.pageFleet(ctx) |
| return &remoteRows{ |
| - confirm: func(app, host string, created time.Time) bool { |
| - return s.confirmRecord(ctx, acct, app, host, created) |
| - }, |
| records: func(app string, skip map[string]bool) ([]provision.Record, error) { |
| rctx, cancel := context.WithTimeout(ctx, instanceStoreTimeout) |
| defer cancel() |
| return s.pageRecords(rctx, acct, app, skip) |
| }, |
| - reports: foldFleet(read, time.Now()), |
| + facts: func(app string) appFacts { return s.remoteFacts(ctx, acct, app) }, |
| } |
| } |
| @@ -620,9 +496,13 @@ var errRetireUnsettled = errors.New("the app's instances have not settled") |
| // and the console refuses for channelSettle after it starts; the audit |
| // log is read too; |
| // - 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. |
| +// - a fresh box report names this account and app (its rollout entry) 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. |
| +// |
| +// The inventory is the records, the console box's routes (channelHosts) and |
| +// the box reports' hosts of the app, all through remoteFacts. |
| // |
| // 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. |
| @@ -667,22 +547,12 @@ func (s *Server) retireUnsettled(ctx context.Context, acct, app string, keys, ho |
| if err := s.recentRecordDeletion(acct, app, now); err != nil { |
| return err |
| } |
| - read := s.pageFleet(ctx) |
| - if !read.complete { |
| + facts := s.remoteFacts(ctx, acct, app) |
| + if !facts.complete() { |
| return unsettled("not every box report could be read") |
| } |
| - f := foldFleet(read, now) |
| - for host, reps := range f.byHost { |
| - if hosts[host] { |
| - continue |
| - } |
| - for _, r := range reps { |
| - for _, c := range r.claims { |
| - if c[0] == acct && c[1] == app { |
| - return unsettled("box %s still serves %s, which no record names", r.box, host) |
| - } |
| - } |
| - } |
| + if host, box, ok := facts.unrecorded(hosts); ok { |
| + return unsettled("box %s still serves %s for this app, which no record names", box, host) |
| } |
| return nil |
| } |
diff --git a/internal/console/remoteinstances_round1_test.go b/internal/console/remoteinstances_round1_test.go| index f39f92b39..64e63c909 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", time.Time{}), f, "a", DNSTargets{}) |
| + rv, dv := remoteRoute(rec, factsOf(f, "a", "shop").host(rec), factsOf(f, "a", "shop"), "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 860ca3cae..7391a3fbd 100644 |
| --- a/internal/console/remoteinstances_round2_test.go |
| +++ b/internal/console/remoteinstances_round2_test.go |
| @@ -179,7 +179,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, "a", DNSTargets{}) |
| + rv, dv := remoteRoute(provision.Record{Host: "s.example.com", App: "shop", Account: "a", Kind: "static"}, nil, factsOf(f, "a", "shop"), "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) |
diff --git a/internal/console/remoteinstances_round4_test.go b/internal/console/remoteinstances_round4_test.go| index 2b158de05..053e5c892 100644 |
| --- a/internal/console/remoteinstances_round4_test.go |
| +++ b/internal/console/remoteinstances_round4_test.go |
| @@ -4,7 +4,6 @@ package console |
| import ( |
| "context" |
| - "encoding/json" |
| "net/http" |
| "strings" |
| "sync" |
| @@ -21,12 +20,11 @@ import ( |
| const residentHost = "always.shop.example.com" |
| -// P2 #3: a remote instance that never sleeps is outside the rollout report |
| -// (rollout.Managed), so its identity comes from its box's edges file. Its |
| -// row shows the box's version. Its readings and health do not join: an |
| -// edges-file owner cannot be dated (the box rewrites the file only on |
| -// change), so a sample under that hostname may be a successor's. |
| -func TestRemoteResidentInstanceIdentifiedByEdgesFile(t *testing.T) { |
| +// Round 5 (by ruling): a remote instance that never sleeps is outside the |
| +// rollout report (rollout.Managed), so no report names its tenant. Its row |
| +// shows the record's facts and "Can't tell right now"; nothing of the |
| +// box's report joins: not the version, not a reading. |
| +func TestRemoteResidentInstanceIsUnknown(t *testing.T) { |
| tb := newTwoBoxes(t) |
| no := false |
| if err := provision.CreateRecord(context.Background(), tb.fx.rel, provision.Record{Schema: 1, Host: residentHost, Slug: "always", |
| @@ -46,38 +44,18 @@ func TestRemoteResidentInstanceIdentifiedByEdgesFile(t *testing.T) { |
| }) |
| report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096) |
| row := instanceRow(t, tb.page(t, "/apps/shop/instances"), residentHost) |
| - if !strings.Contains(row, "v3") || !strings.Contains(row, "Can't tell right now") || strings.Contains(row, "27%") || strings.Contains(row, "Not responding") { |
| + if strings.Contains(row, "v3") || !strings.Contains(row, "Can't tell right now") || !strings.Contains(row, "stable") || strings.Contains(row, "27%") { |
| t.Fatalf("Running row for a resident remote instance = %s", row) |
| } |
| - if ov := tb.page(t, "/apps/shop"); strings.Contains(ov, "27%") { |
| - t.Fatalf("overview joined readings on an edges-file identity:\n%s", ov) |
| + if ov := tb.page(t, "/apps/shop"); strings.Contains(ov, "27%") || strings.Contains(ov, "4.0 KB") { |
| + t.Fatalf("overview joined an unidentified report:\n%s", ov) |
| } |
| if code, _, out := rawReq(t, http.MethodGet, instancesURL(tb.fx, tb.sqid, "shop"), tb.token, ""); code != http.StatusOK || |
| - !strings.Contains(out, `"host":"`+residentHost+`"`) || !strings.Contains(out, `"health":"Can't tell right now"`) { |
| + !strings.Contains(out, `"health":"Can't tell right now"`) { |
| t.Fatalf("instances list = %d %s", code, out) |
| } |
| } |
| -// The edges file and the rollout report naming different tenants for one |
| -// host give it no identity at all. |
| -func TestEdgesAndRolloutDisagreeingIsNoIdentity(t *testing.T) { |
| - now := time.Now() |
| - boxes := []status.Box{{GeneratedAt: now, Label: "b", Metrics: &status.BoxMetrics{ |
| - RouteVersions: map[string]string{"h.example.com": "v2", "s.example.com": "v2"}, |
| - Rollout: &status.RolloutReport{Hosts: map[string]status.HostRollout{ |
| - "h.example.com": {Account: "a", App: "shop"}, |
| - }}, |
| - }}} |
| - owners := map[string]map[string][2]string{"b": {"h.example.com": {"z", "shop"}, "s.example.com": {"a", "shop"}}} |
| - f := foldFleet(fleetRead{boxes: boxes, complete: true, owners: owners, at: now}, now) |
| - if rep := f.pick("h.example.com", "a", "shop", time.Time{}); rep != nil { |
| - t.Fatalf("joined a host whose two sources disagree: %+v", rep) |
| - } |
| - if rep := f.pick("s.example.com", "a", "shop", time.Time{}); rep == nil || rep.version != "v2" || !rep.obsAt.Equal(now) { |
| - t.Fatalf("the edges-file identity of a host the rollout does not manage = %+v", rep) |
| - } |
| -} |
| - |
| // P1 #1: the hostname passes to a successor tenant on the same box while |
| // this account's ownership is still what the console holds (a stale record |
| // snapshot, a cached report naming this account). The successor's samples, |
| @@ -240,10 +218,10 @@ func TestRemoteInstancesListIgnoresSuccessorSample(t *testing.T) { |
| } |
| } |
| -// Codex census review of 55706243: where the rollout report and the edges |
| -// file disagree about a host no record names, the host has no identity to |
| -// join, but either source naming this app still holds a retire. |
| -func TestRetireKeepsConflictingEvidence(t *testing.T) { |
| +// The retire inventory includes the box reports' hosts of the app: a box |
| +// whose rollout report names this app for a host no record names holds the |
| +// retire. |
| +func TestRetireRefusesUnrecordedHostOfApp(t *testing.T) { |
| tb := newTwoBoxes(t) |
| shipAndPromote(t, tb.fx, tb.sqid, "shop", "v4", "canary/rc") |
| if err := tb.regB.Upsert(registry.Route{Host: "hand.shop.example.com", Kind: "instance", App: "shop", Account: tb.sqid, |
| @@ -251,42 +229,14 @@ func TestRetireKeepsConflictingEvidence(t *testing.T) { |
| Socket: "/run/carlos/hand.sock"}); err != nil { |
| t.Fatal(err) |
| } |
| - label := report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096) |
| + report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096) |
| rt, _ := tb.regB.Get("hand.shop.example.com") |
| if !rollout.Managed(*rt) { |
| t.Fatalf("fixture: the hand route is not rollout-managed: %+v", rt) |
| } |
| - writeEdgesOwners(t, tb.fx.rel, label, map[string][2]string{"hand.shop.example.com": {"other", "shop"}}) |
| tb.fx.srv.boxReports.expire() |
| if _, err := tb.fx.srv.channelHosts(context.Background(), tb.sqid, "shop", "canary/rc"); !errorsIsUnsettled(err) { |
| - t.Fatalf("a box naming this app for a host no record names (edges disagreeing) = %v, want unsettled", err) |
| - } |
| -} |
| - |
| -func writeEdgesOwners(t *testing.T, rel release.Store, label string, owners map[string][2]string) { |
| - t.Helper() |
| - hosts := map[string]any{} |
| - for h, o := range owners { |
| - hosts[h] = map[string]any{"role": "home", "account": o[0], "app": o[1]} |
| - } |
| - body, _ := json.Marshal(map[string]any{"v": 1, "box": label, "hosts": hosts, "generation": time.Now().UTC().Format(time.RFC3339)}) |
| - key := "control/edges/" + label + ".json" |
| - _, etag, _ := rel.Get(context.Background(), key) |
| - if _, err := rel.Put(context.Background(), key, body, etag); err != nil { |
| - t.Fatal(err) |
| - } |
| -} |
| - |
| -// Codex census review of 55706243: an edges-file identity is dated by the |
| -// box's report, not by when the console read the file. |
| -func TestEdgesIdentityDatedByReport(t *testing.T) { |
| - gen := time.Now().Add(-4 * time.Minute) |
| - boxes := []status.Box{{GeneratedAt: gen, Label: "b", Metrics: &status.BoxMetrics{ |
| - RouteVersions: map[string]string{"s.example.com": "v2"}}}} |
| - owners := map[string]map[string][2]string{"b": {"s.example.com": {"a", "shop"}}} |
| - f := foldFleet(fleetRead{boxes: boxes, complete: true, owners: owners, at: time.Now()}, time.Now()) |
| - if rep := f.pick("s.example.com", "a", "shop", time.Time{}); rep == nil || !rep.obsAt.Equal(gen) { |
| - t.Fatalf("edges identity observed at %+v, want the report's generation %v", rep, gen) |
| + t.Fatalf("a box naming this app for a host no record names = %v, want unsettled", err) |
| } |
| } |
| @@ -339,59 +289,6 @@ func TestRetireRefusesPointerChangedDuringCheck(t *testing.T) { |
| } |
| } |
| -// Codex census review of 56e72aa5: an edges-file-only identity joins the |
| -// report only while the record demonstrably exists. With the record view's |
| -// snapshot still holding a record deleted behind the console's back, the |
| -// row joins nothing from the box. |
| -func TestEdgesIdentityNeedsLiveRecord(t *testing.T) { |
| - tb := newTwoBoxes(t) |
| - no := false |
| - if err := provision.CreateRecord(context.Background(), tb.fx.rel, provision.Record{Schema: 1, Host: residentHost, Slug: "always", |
| - App: "shop", Account: tb.sqid, Pool: "shop", Region: "uk", Channel: "stable", Hibernate: &no, CreatedAt: time.Now()}); err != nil { |
| - t.Fatal(err) |
| - } |
| - tb.reconcile(t, "v3") |
| - report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096) |
| - v := provision.NewRecordView(tb.fx.rel, release.NewChangeWatch(tb.fx.rel)) |
| - if err := v.Rebuild(context.Background()); err != nil { |
| - t.Fatal(err) |
| - } |
| - tb.fx.srv.SetRecordView(v) |
| - if row := instanceRow(t, tb.page(t, "/apps/shop/instances"), residentHost); !strings.Contains(row, "v3") { |
| - t.Fatalf("fixture: the edges-identified row = %s", row) |
| - } |
| - if err := tb.fx.rel.Delete(context.Background(), provision.RecordKey(tb.sqid, "shop", residentHost)); err != nil { |
| - t.Fatal(err) |
| - } |
| - tb.fx.srv.boxReports.expire() |
| - if row := instanceRow(t, tb.page(t, "/apps/shop/instances"), residentHost); strings.Contains(row, "v3") { |
| - t.Fatalf("a stale snapshot's record let an undated edges identity join: %s", row) |
| - } |
| -} |
| - |
| -// Codex census review of 56e72aa5: a rollout entry that names no tenant |
| -// cannot lend its process state (down, transient, awake) or readings to an |
| -// identity the edges file supplies. |
| -func TestEdgesIdentityTakesNoUnnamedRolloutState(t *testing.T) { |
| - now := time.Now() |
| - boxes := []status.Box{{GeneratedAt: now, Label: "b", Metrics: &status.BoxMetrics{ |
| - RouteVersions: map[string]string{"h.example.com": "v2"}, |
| - Rollout: &status.RolloutReport{Hosts: map[string]status.HostRollout{ |
| - "h.example.com": {Attempt: status.AttemptDown, Awake: true}, |
| - }}, |
| - }}} |
| - owners := map[string]map[string][2]string{"b": {"h.example.com": {"a", "shop"}}} |
| - f := foldFleet(fleetRead{boxes: boxes, complete: true, owners: owners, at: now}, now) |
| - rep := f.pick("h.example.com", "a", "shop", time.Time{}) |
| - if rep == nil || !rep.fromEdges { |
| - t.Fatalf("fixture: %+v", rep) |
| - } |
| - rv, _ := remoteRoute(provision.Record{Host: "h.example.com", App: "shop", Account: "a"}, rep, f, "a", DNSTargets{}) |
| - if rv.Status == "failed" || rv.metricsBox != "" || rv.boxAwake { |
| - t.Fatalf("an unnamed rollout entry's state reached the row: %+v", rv) |
| - } |
| -} |
| - |
| // Codex census review of 56e72aa5: the canary's pointer removed by someone |
| // else during the check is not "restored" from this request's older bytes. |
| func TestRetireDoesNotResurrectRemovedPointer(t *testing.T) { |
diff --git a/internal/console/remoteinstances_round5_test.go b/internal/console/remoteinstances_round5_test.go| new file mode 100644 |
| index 000000000..974f061ce |
| --- /dev/null |
| +++ b/internal/console/remoteinstances_round5_test.go |
| @@ -0,0 +1,118 @@ |
| +package console |
| + |
| +// Round 5 (Astra, 59c2cd61; by the coordinator's ruling, shrink): one |
| +// accessor for remote facts, identity from the record plus a report naming |
| +// the same tenant generated after the record, and nothing else. |
| + |
| +import ( |
| + "context" |
| + "go/ast" |
| + "go/parser" |
| + "go/token" |
| + "os" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/status" |
| +) |
| + |
| +// TestRemoteFactsOneAccessor holds the package to the one-accessor rule: |
| +// box reports are folded only by remoteFacts, their per-host map is read |
| +// only by the accessor's own methods, and the cached read is taken only by |
| +// remoteFacts and by the Overview's local-row database join (which reads |
| +// sizes for the console box's own rows, never a remote host's). A page that |
| +// joins reports for a remote host itself fails here. |
| +func TestRemoteFactsOneAccessor(t *testing.T) { |
| + allowed := map[string]map[string]bool{ |
| + "foldFleetReports": {"remoteFacts": true}, |
| + "pageBoxReports": {"remoteFacts": true, "handleApp": true}, |
| + "byHost": {"foldFleetReports": true, "host": true, "seen": true, "unrecorded": true}, |
| + } |
| + files, err := filepath.Glob("*.go") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + fset := token.NewFileSet() |
| + for _, name := range files { |
| + if strings.HasSuffix(name, "_test.go") { |
| + continue |
| + } |
| + src, err := os.ReadFile(name) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + f, err := parser.ParseFile(fset, name, src, 0) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, decl := range f.Decls { |
| + fn, ok := decl.(*ast.FuncDecl) |
| + if !ok || fn.Body == nil { |
| + continue |
| + } |
| + ast.Inspect(fn.Body, func(n ast.Node) bool { |
| + var ident string |
| + switch x := n.(type) { |
| + case *ast.SelectorExpr: |
| + ident = x.Sel.Name |
| + case *ast.CallExpr: |
| + if id, ok := x.Fun.(*ast.Ident); ok { |
| + ident = id.Name |
| + } |
| + } |
| + if callers, watched := allowed[ident]; watched && !callers[fn.Name.Name] { |
| + t.Errorf("%s: %s uses %s; remote facts go through remoteFacts only", fset.Position(n.Pos()), fn.Name.Name, ident) |
| + } |
| + return true |
| + }) |
| + } |
| + } |
| +} |
| + |
| +// P1 #2: the instance page of a remote host whose only report is a box |
| +// that could not arm its rollout (Unavailable, no per-host entry) and that |
| +// still carries another tenant's installation shows none of it: not its |
| +// installed version, not a rollout section. |
| +func TestRemoteInstancePageTakesNothingFromUnidentifiedReport(t *testing.T) { |
| + tb := newTwoBoxes(t) |
| + tb.create(t, tb.token, tb.sqid, "shop", remoteHost, "uk", "") |
| + tb.reconcile(t, "v3") |
| + routes, err := tb.regB.List() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for i := range routes { |
| + if routes[i].Host == remoteHost { |
| + routes[i].Version = "v9-other" |
| + } |
| + } |
| + b := status.CollectBox(routes, status.Probes{MachineID: "box-b", Region: "uk", |
| + Rollout: &status.RolloutReport{Unavailable: "no-swap"}}, time.Now()) |
| + if err := status.WriteBox(context.Background(), tb.fx.rel, b); err != nil { |
| + t.Fatal(err) |
| + } |
| + inst := tb.page(t, "/apps/shop/instances/"+remoteHost) |
| + if strings.Contains(inst, "v9-other") { |
| + t.Fatalf("the instance page shows another installation's version from an unidentified report:\n%s", inst) |
| + } |
| + if !strings.Contains(inst, "Can't tell right now") { |
| + t.Fatalf("the instance page does not say its state is unknown:\n%s", inst) |
| + } |
| +} |
| + |
| +// The accessor's facts are for one account and app: a record of any other, |
| +// handed to it, joins nothing, even a report naming the facts' own tenant. |
| +func TestRemoteFactsAreScopedToTheirApp(t *testing.T) { |
| + now := time.Now() |
| + boxes := []status.Box{{GeneratedAt: now, Label: "b", Metrics: &status.BoxMetrics{ |
| + RouteVersions: map[string]string{"h.example.com": "v2"}, |
| + Rollout: &status.RolloutReport{Hosts: map[string]status.HostRollout{"h.example.com": {Account: "a", App: "shop"}}}, |
| + }}} |
| + facts := factsOf(foldFleetReports(boxes, true, now), "a", "shop") |
| + if rep := facts.host(provision.Record{Host: "h.example.com", Account: "b", App: "shop"}); rep != nil { |
| + t.Fatalf("facts for a/shop joined a record of b/shop: %+v", rep) |
| + } |
| +} |
diff --git a/internal/console/remoteinstances_test.go b/internal/console/remoteinstances_test.go| index df9f0f6b3..6208dc964 100644 |
| --- a/internal/console/remoteinstances_test.go |
| +++ b/internal/console/remoteinstances_test.go |
| @@ -11,7 +11,6 @@ package console |
| import ( |
| "context" |
| - "encoding/json" |
| "fmt" |
| "net/http" |
| "net/url" |
| @@ -150,12 +149,10 @@ func (tb *twoBoxes) reconcile(t *testing.T, version string) { |
| } |
| // report writes box's status snapshot from its own registry, what the |
| -// agent's status tick does (CollectBox over the registry and its aliases), |
| -// and its edges file. The rollout report names the tenant of exactly the |
| -// routes production's rollout manages (rollout.Managed: never a static, a |
| -// non-hibernating or a unit-backed route); the edges file names the owner |
| -// of every route, as internal/host's servedOwners publishes it. Each route |
| -// gets a database size. |
| +// agent's status tick does (CollectBox over the registry and its aliases). |
| +// The rollout report names the tenant of exactly the routes production's |
| +// rollout manages (rollout.Managed: never a static, a non-hibernating or a |
| +// unit-backed route). Each route gets a database size. |
| func report(t *testing.T, rel release.Store, reg *registry.Registry, machine, region string, at time.Time, awake map[string]bool, dbBytes int64) string { |
| t.Helper() |
| routes, err := reg.List() |
| @@ -177,30 +174,9 @@ func report(t *testing.T, rel release.Store, reg *registry.Registry, machine, re |
| if err := status.WriteBox(context.Background(), rel, b); err != nil { |
| t.Fatal(err) |
| } |
| - writeEdges(t, rel, b.Label, region, routes) |
| return b.Label |
| } |
| -// writeEdges writes box's edges file in the shape internal/host publishes: |
| -// every route it serves, as home, with the account and app that own it. |
| -func writeEdges(t *testing.T, rel release.Store, label, region string, routes []registry.Route) { |
| - t.Helper() |
| - hosts := map[string]any{} |
| - for _, rt := range routes { |
| - hosts[rt.Host] = map[string]any{"role": "home", "platform": rt.Platform, "account": release.RouteAccount(rt), "app": rt.App} |
| - } |
| - body, err := json.Marshal(map[string]any{"v": 1, "box": label, "eip": "203.0.113.10", "region": region, |
| - "generation": time.Now().UTC().Format(time.RFC3339), "hosts": hosts}) |
| - if err != nil { |
| - t.Fatal(err) |
| - } |
| - key := "control/edges/" + label + ".json" |
| - _, etag, _ := rel.Get(context.Background(), key) |
| - if _, err := rel.Put(context.Background(), key, body, etag); err != nil { |
| - t.Fatal(err) |
| - } |
| -} |
| - |
| // sweep writes box's metrics chunk: one exec-child unit per host given, |
| // sampled now (after the instances it reads were created: earlier samples |
| // of a hostname are not its current owner's, ownerAppMetricsFrom). |
| @@ -458,16 +434,16 @@ func TestRemoteReportNamingAnotherTenant(t *testing.T) { |
| }}, |
| }}} |
| f := foldFleetReports(boxes, true, now) |
| - if rep := f.pick("h.example.com", "mine", "shop", time.Time{}); rep != nil { |
| + if rep := pickFor(f, "h.example.com", "mine", "shop"); rep != nil { |
| t.Fatalf("joined a report naming another account: %+v", rep) |
| } |
| - if rep := f.pick("h.example.com", "other", "web", time.Time{}); rep != nil { |
| + if rep := pickFor(f, "h.example.com", "other", "web"); rep != nil { |
| t.Fatalf("joined a report naming another app: %+v", rep) |
| } |
| - if rep := f.pick("h.example.com", "other", "shop", time.Time{}); rep == nil || rep.version != "v7" || !rep.awake { |
| + if rep := pickFor(f, "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", time.Time{}), f, "mine", DNSTargets{}) |
| + rv, dv := remoteRoute(provision.Record{Host: "h.example.com", App: "shop", Account: "mine"}, pickFor(f, "h.example.com", "mine", "shop"), factsOf(f, "mine", "shop"), "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 != "" { |
| @@ -483,13 +459,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", time.Time{}), f, "a", DNSTargets{}) |
| + rv, _ := remoteRoute(provision.Record{Host: "h.example.com", App: "shop", Account: "a"}, pickFor(f, "h.example.com", "a", "shop"), factsOf(f, "a", "shop"), "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", time.Time{}), f, "a", DNSTargets{}) |
| + rv, dv := remoteRoute(provision.Record{Host: "h.example.com", App: "shop", Account: "a"}, pickFor(f, "h.example.com", "a", "shop"), factsOf(f, "a", "shop"), "a", DNSTargets{}) |
| if rv.Status != "" { |
| t.Fatalf("an incomplete read vouched for absence: %+v", rv) |
| } |
| @@ -507,7 +483,7 @@ func TestRemoteReportStaleAndMoving(t *testing.T) { |
| RouteVersions: map[string]string{"h.example.com": "v3"}, |
| Rollout: &status.RolloutReport{Hosts: map[string]status.HostRollout{"h.example.com": {Account: "a", App: "shop"}}}}} |
| f = foldFleetReports([]status.Box{older, newerNoTenant, newer}, true, now) |
| - if rep := f.pick("h.example.com", "a", "shop", time.Time{}); rep == nil || rep.version != "v3" { |
| + if rep := pickFor(f, "h.example.com", "a", "shop"); rep == nil || rep.version != "v3" { |
| t.Fatalf("move in flight picked %+v, want the freshest report naming the tenant (v3)", rep) |
| } |
| } |
| @@ -522,7 +498,7 @@ func TestRemoteRecordsAccountFilter(t *testing.T) { |
| {Host: "theirs.example.com", App: "shop", Account: "b"}, |
| {Host: "sibling.example.com", App: "web", Account: "a"}, |
| }, nil |
| - }, reports: fleetReports{complete: true}} |
| + }, facts: func(app string) appFacts { return factsOf(fleetReports{complete: true}, "a", app) }} |
| routes, domains := addRemoteRows(remote, "a", "shop", map[string]bool{}, nil, nil, DNSTargets{}) |
| if len(routes) != 1 || routes[0].Host != "mine.example.com" || len(domains) != 1 { |
| t.Fatalf("rows = %+v", routes) |
| @@ -768,3 +744,13 @@ func TestRemoteInstanceRequestBudget(t *testing.T) { |
| t.Fatalf("unarmed overview within the minute = %v, want [0 0 1 1]", got) |
| } |
| } |
| + |
| +// factsOf and pickFor wrap folded reports in the one accessor's type, for |
| +// unit tests of the join rules. |
| +func factsOf(f fleetReports, acct, app string) appFacts { |
| + return appFacts{acct: acct, app: app, reports: f} |
| +} |
| + |
| +func pickFor(f fleetReports, host, acct, app string) *hostReport { |
| + return factsOf(f, acct, app).host(provision.Record{Host: host, Account: acct, App: app}) |
| +} |
diff --git a/internal/console/view.go b/internal/console/view.go| index 6aeecef4d..0023c70cc 100644 |
| --- a/internal/console/view.go |
| +++ b/internal/console/view.go |
| @@ -711,6 +711,7 @@ func addRemoteRows(remote *remoteRows, acct, app string, localHosts map[string]b |
| // read, its ownership start is unknown. |
| routes[i].bounded = rt.Provisioned |
| } |
| + facts := remote.facts(app) |
| recs, err := remote.records(app, nil) |
| if err != nil { |
| log.Printf("console: instance records %s/%s: %v", acct, app, err) |
| @@ -731,13 +732,7 @@ func addRemoteRows(remote *remoteRows, acct, app string, localHosts map[string]b |
| } |
| continue |
| } |
| - rep := remote.reports.pick(rec.Host, acct, app, rec.CreatedAt) |
| - if rep != nil && rep.fromEdges && (remote.confirm == nil || !remote.confirm(app, rec.Host, rec.CreatedAt)) { |
| - // An undated edges-file identity joins only while the record |
| - // demonstrably still exists (remoteRows.confirm). |
| - rep = nil |
| - } |
| - rv, dv := remoteRoute(rec, rep, remote.reports, acct, dns) |
| + rv, dv := remoteRoute(rec, facts.host(rec), facts, 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 33d952a8d..7a33a3eb1 100644 |
| --- a/internal/provision/console_remote_instances_census_test.go |
| +++ b/internal/provision/console_remote_instances_census_test.go |
| @@ -8,8 +8,9 @@ package provision |
| // docs/superpowers/notes/census-proposal-console-remote-instances.md). |
| // No record write is added anywhere. |
| // - Server.handleAppInstance: a remote row (an instance record with no |
| -// row in the console box's registry) takes its aliases from its box |
| -// report instead of the local ListAliases; its instances literal (the |
| +// row in the console box's registry) runs none of the hostname-keyed |
| +// box joins and takes its aliases from its row (remoteFacts) instead of |
| +// the local ListAliases; its instances literal (the |
| // list URL it links back to) is unchanged and it writes nothing: |
| // key-site. |
| // - Server.channelHosts (the canary-retire guard) now also lists the |
| @@ -44,12 +45,12 @@ package provision |
| func consoleRemoteInstancesWriteCensusInventory() []censusEntry { |
| entries := append([]censusEntry(nil), edgeRateLimitWriteCensusInventory()...) |
| replacements := []censusEntry{ |
| - {"internal/console/instancepage.go", "Server.handleAppInstance", "key-site", "lit:instances", "07f5c01659b0d453d5996abb6a6e9493f74c7df97e3cddfe0f765b6f316de4a7"}, |
| + {"internal/console/instancepage.go", "Server.handleAppInstance", "key-site", "lit:instances", "5208ae08d92c1022d7849e4ad50578460bb01b521983e09ee2f39af528a1dc55"}, |
| {"internal/console/server.go", "Server.channelHosts", "key-site", "key:RecordKey,key:SidecarsPrefix", "966e1fb668d3910ccb102845f1c5c91a1aa2cfa857bbf0ca11d850945259c682"}, |
| {"internal/console/apiinstanceimport.go", "Server.deleteRead", "key-site", "key:RecordKey", "10452daaaf26912a51748001af6d1c801726b80c1167b22815e70f41c04c9552"}, |
| {"internal/console/seedfinish.go", "Server.finishSeedOnce", "key-site", "key:RecordKey", "55c0cd69496dbc7c5339ea9374d90da70864d5c6f8a33e613351e290988c1e72"}, |
| {"internal/console/claim_retire.go", "Server.retireClaimHostRecord", "key-site", "key:claimRetireRecordKey", "3c30cfcad8f2edb3c38b7dd9e56697cd3e17ce3a7fa0e76eb815adf3dad7bd4d"}, |
| - {"internal/console/remoteinstances.go", "Server.retireUnsettled", "key-site", "key:RecordsPrefix,key:SidecarsPrefix", "f8060eaf63710c2326b3bcb10b545b15f21d91c52d540b0245d0dc5b83548ab6"}, |
| + {"internal/console/remoteinstances.go", "Server.retireUnsettled", "key-site", "key:RecordsPrefix,key:SidecarsPrefix", "a880d8edff2cba0ede6ed32fd5e48984b52b486c1db75ff612878ddb7ac2007b"}, |
| {"internal/console/remoteinstances.go", "Server.pageRecords", "key-site", "key:RecordsPrefix", "5298e5713404c168fdc4cfdc9995f57a5d3d61893d4b6c17f985877de59f8896"}, |
| {"internal/console/remoteinstances.go", "Server.recordStamps", "key-site", "key:RecordsPrefix,key:SidecarsPrefix", "c38f120e5be0e8c883b6da7d86df23a5b6b495a31732732e6cbe6efe5821ff43"}, |
| } |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index c2d071375..dcac93e3f 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 91381ac20a7c806cdb36e7362850c6a45a196501e5768cbceef73fc3c0153102 |
| +plan14-root-reads-console-remote-instances.tsv 99d2ccf52f30915b0b7c7af61013a6046ddb03f165271dd3f2fe43d6c6bbc5f1 |
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 b7606de68..683c0fcb2 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-console-remote-instances.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-console-remote-instances.tsv |
| @@ -4,22 +4,22 @@ |
| @legacy 5d23e3044287253a4ff2e8ef1bd1ea50e2f4682485ba794d7c9d5635c8a24584 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 window per host (since, until) from the caller: readings only from that box and only from samples inside the window, via ownerAppMetricsFrom; registry reads unchanged. registry:Backing@1279,registry:Hibernate@1201,registry:Kind@1184,registry:Provisioned@1254,registry:Status@1061,registry:Unit@1270,registry:Unit@394,registry:Unit@429,whole:Route@1038,whole:Route@242,whole:Route@285,whole:Route@351 6d4e71f0460632bec27b64b948c6bea4fdf48c2ff5c15c252614a46643b81924 |
| @legacy 6aca486aeff4e98674d40cac55e1ed92f45045a178c212f3ed3be6e106ad8bde 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-window arguments; nothing else. registry:Account@4619,registry:App@1646,registry:App@2119,registry:App@4558,registry:Backing@2279,registry:Canary@2417,registry:Channel@2139,registry:Environment@2164,registry:Hibernate@2238,registry:Host@1730,registry:Host@2061,registry:Host@2217,registry:Host@2373,registry:Host@4691,registry:Host@4771,registry:Kind@2076,registry:Platform@2402,registry:Prefix@4787,registry:Provisioned@2304,registry:Replication@2336,registry:Status@2188,registry:Target@4805,registry:Unit@2258,whole:Route@1635,whole:Route@1684,whole:Route@1721,whole:Route@1741,whole:Route@1861,whole:Route@1978,whole:Route@2009,whole:Route@2109,whole:Route@4682,whole:RoutePath@3624 b4c691f072d0c7d829aba6a5302cf95fe36abf2596d5060064493b49af80c35f |
| @legacy e096052196bcd47b52cd721741d73c701d59e2f0d6a0a0a0cf9c4b33a1636bf1 internal/console/claim_retire.go Server.retireClaimHostRecord legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-console-remote-instances;basis=Notes the app in the console's in-memory deletion log (noteRecordDeletion, which also invalidates the pages' held box reports) before retiring a record, for the canary-retire guard; the retire itself is unchanged. file:Read@941 3c30cfcad8f2edb3c38b7dd9e56697cd3e17ce3a7fa0e76eb815adf3dad7bd4d |
| -@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 2c4f2defe9c0c19d0f25974cf6ddf19e1fbdf2bf5f5658e4b50447c84d4e90ef 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) runs none of the hostname-keyed box joins (layout, rollout, updates): it shows only what its row brought through remoteFacts, aliases included. Local rows read layout, rollout join and ListAliases as before. file:Query@2895,registry:Account@2667,registry:Alias@2767,registry:App@2697,registry:Host@2645,whole:RouteAlias@2628 5208ae08d92c1022d7849e4ad50578460bb01b521983e09ee2f39af528a1dc55 |
| @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 5ba3b725e417106dfbca90c2d28ca0ff116430d0ec8dcbdf9533464cbeda380b 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). 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 f9afa7172609f539612d70a95d9cb6d9b094d3c171572994221367ae25da27ff 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 (rollout entry or edges-file owner) naming the record's own account and app and generated after the record existed (held down: Failed; transient, unidentified or unread: Can't tell right now), readings pinned to that box and bounded by the record's created_at and the report's observation. 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@2893,whole:Route@3920,whole:Route@4519,whole:Route@4572,whole:Route@4687,whole:Route@792,whole:Route@821,whole:Route@832,whole:Route@850 791a8e223123dd5361e927bf69023edda74f5f347a4a63a83c00d9b3d55872c8 |
| -@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 |
| +@legacy 80631d7995159901c7272e19e73a447d95cce7fc671ec0056f28572057b55071 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 remoteFacts: a box report whose rollout entry names the record's own account and app, generated after the record was created (held down: Failed; transient, unidentified or unread: Can't tell right now), readings pinned to that box and bounded by the record's created_at and the report's generation. 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@2887,whole:Route@3596,whole:Route@4110,whole:Route@4163,whole:Route@4278,whole:Route@792,whole:Route@821,whole:Route@832,whole:Route@850 c6e49aec6194fbb4ce76a51610708b4d9a4de82f2a8ae6a52f4ae25a1a06135b |
| +@legacy 985c17c7d12aab5b0e7faa1861e93fc51e946406f767e9f2fc33a89f4a74f16e 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 remoteFacts 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 window per host (since, until) from the caller: readings only from that box and only from samples inside the window, via ownerAppMetricsFrom; registry reads unchanged. registry:Backing@1279,registry:Hibernate@1201,registry:Kind@1184,registry:Provisioned@1254,registry:Status@1061,registry:Unit@1270,registry:Unit@394,registry:Unit@429,whole:Route@1038,whole:Route@242,whole:Route@285,whole:Route@351 6d4e71f0460632bec27b64b948c6bea4fdf48c2ff5c15c252614a46643b81924 |
| 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-window arguments; nothing else. registry:Account@4619,registry:App@1646,registry:App@2119,registry:App@4558,registry:Backing@2279,registry:Canary@2417,registry:Channel@2139,registry:Environment@2164,registry:Hibernate@2238,registry:Host@1730,registry:Host@2061,registry:Host@2217,registry:Host@2373,registry:Host@4691,registry:Host@4771,registry:Kind@2076,registry:Platform@2402,registry:Prefix@4787,registry:Provisioned@2304,registry:Replication@2336,registry:Status@2188,registry:Target@4805,registry:Unit@2258,whole:Route@1635,whole:Route@1684,whole:Route@1721,whole:Route@1741,whole:Route@1861,whole:Route@1978,whole:Route@2009,whole:Route@2109,whole:Route@4682,whole:RoutePath@3624 b4c691f072d0c7d829aba6a5302cf95fe36abf2596d5060064493b49af80c35f |
| internal/console/claim_retire.go Server.retireClaimHostRecord legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-console-remote-instances;basis=Notes the app in the console's in-memory deletion log (noteRecordDeletion, which also invalidates the pages' held box reports) before retiring a record, for the canary-retire guard; the retire itself is unchanged. file:Read@941 3c30cfcad8f2edb3c38b7dd9e56697cd3e17ce3a7fa0e76eb815adf3dad7bd4d |
| -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/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) runs none of the hostname-keyed box joins (layout, rollout, updates): it shows only what its row brought through remoteFacts, aliases included. Local rows read layout, rollout join and ListAliases as before. file:Query@2895,registry:Account@2667,registry:Alias@2767,registry:App@2697,registry:Host@2645,whole:RouteAlias@2628 5208ae08d92c1022d7849e4ad50578460bb01b521983e09ee2f39af528a1dc55 |
| 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/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). 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 (rollout entry or edges-file owner) naming the record's own account and app and generated after the record existed (held down: Failed; transient, unidentified or unread: Can't tell right now), readings pinned to that box and bounded by the record's created_at and the report's observation. 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@2893,whole:Route@3920,whole:Route@4519,whole:Route@4572,whole:Route@4687,whole:Route@792,whole:Route@821,whole:Route@832,whole:Route@850 791a8e223123dd5361e927bf69023edda74f5f347a4a63a83c00d9b3d55872c8 |
| -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 3215df94bc068619202cff7b7bb14fb5d957f2f3fd41a138d82157c96a4e0b27 |
| +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 remoteFacts: a box report whose rollout entry names the record's own account and app, generated after the record was created (held down: Failed; transient, unidentified or unread: Can't tell right now), readings pinned to that box and bounded by the record's created_at and the report's generation. 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@2887,whole:Route@3596,whole:Route@4110,whole:Route@4163,whole:Route@4278,whole:Route@792,whole:Route@821,whole:Route@832,whole:Route@850 c6e49aec6194fbb4ce76a51610708b4d9a4de82f2a8ae6a52f4ae25a1a06135b |
| +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 remoteFacts 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 74008e9f09feea99a63d54b7f08f11d90a8fc92df2a0d0728b0d753e01804a8f |
| @coverage internal/console/templates 6e272e30e00be5785b3f364a947ea4ab86b2d96a0e8d21821b7812c45f0a636f |