console: LoadMetrics answers unavailable with no deployment bucket
#720 Astra round 2. A routed app's Overview, Instances and instance pages panicked on a bucketless console: appResourceMetrics -> ownerAppMetricsFrom -> LoadMetrics -> sweepAll -> discoverBoxes listed the nil Config.Releases. LoadMetrics, the one entry every metrics caller (and its background refresh) goes through, now returns errMetricsNoBucket before the cache or any sweep; callers show metrics as unavailable through their existing error paths. TestNoBucketRoutedAppMetricsPages GETs the three pages for the fixture's routed kass app with a cold cache, one subtest each, and TestNoBucketAppPagesRender now walks kass as well as sprout.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/console/envform_test.go+34 −7internal/console/metricsview.go+11 −0
CI passed — run details
Intent
<task-notification> <task-id>by2n5vlm5</task-id> <tool-use-id>toolu_019yjzJWTZpSagCmRjo2Uofp</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/abe35d56-e4c2-40df-9005-6e66b76b1f50/tasks/by2n5vlm5.output</output-file> <status>completed</status> <summary>Background command "N=/home/paulca/amadan.net/carlos/platform/.claude/worktrees/followups-notes; until [ -f $N/astra-720-r2.done ]; do sleep 30; done; grep -E "READY|^##|^### |resolved" $N/astra-720-r2-findings.md | head -20; amadan ci status carlos/platform -branch nobucket-panic-720 2>&1 | head -1" completed (exit code 0)</summary> </task-notification>
<paseo-system version="1" kind="agent-message" source-agent-id="55f1f6a4-252a-4d89-af7b-a8a460b2b81d" message-id="ffa47687-42ba-40de-8755-780af1b54662"> Coordinator: Paul chose 3 for #720: enforce at the shared metrics boundary (no store => the existing 'metrics unavailable' result before any bucket work), with the routed-app regression test covering Overview, Instances and the instance page. One scoped Astra check of that diff (within the 3-round budget), CI, squash-merge, then ask 8a3d302 to fold #719 and #720 into the next console release and track the box 'managed' field. Report when done. </paseo-system>
Attributed to this commit: 10.9 g CO₂e (1,411,476 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on nobucket-panic-720, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/internal/console/envform_test.go b/internal/console/envform_test.go| index 668c3a8fb..a4cb3aba2 100644 |
| --- a/internal/console/envform_test.go |
| +++ b/internal/console/envform_test.go |
| @@ -280,13 +280,18 @@ func TestNoBucketAppPagesRender(t *testing.T) { |
| for section := range appSettingsSections { |
| paths[section] = "/apps/sprout/settings/" + section |
| } |
| - for name, path := range paths { |
| - status, _, body := get(t, c, fx.u(path)) |
| - if status != http.StatusOK { |
| - t.Fatalf("%s on a bucketless console = %d:\n%s", name, status, body) |
| - } |
| - if want := banners[name]; want != "" { |
| - mustContain(t, body, want) |
| + // sprout has no routes; kass (the fixture's) has owned routes, so its |
| + // pages also reach the metrics reader. |
| + for _, app := range []string{"sprout", "kass"} { |
| + for name, path := range paths { |
| + path = strings.Replace(path, "/apps/sprout", "/apps/"+app, 1) |
| + status, _, body := get(t, c, fx.u(path)) |
| + if status != http.StatusOK { |
| + t.Fatalf("%s %s on a bucketless console = %d:\n%s", app, name, status, body) |
| + } |
| + if want := banners[name]; want != "" { |
| + mustContain(t, body, want) |
| + } |
| } |
| } |
| @@ -308,6 +313,28 @@ func TestNoBucketAppPagesRender(t *testing.T) { |
| mustNotContain(t, body, "MODE", "fast", `class="savebar"`) |
| } |
| +// TestNoBucketRoutedAppMetricsPages: the three app pages that read box |
| +// metrics for an app's owned routes (Overview, Instances, one instance) |
| +// render on a bucketless console with a cold metrics cache, LoadMetrics |
| +// answering unavailable rather than listing a nil store (#720 round 2). |
| +func TestNoBucketRoutedAppMetricsPages(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + fx.srv.cfg.Releases = nil |
| + c := signInPaul(t, fx) |
| + for name, path := range map[string]string{ |
| + "overview": "/apps/kass", |
| + "instances": "/apps/kass/instances", |
| + "instance": "/apps/kass/instances/kass.carlosapp.dev", |
| + } { |
| + t.Run(name, func(t *testing.T) { |
| + status, _, body := get(t, c, fx.u(path)) |
| + if status != http.StatusOK { |
| + t.Fatalf("%s = %d:\n%s", path, status, body) |
| + } |
| + }) |
| + } |
| +} |
| + |
| func TestEnvFormCSRF(t *testing.T) { |
| e := newEnvFx(t) |
| f := envFields(t, e.page(t)) |
diff --git a/internal/console/metricsview.go b/internal/console/metricsview.go| index 90c3a77b9..09ec793c2 100644 |
| --- a/internal/console/metricsview.go |
| +++ b/internal/console/metricsview.go |
| @@ -299,7 +299,14 @@ type metricsCache struct { |
| // own context still governs WAITING in the blocking case (a cancelled |
| // waiter gives up rather than hanging), it just never governs the sweep |
| // itself. |
| +// |
| +// A console with no deployment bucket has no metrics to read: LoadMetrics |
| +// answers errMetricsNoBucket before the cache or any sweep, and every caller |
| +// shows metrics as unavailable through its ordinary error path (#720). |
| func (s *Server) LoadMetrics(ctx context.Context) ([]BoxMetricsView, []AlertRow, error) { |
| + if s.cfg.Releases == nil { |
| + return nil, nil, errMetricsNoBucket |
| + } |
| c := &s.metricsCache |
| for { |
| c.mu.Lock() |
| @@ -435,6 +442,10 @@ func (s *Server) startBackgroundSweep(c *metricsCache) { |
| }() |
| } |
| +// errMetricsNoBucket is LoadMetrics' answer on a console with no |
| +// deployment bucket. |
| +var errMetricsNoBucket = errors.New("console: no deployment bucket, so no metrics to read") |
| + |
| // sweepAll is the bucket half of LoadMetrics: discovery, every box's 48h raw |
| // sweep (metricsSweepBoxes of them at a time), then the alerts pass, on a |
| // context detached from the caller's (WithoutCancel) and bounded by |