console-budget-cold-warm: review fixes
Astra's round 1 (READY AFTER FIXES, five P2s), all five fixed: 1. Tenant-bucket S3 requests now count. The economics sizer (sizeProvisionedStore) and the scan pass's lister (storeLister) build their own S3 clients; both are now timed at the HTTP boundary (TimeS3Client), so their requests land on the run's job, else on the unattributed count. The store provisioner's S3 client is built inside objstore, so objstore gains NewAWSProvisionerWith (an optional wrap of the S3 HTTP doer; NewAWSProvisioner passes nil and builds exactly what it did) and cmd/console passes console.TimeS3HTTP. lease.NewVersionedS3 (host-claim consoles only) is left as it was. TestTenantBucketListings CountOnTheJob sizes a provisioned bucket of three listing pages through the real storage pass inside the economics job and checks the job's total equals the requests the tenant endpoint and the deployment fake received; it fails without the wrap (7 counted, 10 sent). 2. The report's flagship estimates are redone along the complete paths (report only; no pass changed). 3. The Changes table takes POST, PUT, PATCH and DELETE only; OPTIONS, CONNECT and OTHER have no budget and are in neither table (tested). 4. The jobs grid is a size container: below 56rem (a 1,024 px window beside the rail) its note moves to a line of its own under the row. Screenshots of Boxes and the dashboard at 1280, 1024 and 390 checked; TestOperatorScreenshots now shoots 1024 too and takes CONSOLE_OPS_SHOTS_PAGES. 5. CPF-30 replaces CPF-20: "page requests among the last 2,048 measured requests". Luna's one-string check returned the draft unchanged; record and gate updated, CPF-20 kept as history. Census: objstore's envelope re-pinned in the branch overlay plan14-root-reads-console-budget-cold-warm (card in docs/superpowers/notes/census-proposal-console-budget-cold-warm.md), on main's chain after merging origin/main 9665606d. It needs a cross-model reviewer's verdict on #280; not approved here.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
18 files changed,
+276
−37
approved_console_perf_copy_test.go+8 −6cmd/console/main.go+8 −7docs/superpowers/notes/census-proposal-console-budget-cold-warm.md+11 −0docs/superpowers/plans/2026-10-28-console-budget-copy.md+9 −0docs/superpowers/plans/LUNA-COPY-BRIEF-CONSOLE-BUDGET-CPF30.md+27 −0docs/superpowers/plans/LUNA-COPY-REVIEW-CONSOLE-BUDGET-CPF30.md+2 −0internal/console/economicspass.go+8 −4internal/console/jobs_s3_test.go+110 −0internal/console/opshots_test.go+16 −5internal/console/perfs3.go+17 −3internal/console/perfspeed.go+8 −4internal/console/perfspeed_test.go+15 −5internal/console/scanpass.go+4 −2internal/console/static/ops.css+16 −0internal/console/templates/metrics.html+1 −1internal/objstore/aws.go+12 −0internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-console-budget-cold-warm.tsv+3 −0
CI failed — run details
diff --git a/approved_console_perf_copy_test.go b/approved_console_perf_copy_test.go| index 65ef0e6b9..b7a147fb5 100644 |
| --- a/approved_console_perf_copy_test.go |
| +++ b/approved_console_perf_copy_test.go |
| @@ -31,13 +31,13 @@ const consoleBudgetCopyRecordPath = "docs/superpowers/plans/2026-10-28-console-b |
| var consolePerfCopyIDPattern = regexp.MustCompile(`^CPF-[0-9]+$`) |
| // consolePerfCopyIDs is the records' inventory, pinned: CPF-1 to CPF-11 |
| -// (plan 1) and CPF-20 to CPF-29 (the two-tier budget). |
| +// (plan 1) and CPF-20 to CPF-30 (the two-tier budget). |
| var consolePerfCopyIDs = func() []string { |
| - ids := make([]string, 0, 21) |
| + ids := make([]string, 0, 22) |
| for i := 1; i <= 11; i++ { |
| ids = append(ids, "CPF-"+strconv.Itoa(i)) |
| } |
| - for i := 20; i <= 29; i++ { |
| + for i := 20; i <= 30; i++ { |
| ids = append(ids, "CPF-"+strconv.Itoa(i)) |
| } |
| return ids |
| @@ -50,12 +50,14 @@ var consolePerfCopyIDs = func() []string { |
| // metadata and is never edited for this. |
| // |
| // CPF-2 and CPF-11 are retired: the two-tier budget replaced them with CPF-20 |
| -// and CPF-27, and their rows stay in the first record as history. |
| +// and CPF-27, and their rows stay in the first record as history. CPF-20 is |
| +// retired in turn by CPF-30 (it miscounted the window), its row kept as |
| +// history in the second record. |
| var consolePerfCopyBuilt = []string{ |
| "CPF-1", "CPF-3", "CPF-4", "CPF-5", "CPF-6", |
| "CPF-7", "CPF-8", "CPF-9", "CPF-10", |
| - "CPF-20", "CPF-21", "CPF-22", "CPF-23", "CPF-24", |
| - "CPF-25", "CPF-26", "CPF-27", "CPF-28", "CPF-29", |
| + "CPF-21", "CPF-22", "CPF-23", "CPF-24", |
| + "CPF-25", "CPF-26", "CPF-27", "CPF-28", "CPF-29", "CPF-30", |
| } |
| // consolePerfBuiltRows is entryBuiltRows (approved_asset_cache_copy_test.go) |
diff --git a/cmd/console/main.go b/cmd/console/main.go| index 9aee7b747..044004a13 100644 |
| --- a/cmd/console/main.go |
| +++ b/cmd/console/main.go |
| @@ -358,7 +358,12 @@ func serve() { |
| } |
| hostClaim := hostClaimEnabled(os.Getenv) |
| st := openServeDB(hostClaim) |
| - storeProvisioner, storeDeployment := storeBackend() |
| + // One request-timing ring for the whole console: the server records |
| + // into it, and the S3 clients below count their calls into it, so a |
| + // page's S3 requests are charged to the page that made them (and a |
| + // background job's to the job). |
| + rec := new(perf.Recorder) |
| + storeProvisioner, storeDeployment := storeBackend(rec) |
| storeScanner, seedAntivirus := storeScannerFor(storeDeployment) |
| catalog, err := planCatalog() |
| if err != nil { |
| @@ -401,10 +406,6 @@ func serve() { |
| return mail.NewAWSProvisioner(ctx, region, mailBoundary) |
| } |
| mailProvisioner, dnsWriter := mailBackends(mailDep, newMailProvisioner, dnsrec.NewRoute53Writer) |
| - // One request-timing ring for the whole console: the server records |
| - // into it, and the S3 clients below count their calls into it, so a |
| - // page's S3 requests are charged to the page that made them. |
| - rec := new(perf.Recorder) |
| // One release.Store, named, because the senders sweep below needs the |
| // same one the server got. |
| rel := openStore(rec) |
| @@ -939,7 +940,7 @@ func appsDomain() string { |
| // did not choose, and the RECORD would then say that is where the app's data |
| // lives. CARLOS_STORE_ENDPOINT stays optional: an empty endpoint is what |
| // "real AWS S3" means (objstore.NewAWSProvisioner). |
| -func storeBackend() (objstore.Provisioner, objstore.Deployment) { |
| +func storeBackend(rec *perf.Recorder) (objstore.Provisioner, objstore.Deployment) { |
| backend := strings.TrimSpace(os.Getenv("CARLOS_STORE_BACKEND")) |
| if backend == "" { |
| return nil, objstore.Deployment{} |
| @@ -978,7 +979,7 @@ func storeBackend() (objstore.Provisioner, objstore.Deployment) { |
| log.Fatal("console: CARLOS_STORE_BACKEND is set — also set CARLOS_STORE_USER_BOUNDARY (the permissions-boundary policy ARN store users are created under; infra/modules/region-host outputs it as store_user_boundary_arn)") |
| } |
| endpoint := strings.TrimSpace(os.Getenv("CARLOS_STORE_ENDPOINT")) |
| - p, err := objstore.NewAWSProvisioner(context.Background(), region, endpoint, boundary) |
| + p, err := objstore.NewAWSProvisionerWith(context.Background(), region, endpoint, boundary, console.TimeS3HTTP(rec)) |
| if err != nil { |
| log.Fatal(err) |
| } |
diff --git a/docs/superpowers/notes/census-proposal-console-budget-cold-warm.md b/docs/superpowers/notes/census-proposal-console-budget-cold-warm.md| new file mode 100644 |
| index 000000000..00618a0ee |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-console-budget-cold-warm.md |
| @@ -0,0 +1,11 @@ |
| +# Census approval: console-budget-cold-warm |
| + |
| +Ruling `census-ruling-console-budget-cold-warm`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +Envelopes re-pinned: `internal/objstore`. |
| + |
| +Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| + |
| +Seal: `886863e79986b005cf52aa11445a49c1bbc3fb9b55bce25915fc21d0e65f1b7f` → `886863e79986b005cf52aa11445a49c1bbc3fb9b55bce25915fc21d0e65f1b7f`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-console-budget-cold-warm.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/plans/2026-10-28-console-budget-copy.md b/docs/superpowers/plans/2026-10-28-console-budget-copy.md| index 16f29a0ff..31d383671 100644 |
| --- a/docs/superpowers/plans/2026-10-28-console-budget-copy.md |
| +++ b/docs/superpowers/plans/2026-10-28-console-budget-copy.md |
| @@ -24,6 +24,14 @@ Luna's review is `LUNA-COPY-REVIEW-CONSOLE-BUDGET.md` (brief |
| CPF-27, CPF-29), none flagged, 6 left alone. Every row below is approved by |
| delegation to Luna, 2026-10-28, with Luna's text applied verbatim. |
| +Retired the same day: CPF-20 said "the last 2,048 page requests", but the |
| +console keeps its last 2,048 measured requests of every method, and the |
| +table shows the page requests among them (Astra's review, P2 5). CPF-30 |
| +replaces it; Luna's one-string check |
| +(`LUNA-COPY-BRIEF-CONSOLE-BUDGET-CPF30.md`, result |
| +`LUNA-COPY-REVIEW-CONSOLE-BUDGET-CPF30.md`) returned the draft unchanged. |
| +CPF-20's row stays as history and is no longer built. |
| + |
| Placeholders: `<n>` a whole number. |
| ## Console speed tables |
| @@ -31,6 +39,7 @@ Placeholders: `<n>` a whole number. |
| | id | file | text | status | |
| |---|---|---|---| |
| | CPF-20 | internal/console/templates/metrics.html | This page shows the time to first byte for the last 2,048 page requests. Warm requests make no S3 or box requests before the first byte. They use memory and the console database and have a 150 ms budget. Cold requests make at least one S3 or box request before the first byte and have a 500 ms budget. | approved | |
| +| CPF-30 | internal/console/templates/metrics.html | This page shows the time to first byte for page requests among the last 2,048 measured requests. Warm requests make no S3 or box requests before the first byte. They use memory and the console database and have a 150 ms budget. Cold requests make at least one S3 or box request before the first byte and have a 500 ms budget. | approved | |
| | CPF-21 | internal/console/templates/metrics.html | Warm | approved | |
| | CPF-22 | internal/console/templates/metrics.html | Cold | approved | |
| | CPF-23 | internal/console/templates/metrics.html | Over 500 ms | approved | |
diff --git a/docs/superpowers/plans/LUNA-COPY-BRIEF-CONSOLE-BUDGET-CPF30.md b/docs/superpowers/plans/LUNA-COPY-BRIEF-CONSOLE-BUDGET-CPF30.md| new file mode 100644 |
| index 000000000..32e83e67a |
| --- /dev/null |
| +++ b/docs/superpowers/plans/LUNA-COPY-BRIEF-CONSOLE-BUDGET-CPF30.md |
| @@ -0,0 +1,27 @@ |
| +# Copy check brief: one string, CPF-30 (2026-10-28) |
| + |
| +Paul delegated copy review for this work to you. Your wording is applied |
| +verbatim. |
| + |
| +A reviewer found a factual error in CPF-20, the sentence under "Console |
| +speed" on the operator-only metrics page |
| +(`docs/superpowers/plans/2026-10-28-console-budget-copy.md`). It says "the |
| +last 2,048 page requests", but the console keeps its last 2,048 measured |
| +requests of every method (pages and changes together), and the table shows |
| +the page requests (GET and HEAD) among them. Changes can push page requests |
| +out of the 2,048. |
| + |
| +CPF-30 replaces CPF-20. Draft: |
| + |
| +> This page shows the time to first byte for page requests among the last 2,048 measured requests. Warm requests make no S3 or box requests before the first byte. They use memory and the console database and have a 150 ms budget. Cold requests make at least one S3 or box request before the first byte and have a 500 ms budget. |
| + |
| +Only the first sentence changes; the rest is CPF-20 as you approved it. Keep |
| +the facts: page requests among the last 2,048 measured requests, warm 150 ms, |
| +cold 500 ms, S3 or box. |
| + |
| +House rules: no em dashes ever (a full stop and a new sentence instead); |
| +plain words; short; sentence case. |
| + |
| +Reply with only one line: the exact final text of CPF-30, then a second line |
| +starting "why:" with a few words. If the draft is already right, return it |
| +unchanged. |
diff --git a/docs/superpowers/plans/LUNA-COPY-REVIEW-CONSOLE-BUDGET-CPF30.md b/docs/superpowers/plans/LUNA-COPY-REVIEW-CONSOLE-BUDGET-CPF30.md| new file mode 100644 |
| index 000000000..be1154f68 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/LUNA-COPY-REVIEW-CONSOLE-BUDGET-CPF30.md |
| @@ -0,0 +1,2 @@ |
| +This page shows the time to first byte for page requests among the last 2,048 measured requests. Warm requests make no S3 or box requests before the first byte. They use memory and the console database and have a 150 ms budget. Cold requests make at least one S3 or box request before the first byte and have a 500 ms budget. |
| +why: Fixes the request-count scope. |
| \ No newline at end of file |
diff --git a/internal/console/economicspass.go b/internal/console/economicspass.go| index 3b4711d7b..df29337b8 100644 |
| --- a/internal/console/economicspass.go |
| +++ b/internal/console/economicspass.go |
| @@ -21,6 +21,7 @@ import ( |
| "github.com/carlosframework/platform/internal/economics" |
| "github.com/carlosframework/platform/internal/metrics" |
| "github.com/carlosframework/platform/internal/objstore" |
| + "github.com/carlosframework/platform/internal/perf" |
| "github.com/carlosframework/platform/internal/provision" |
| "github.com/carlosframework/platform/internal/registry" |
| "github.com/carlosframework/platform/internal/release" |
| @@ -1182,18 +1183,21 @@ func (s *Server) sizeStore(ctx context.Context, p *objstore.Provisioned) (int64, |
| if s.storeSizer != nil { |
| return s.storeSizer(ctx, p) |
| } |
| - return sizeProvisionedStore(ctx, p) |
| + return sizeProvisionedStore(ctx, p, s.perf) |
| } |
| // sizeProvisionedStore sums a tenant object store's live bytes with a |
| // paginated ListObjectsV2, using an S3 client built exactly the way |
| // objstore.NewAWSProvisioner builds its own (objstore.S3ClientFor: region + |
| -// optional endpoint override for S3-compatible backends). |
| -func sizeProvisionedStore(ctx context.Context, p *objstore.Provisioned) (int64, error) { |
| - client, err := objstore.S3ClientFor(ctx, p.Region, p.Endpoint) |
| +// optional endpoint override for S3-compatible backends). The client is |
| +// timed into rec (TimeS3Client), so each listing page counts on the |
| +// economics run that made it. |
| +func sizeProvisionedStore(ctx context.Context, p *objstore.Provisioned, rec *perf.Recorder) (int64, error) { |
| + bare, err := objstore.S3ClientFor(ctx, p.Region, p.Endpoint) |
| if err != nil { |
| return 0, err |
| } |
| + client := TimeS3Client(bare, rec) |
| var total int64 |
| var token *string |
| for { |
diff --git a/internal/console/jobs_s3_test.go b/internal/console/jobs_s3_test.go| index 5155bba3c..ac01e4aa7 100644 |
| --- a/internal/console/jobs_s3_test.go |
| +++ b/internal/console/jobs_s3_test.go |
| @@ -2,14 +2,21 @@ package console |
| import ( |
| "context" |
| + "encoding/json" |
| "fmt" |
| + "io" |
| "net/http" |
| + "net/http/httptest" |
| "os" |
| "slices" |
| "strconv" |
| "strings" |
| + "sync/atomic" |
| "testing" |
| "time" |
| + |
| + "github.com/carlosframework/platform/internal/objstore" |
| + "github.com/carlosframework/platform/internal/usage" |
| ) |
| // One run of the plan limits pass through the job registry, on the perf |
| @@ -235,3 +242,106 @@ func perfKeyFamily(key string) string { |
| } |
| return strings.Join(seg, "/") |
| } |
| + |
| +// fakeTenantS3 is a tenant's provisioned bucket behind an S3-compatible |
| +// endpoint: every ListObjectsV2 is answered from pages, two objects of 100 |
| +// bytes a page, truncated until the last, and every HTTP request it gets is |
| +// counted. |
| +type fakeTenantS3 struct { |
| + pages int |
| + requests atomic.Int64 |
| +} |
| + |
| +func (f *fakeTenantS3) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
| + f.requests.Add(1) |
| + page := 0 |
| + if tok := r.URL.Query().Get("continuation-token"); tok != "" { |
| + page, _ = strconv.Atoi(strings.TrimPrefix(tok, "p")) |
| + } |
| + var b strings.Builder |
| + b.WriteString(`<?xml version="1.0" encoding="UTF-8"?><ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>tenant</Name><KeyCount>2</KeyCount><MaxKeys>2</MaxKeys>`) |
| + if page+1 < f.pages { |
| + fmt.Fprintf(&b, `<IsTruncated>true</IsTruncated><NextContinuationToken>p%d</NextContinuationToken>`, page+1) |
| + } else { |
| + b.WriteString(`<IsTruncated>false</IsTruncated>`) |
| + } |
| + for i := 0; i < 2; i++ { |
| + fmt.Fprintf(&b, `<Contents><Key>obj-%d-%d</Key><Size>100</Size><ETag>"e"</ETag><StorageClass>STANDARD</StorageClass></Contents>`, page, i) |
| + } |
| + b.WriteString(`</ListBucketResult>`) |
| + w.Header().Set("Content-Type", "application/xml") |
| + io.WriteString(w, b.String()) |
| +} |
| + |
| +// The economics pass sizes a tenant's provisioned bucket with its own S3 |
| +// client, and the scan pass lists one the same way. Both clients are the |
| +// console's and are timed: every HTTP request they send inside a job run |
| +// counts on that job, with the deployment store's, and none is lost or left |
| +// unattributed. Here the storage pass runs inside the economics job over a |
| +// bucket of three listing pages, and the job's S3 total must equal the |
| +// requests the tenant endpoint and the deployment fake actually received. |
| +func TestTenantBucketListingsCountOnTheJob(t *testing.T) { |
| + perfCaptureLogs(t) |
| + lat := &perfLatency{} |
| + fx := newConsoleFixtureWith(t, consoleFixtureOptions{WithKey: true, S3: lat, AppClient: lat.AppClient()}) |
| + tenant := &fakeTenantS3{pages: 3} |
| + ts := httptest.NewServer(tenant) |
| + t.Cleanup(ts.Close) |
| + now := time.Now() |
| + prov := &objstore.Provisioned{Bucket: "carlos-bab-kass", Region: "us-east-1", Endpoint: ts.URL, IAMUser: "u", KeyID: "K", At: now} |
| + if _, err := objstore.PutIn(context.Background(), fx.rel, fx.sqid, "kass", "", &objstore.Record{ |
| + Declared: &objstore.Declared{EnvPrefix: "CARLOS_STORE", At: now, By: "paul@keymail.dev"}, |
| + Grant: &objstore.GrantBlock{Backend: "aws", Bucket: prov.Bucket, Source: objstore.GrantSourceOperator, At: now, By: "op"}, |
| + Provisioned: prov, |
| + }, ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + |
| + s0, _ := lat.Calls() |
| + b0 := fx.srv.PerfBackground()["s3"] |
| + date := usage.DayOf(now) |
| + if err := fx.srv.jobs.Run(context.Background(), "StartEconomicsPass", func(ctx context.Context) error { |
| + return fx.srv.storagePass(ctx, date) |
| + }); err != nil { |
| + t.Fatalf("storage pass: %v", err) |
| + } |
| + s1, _ := lat.Calls() |
| + st, _ := jobStatusOf(fx.srv, "StartEconomicsPass") |
| + if got := tenant.requests.Load(); got != 3 { |
| + t.Fatalf("the tenant endpoint got %d requests, want its 3 listing pages", got) |
| + } |
| + if want := tenant.requests.Load() + (s1 - s0); st.Calls["s3"] != want || st.RunCalls["s3"] != want { |
| + t.Errorf("economics job counted %d S3 requests (finished runs %d); the tenant endpoint got %d and the deployment fake %d, want %d", |
| + st.Calls["s3"], st.RunCalls["s3"], tenant.requests.Load(), s1-s0, want) |
| + } |
| + if bg := fx.srv.PerfBackground()["s3"] - b0; bg != 0 { |
| + t.Errorf("the run left %d S3 requests unattributed, want none", bg) |
| + } |
| + raw, _, err := fx.rel.Get(context.Background(), usage.StorageDayKey(date)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var day usage.StorageDay |
| + if err := json.Unmarshal(raw, &day); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got := day.Apps[fx.sqid+"/kass"].StoreBytes; got != 600 { |
| + t.Errorf("kass store bytes = %d, want 600 (three pages of two 100-byte objects)", got) |
| + } |
| + |
| + // The scan pass's lister: one page, one request, on the scan job. |
| + tenant.requests.Store(0) |
| + if err := fx.srv.jobs.Run(context.Background(), "StartScanPass", func(ctx context.Context) error { |
| + l, err := fx.srv.storeLister(ctx, prov) |
| + if err != nil { |
| + return err |
| + } |
| + _, _, err = l.ListPage(ctx, prov.Bucket, "", 2) |
| + return err |
| + }); err != nil { |
| + t.Fatalf("scan listing: %v", err) |
| + } |
| + if st, _ := jobStatusOf(fx.srv, "StartScanPass"); st.Calls["s3"] != 1 || tenant.requests.Load() != 1 { |
| + t.Errorf("scan job counted %d S3 requests, the tenant endpoint got %d; want 1 and 1", st.Calls["s3"], tenant.requests.Load()) |
| + } |
| +} |
diff --git a/internal/console/opshots_test.go b/internal/console/opshots_test.go| index af1e02e20..d414a296e 100644 |
| --- a/internal/console/opshots_test.go |
| +++ b/internal/console/opshots_test.go |
| @@ -65,10 +65,12 @@ func seedOperatorShotExtras(t *testing.T, fx *consoleFixture) { |
| } |
| // TestOperatorScreenshots is a review aid, not acceptance: it renders every |
| -// operator page on the seeded world at 1280 and 390 px wide, light and |
| -// dark, with headless Chromium, into $CONSOLE_OPS_SHOTS_DIR as |
| -// <page>-<width>-<scheme>.png. It is skipped unless that directory is set |
| -// and chromium is on the PATH. |
| +// operator page on the seeded world at 1280, 1024 (the rail beside a |
| +// narrow main column) and 390 px wide, light and dark, with headless |
| +// Chromium, into $CONSOLE_OPS_SHOTS_DIR as <page>-<width>-<scheme>.png. |
| +// $CONSOLE_OPS_SHOTS_PAGES, a comma-separated list of shot names, narrows |
| +// it to those pages. It is skipped unless that directory is set and |
| +// chromium is on the PATH. |
| // |
| // Two servers on 127.0.0.1 stand in front of the console: each adds Paul's |
| // session cookie to every request, and the dark one also marks every HTML |
| @@ -131,8 +133,17 @@ func TestOperatorScreenshots(t *testing.T) { |
| srv *httptest.Server |
| }{{"light", front(false)}, {"dark", front(true)}} |
| + only := map[string]bool{} |
| + for _, name := range strings.Split(os.Getenv("CONSOLE_OPS_SHOTS_PAGES"), ",") { |
| + if name = strings.TrimSpace(name); name != "" { |
| + only[name] = true |
| + } |
| + } |
| for _, pg := range opShotPages { |
| - for _, width := range []int{1280, 390} { |
| + if len(only) > 0 && !only[pg.name] { |
| + continue |
| + } |
| + for _, width := range []int{1280, 1024, 390} { |
| for _, sc := range schemes { |
| out := filepath.Join(dir, pg.name+"-"+strconv.Itoa(width)+"-"+sc.name+".png") |
| ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) |
diff --git a/internal/console/perfs3.go b/internal/console/perfs3.go| index 9c753d039..d13c6be26 100644 |
| --- a/internal/console/perfs3.go |
| +++ b/internal/console/perfs3.go |
| @@ -18,8 +18,22 @@ import ( |
| // release.VersionCandidates), and a wrapper would change those answers. |
| // Swapping the client changes no method set and sends no request. |
| func TimeS3Store(s *release.S3Store, rec *perf.Recorder) *release.S3Store { |
| - s.Client = awss3.New(s.Client.Options(), func(o *awss3.Options) { |
| - o.HTTPClient = perf.TimeDoer(o.HTTPClient, "s3", rec) |
| - }) |
| + s.Client = TimeS3Client(s.Client, rec) |
| return s |
| } |
| + |
| +// TimeS3Client is c with its HTTP doer timed and counted as TimeS3Store's |
| +// is: each request is one "s3" span and count on the console request whose |
| +// context it carries, else on the job run's (jobs.go), else one background |
| +// count in rec. It is for the S3 clients the console builds outside the |
| +// deployment store: the tenant-bucket sizer and lister (economics and |
| +// scan passes) and the store provisioner. c is not changed. |
| +func TimeS3Client(c *awss3.Client, rec *perf.Recorder) *awss3.Client { |
| + return awss3.New(c.Options(), func(o *awss3.Options) { o.HTTPClient = TimeS3HTTP(rec)(o.HTTPClient) }) |
| +} |
| + |
| +// TimeS3HTTP wraps an S3 client's HTTP doer the same way, for a constructor |
| +// that takes the wrap rather than the client (objstore.NewAWSProvisionerWith). |
| +func TimeS3HTTP(rec *perf.Recorder) func(awss3.HTTPClient) awss3.HTTPClient { |
| + return func(d awss3.HTTPClient) awss3.HTTPClient { return perf.TimeDoer(d, "s3", rec) } |
| +} |
diff --git a/internal/console/perfspeed.go b/internal/console/perfspeed.go| index 6080edb51..c831c426e 100644 |
| --- a/internal/console/perfspeed.go |
| +++ b/internal/console/perfspeed.go |
| @@ -53,13 +53,17 @@ func consoleSpeedRows(groups []perf.Group) []consoleSpeedRow { |
| } |
| // consoleSpeedTables splits the rows into the two tables: pages (GET and |
| -// HEAD, judged warm or cold on their first byte) and changes (every other |
| -// method, a write judged from its body read). Each keeps the rows' order. |
| +// HEAD, judged warm or cold on their first byte) and changes (POST, PUT, |
| +// PATCH and DELETE, judged from the body read against perf.WriteBudget). |
| +// Every other method (OPTIONS, CONNECT, OTHER) has no budget, so it is in |
| +// neither table rather than shown under a budget it is not held to. Each |
| +// table keeps the rows' order. |
| func consoleSpeedTables(groups []perf.Group) (pages, changes []consoleSpeedRow) { |
| for _, row := range consoleSpeedRows(groups) { |
| - if row.Method == http.MethodGet || row.Method == http.MethodHead { |
| + switch row.Method { |
| + case http.MethodGet, http.MethodHead: |
| pages = append(pages, row) |
| - } else { |
| + case http.MethodPost, http.MethodPut, http.MethodPatch, http.MethodDelete: |
| changes = append(changes, row) |
| } |
| } |
diff --git a/internal/console/perfspeed_test.go b/internal/console/perfspeed_test.go| index 1174230fd..525198718 100644 |
| --- a/internal/console/perfspeed_test.go |
| +++ b/internal/console/perfspeed_test.go |
| @@ -148,12 +148,19 @@ func TestFleetMetricsConsoleSpeedEmptyState(t *testing.T) { |
| } |
| } |
| -// The pages table holds GET and HEAD, the changes table everything else, |
| -// each in the groups' order; a change row carries its over-budget count. |
| +// The pages table holds GET and HEAD, the changes table POST, PUT, PATCH |
| +// and DELETE, each in the groups' order; a change row carries its |
| +// over-budget count. OPTIONS, CONNECT and OTHER have no budget and are in |
| +// neither table. |
| func TestConsoleSpeedTablesSplitPagesAndChanges(t *testing.T) { |
| pages, changes := consoleSpeedTables([]perf.Group{ |
| {Screen: "POST /a", Method: "POST", P95: 900, Requests: 2, Writes: 2, WriteOver: 1, Over: 1}, |
| + {Screen: "/x", Method: "OPTIONS", P95: 900, Requests: 1}, |
| {Screen: "GET /b", Method: "GET", P95: 600, Requests: 2, Cold: 2, ColdOver: 1, Over: 1}, |
| + {Screen: "/x", Method: "CONNECT", P95: 50, Requests: 1}, |
| + {Screen: "/c", Method: "PUT", P95: 40, Requests: 1, Writes: 1}, |
| + {Screen: "/c", Method: "PATCH", P95: 30, Requests: 1, Writes: 1}, |
| + {Screen: "unmatched", Method: "OTHER", P95: 20, Requests: 1}, |
| {Screen: "/c", Method: "DELETE", P95: 10, Requests: 1, Writes: 1}, |
| {Screen: "GET /b", Method: "HEAD", P95: 1, Requests: 1, Warm: 1}, |
| }) |
| @@ -168,7 +175,7 @@ func TestConsoleSpeedTablesSplitPagesAndChanges(t *testing.T) { |
| for _, r := range changes { |
| got = append(got, r.Route) |
| } |
| - if want := []string{"POST /a", "DELETE /c"}; !slices.Equal(got, want) { |
| + if want := []string{"POST /a", "PUT /c", "PATCH /c", "DELETE /c"}; !slices.Equal(got, want) { |
| t.Errorf("changes = %q, want %q", got, want) |
| } |
| if pages[0].Cold != 2 || pages[0].ColdOver != 1 || changes[0].WriteOver != 1 { |
| @@ -177,11 +184,11 @@ func TestConsoleSpeedTablesSplitPagesAndChanges(t *testing.T) { |
| } |
| // On the page: a write is a row of the Changes table, not of the pages |
| -// table, and a GET's row counts it warm. |
| +// table, and an OPTIONS, which has no budget, is in neither. |
| func TestFleetMetricsListsWritesUnderChanges(t *testing.T) { |
| fx := newConsoleFixture(t) |
| c := operatorBrowser(t, fx) |
| - for _, m := range []string{http.MethodGet, http.MethodPost} { |
| + for _, m := range []string{http.MethodGet, http.MethodPost, http.MethodOptions} { |
| req, _ := http.NewRequest(m, fx.ts.URL+"/fleet/architecture", nil) |
| resp, err := c.Do(req) |
| if err != nil { |
| @@ -204,6 +211,9 @@ func TestFleetMetricsListsWritesUnderChanges(t *testing.T) { |
| if !strings.Contains(changes, "<td>POST /fleet/architecture</td>") || strings.Contains(changes, "<td>GET /fleet/architecture</td>") { |
| t.Errorf("the Changes table should list the POST and not the GET:\n%s", changes) |
| } |
| + if strings.Contains(body, "<td>OPTIONS /fleet/architecture</td>") { |
| + t.Errorf("/fleet/metrics lists the OPTIONS, which has no budget:\n%s", body) |
| + } |
| if !strings.Contains(pages, "<th co-m-hide>Warm</th><th>Over 150 ms</th><th co-m-hide>Cold</th><th>Over 500 ms</th>") { |
| t.Errorf("the pages table lacks the warm and cold columns:\n%s", pages) |
| } |
diff --git a/internal/console/scanpass.go b/internal/console/scanpass.go| index a606fba31..a82b48068 100644 |
| --- a/internal/console/scanpass.go |
| +++ b/internal/console/scanpass.go |
| @@ -251,7 +251,9 @@ func (s *Server) storeIsDue(ctx context.Context, rec *objstore.Record, acct, app |
| } |
| // storeLister routes through the test seam or builds a real S3 lister, the |
| -// way sizeStore already does for the storage sweep. |
| +// way sizeStore already does for the storage sweep. The client is timed |
| +// into the console's recorder (TimeS3Client), so the scan run's listings |
| +// count on its job. |
| func (s *Server) storeLister(ctx context.Context, p *objstore.Provisioned) (objstore.ObjectLister, error) { |
| if s.storeListerFor != nil { |
| return s.storeListerFor(ctx, p) |
| @@ -260,7 +262,7 @@ func (s *Server) storeLister(ctx context.Context, p *objstore.Provisioned) (objs |
| if err != nil { |
| return nil, err |
| } |
| - return objstore.NewObjectLister(client), nil |
| + return objstore.NewObjectLister(TimeS3Client(client, s.perf)), nil |
| } |
| // errNoScanner is what the doors return when scanning was never configured. |
diff --git a/internal/console/static/ops.css b/internal/console/static/ops.css| index 69437275e..ffab9a27c 100644 |
| --- a/internal/console/static/ops.css |
| +++ b/internal/console/static/ops.css |
| @@ -54,6 +54,22 @@ |
| [co-cols="jobs"] > [rst-lrow] > :nth-child(n+3) { display: none; } |
| } |
| +/* The jobs list is six columns, about 56rem with Rastrillo's gaps and |
| + padding: wider than the main column beside the 15rem rail on a 1,024 px |
| + window. So the card is a size container, and when it is narrower than |
| + that (and the window is wider than a phone, whose two-cell rule above |
| + applies), each row keeps its five short cells on one line and the note |
| + takes a line of its own under them, or none when it is empty. */ |
| +[co-cols="jobs"] { container-type: inline-size; } |
| +@media (min-width: 801px) { |
| + @container (max-width: 56rem) { |
| + [co-cols="jobs"] > [rst-lrow] { grid-template-columns: minmax(8rem, 1fr) 8rem 6.5rem 5.5rem 6.5rem; } |
| + [co-cols="jobs"] > [rst-lrow] > :nth-child(6) { grid-column: 1 / -1; } |
| + [co-cols="jobs"] > [rst-lrow] > :nth-child(6):empty, |
| + [co-cols="jobs"] > [rst-lrow="head"] > :nth-child(6) { display: none; } |
| + } |
| +} |
| + |
| /* A page's view switch under a stats band: the band has no margin of its |
| own, so the switch keeps the gap a section head would. */ |
| [co-tabs] { margin-block-start: 1.5rem; } |
diff --git a/internal/console/templates/metrics.html b/internal/console/templates/metrics.html| index 844921bf8..4a3399886 100644 |
| --- a/internal/console/templates/metrics.html |
| +++ b/internal/console/templates/metrics.html |
| @@ -54,7 +54,7 @@ |
| {{end}} |
| <section co-section aria-labelledby="console-speed"> |
| <div rst-box-head><h2 id="console-speed">Console speed</h2></div> |
| -<p co-note>This page shows the time to first byte for the last 2,048 page requests. Warm requests make no S3 or box requests before the first byte. They use memory and the console database and have a 150 ms budget. Cold requests make at least one S3 or box request before the first byte and have a 500 ms budget.</p> |
| +<p co-note>This page shows the time to first byte for page requests among the last 2,048 measured requests. Warm requests make no S3 or box requests before the first byte. They use memory and the console database and have a 150 ms budget. Cold requests make at least one S3 or box request before the first byte and have a 500 ms budget.</p> |
| {{if .ConsoleSpeed}} |
| <div rst-card class="co-table-wrap"> |
| <table co-table> |
diff --git a/internal/objstore/aws.go b/internal/objstore/aws.go| index bd46ea76e..341b0295f 100644 |
| --- a/internal/objstore/aws.go |
| +++ b/internal/objstore/aws.go |
| @@ -79,10 +79,22 @@ var _ Provisioner = (*awsProvisioner)(nil) |
| // twin, so a non-AWS backend (endpoint set, "aws" backend) still means |
| // IAM-against-real-AWS in v1 — there is nothing else for it to point at. |
| func NewAWSProvisioner(ctx context.Context, region, endpoint, boundary string) (Provisioner, error) { |
| + return NewAWSProvisionerWith(ctx, region, endpoint, boundary, nil) |
| +} |
| + |
| +// NewAWSProvisionerWith is NewAWSProvisioner with wrap applied to its S3 |
| +// client's HTTP doer; a nil wrap leaves the client exactly as |
| +// NewAWSProvisioner builds it. The console passes a wrap that times and |
| +// counts each S3 request (console.TimeS3HTTP). The IAM client is not |
| +// wrapped. |
| +func NewAWSProvisionerWith(ctx context.Context, region, endpoint, boundary string, wrap func(awss3.HTTPClient) awss3.HTTPClient) (Provisioner, error) { |
| s3Client, err := S3ClientFor(ctx, region, endpoint) |
| if err != nil { |
| return nil, err |
| } |
| + if wrap != nil { |
| + s3Client = awss3.New(s3Client.Options(), func(o *awss3.Options) { o.HTTPClient = wrap(o.HTTPClient) }) |
| + } |
| cfg, err := rootaws.LoadDefaultConfig(ctx, awsconfig.WithRegion(region)) |
| if err != nil { |
| return nil, fmt.Errorf("objstore: load aws config: %w", err) |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index b156ee056..a2f00817e 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -23,3 +23,4 @@ plan14-root-reads-team-scoped-credentials.tsv b6f3a369ca91563f1d28a9855b242125fa |
| plan14-root-reads-rootfs-apps-3-release.tsv 2cced1b359b64855bacc94c64e0370e6b78cfe2c4947d6d4944915b3a05c6a7c |
| plan14-root-reads-rootfs-overlap-demand.tsv 2cced1b359b64855bacc94c64e0370e6b78cfe2c4947d6d4944915b3a05c6a7c |
| plan14-root-reads-edge-roll-blip.tsv 886863e79986b005cf52aa11445a49c1bbc3fb9b55bce25915fc21d0e65f1b7f |
| +plan14-root-reads-console-budget-cold-warm.tsv 886863e79986b005cf52aa11445a49c1bbc3fb9b55bce25915fc21d0e65f1b7f |
diff --git a/internal/provision/testdata/plan14-root-reads-console-budget-cold-warm.tsv b/internal/provision/testdata/plan14-root-reads-console-budget-cold-warm.tsv| new file mode 100644 |
| index 000000000..c14890191 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-console-budget-cold-warm.tsv |
| @@ -0,0 +1,3 @@ |
| +# Census overlay console-budget-cold-warm, written by census-propose (#369). census-ruling-console-budget-cold-warm, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-console-budget-cold-warm.md. |
| +# 0 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@coverage internal/objstore 1448f98d6b252b1bf5b0ccabdf73857e86978647dedb53b87844847849e53924 |