Skip to content

fix(gcp): size the boot disk by vCPU so GCP nodes pack workspaces - #2730

Merged
simple-agent-manager[bot] merged 9 commits into
mainfrom
sam/sam-actually-use-gcp-1f4yv4
Nov 14, 2026
Merged

simple-agent-manager[bot] merged 9 commits into
mainfrom
sam/sam-actually-use-gcp-1f4yv4

Conversation

@simple-agent-manager

@simple-agent-manager simple-agent-manager Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

GCP nodes always got a 50 GB boot disk (diskSizeGb = 50 default in GcpProvider), and the catalog advertised 50 GB, so a t2d-standard-8 (8 vCPU / 32 GB) admitted about one default workspace (40,960 MB disk reservation). Since 2026-11-11, SAM-project tasks refused running GCP nodes 29 times for "disk reservation budget would be exceeded" and 12 times for "disk pressure threshold reached"; each refusal provisioned another t2d-standard-8, three of them filled the 24-vCPU T2D quota, and new work fell back to Hetzner (ideas 01M76GEHBVB0EXG619ZAZCN327, 01M77QAMDKN1FSSFKMYJK63X22). GCP_DISK_SIZE_GB was documented but never reached the provider.

Slice 1 of 3 for SAM task 01M7D36PKX3YHK4CTW8T1F4YV4 ("make SAM actually use GCP first").

What changes:

  • One policy (gcpBootDiskSizeGb(), packages/providers/src/gcp-boot-disk.ts): max(minGb, gbPerVcpu × vCPUs), defaults 20 GB/vCPU and 50 GB floor. t2d-standard-8 → 160 GB, e2-standard-4 → 80 GB, ≤2 vCPU → 50 GB, 16 vCPU → 320 GB.
  • Admin settings, not env vars (policy 9017df94): gcpCatalog.bootDiskGbPerVcpu (1–256) and gcpCatalog.bootDiskMinGb (10–4096), resolved through the per-isolate admin settings cache by resolveGcpBootDiskPolicy(); every GcpProvider the API builds goes through createGcpProviderForEnv() (6 construction sites).
  • Everything agrees on the size: live catalog offerings (gcpOfferingsFromMachineTypes), the static catalog and its API fallback (applyGcpBootDiskPolicy), the pool candidate provider_instance_disk_gb, and createVM. createVM precedence: explicit bootDiskSizeGb > the pool plan's resources.diskGb (the candidate disk, so a plan made before a refresh still gets the disk its node row records) > policy.
  • Price includes the boot disk: the stored price table gains per-region zonal Balanced PD Capacity prices (SKU names and GiBy.mo unit read from the live Cloud Billing catalog on 2026-11-14). A table stored before this change is refreshed on the next cron tick rather than waiting out its TTL; a malformed disk map drops only disk prices; a refresh that finds no disk SKU logs gcp_price_table.no_boot_disk_prices.
  • Running nodes stay reusable. Placement authority (placement-authority.ts, owned by draft PR fix: retain committed compute catalogs and recover accepted wakes #2693, not edited here) compares the candidate's provider_instance_boot_disk_size_gb to the node's, and builds the reuse snapshot from the current candidate. This change therefore only moves provider_instance_disk_gb and leaves the boot-disk column NULL; a control test shows the node would be refused if the size were written to the boot-disk column instead. Nodes keep their own recorded capacity (50 GB).
  • Removed the dead GCP_DISK_SIZE_GB (env.ts, .env.example, configuration.md, env-reference skill, runtime-tunables baseline) and DEFAULT_GCP_DISK_SIZE_GB.

SSD quota worst case (regional SSD_TOTAL_GB 20,480 GB): Raphaël's pool has max_nodes = 8; 8 × t2d-standard-16 (largest default type, 320 GB) = 2,560 GB in one region. Independently, disk ≤ 20 GB × regional CPUS quota (200) = 4,000 GB.

Rollout note: candidates republish when a pool's catalog is refreshed (opening the pool settings, credential lifecycle), not on a timer, so production nodes keep getting the old 50 GB until each pool's next refresh.

Validation

  • pnpm lint
  • pnpm typecheck
  • pnpm test — all packages green except one unrelated flaky web test on one run (AccountProjectsDialog unhandled window is not defined after teardown; no web code changed; web passed on the other run). API suite run separately: see below.
  • Additional validation: discrimination checks — replacing the catalog sizing with a flat 50 reddened the API refresh tests (2) and the provider offering test; the boot-disk-column control proves the authority trap.
  • N/A candidate selection for sweeps: no sweep/cron/alarm selection changed. Per-request I/O: two admin setting reads per provider build, served by the per-isolate settings cache (one platform_settings read per isolate per ≤60 s, shared with every other setting).

Staging Verification (REQUIRED for all code changes — merge-blocking)

  • Staging deployment green — run 43601314454 (commit 03c2272) passed; final head redeployed in run 43604120643 (see evidence)
  • Live app verified via Playwright — token login on app.sammy.party, dashboard and Settings → Infrastructure at 1280×800 and 375×667: no horizontal overflow, 0 console errors
  • Existing workflows confirmed working — dashboard, settings, project list, task submit, workspace create/delete, node delete
  • New feature/fix verified on staging — see evidence
  • Infrastructure verification completed — a real GCP VM was provisioned, heartbeated, hosted workspaces, and was deleted (no cloud-init/VM-agent code changed; VM path exercised because the change sizes the VM)
  • Mobile and desktop verification notes added for UI changes (N/A: no UI changes; smoke at both sizes anyway)

Staging Verification Evidence

On staging (smoke user toWz…, Potato project), 2026-11-14:

  1. Catalog → candidates. GET /api/capacity-pools/defaults?ensure=true (200) republished every GCP workspace candidate at 14:01:45Z (D1): ≤2 vCPU types → 50 GB, *-standard-4 → 80, *-standard-8 → 160, *-standard-16 → 320; provider_instance_boot_disk_size_gb NULL throughout.
  2. Price includes the disk. e2-standard-4 europe-west1 = 158,390 µ$/h = Belgium E2 machine ≈ $0.1474/h + 80 GB × $0.10/GB-month ÷ 730 ≈ $0.0110/h. The pre-change stored price table had been refreshed by the cron right after deploy (old tables are due at once).
  3. Real VM. With one GCP candidate temporarily enabled (europe-west1-b e2-standard-4), task 01M7D5X04C54BZ6VJCB5D6WTMX (provider gcp) provisioned node 01M7D5X7ZP4PDEAVP0X8NN9QFQ: node row disk 80, observed disk 80, heartbeat 14:06:42Z. At GCP (read-only reader): node-01m7d5x7zp4pdeavp0x8nn9qfq RUNNING, e2-standard-4, boot disk pd-balanced 80 GB.
  4. Two 40 GB workspaces on one node. Tasks 01M7D6D0PQ5NYF6Y8MWD5AZ3WB and 01M7D6D4WXS6H4RE3WFAYVFJDB, each reserving 1 vCPU / 2 GB / 40,960 MB disk (the production default disk reservation), both ran on that node at once (workspaces 01M7D6D5ZQ8SYR2RREB2CP5QTB, 01M7D6DAKVSJ5D3Y9PJEBEFDHS): 81,920 MB reserved on an 80 GB disk. At the old 50 GB only one would fit. (An earlier attempt used vmSize: large, whose legacy workload mapping reserves the whole machine — 4 vCPU / 80 GB — so a second large was correctly refused; that is the legacy size mapping, not this change.)
  5. Cleanup. Workspaces and node deleted (deletionStatus confirmed; GCP lookup by instance ID finds nothing; D1 rows gone), candidate set back to disabled, leftover tasks cancelled.
  6. Final head. Run 43604120643 deployed head fe3e504 through "Deploy API Worker"; I cancelled the run while it sat in "Wait for container rollout completion", the step that is falsely timing out on a stale application-list version for every deploy today (prod run 43601089742; fix in task 01M7D6NKG8E8R7SFTEVTAVWS85), to free staging for that fix. The full staging workflow concluded success on run 43601314454 (head 03c2272); the later commits are a test-compat refactor and a shared constant. On fe3e504 (test-compat refactor of the factory + shared constants). After its API Worker step: GET /api/capacity-pools/defaults?ensure=true 200, catalog GET /api/providers/catalog 200, GCP candidates still at policy sizes (e2-medium 50, e2-standard-4 80, t2d-standard-8 160, n2d-standard-16 320), 0 live test nodes.

End-to-End Verification

  • Data flow traced from user input to final outcome with code path citations
  • Capability test exercises the complete happy path across system boundaries
  • All spec/doc assumptions about existing behavior verified against code
  • Gaps documented below

Data Flow Trace

  1. Admin setting → resolveGcpBootDiskPolicy() (apps/api/src/services/gcp-provider-factory.ts) → createGcpProviderForEnv().
  2. Catalog: GcpProvider.listInstanceOfferings() → gcpOfferingsFromMachineTypes() sizes diskGb per type and adds gcpBootDiskHourlyPrice(); static fallback → getStaticProviderCatalogOfferings(provider, { gcpBootDiskPolicy }).
  3. Publication: ensureCandidatesForSource() → candidateValueForOffering() writes provider_instance_disk_gb, preserves NULL provider_instance_boot_disk_size_gb.
  4. Reuse: resolveReusableNodeCapacitySnapshot() builds the snapshot from the current candidate → filterReusableNodesByCurrentAuthority() / buildPlacementAuthoritySqlPredicate() (unchanged).
  5. Provision: nativePlanFromRow() → applyNativePlanToVmConfig() (resources.diskGb = candidate disk) → GcpProvider.createVM() → defaultBootDiskSizeGb() → gcpBootDisk() insert body → observed hardware (gcpInstanceToObservedVM) → observedHardwareDbValues().

Tests: packages/providers/tests/unit/gcp-boot-disk-sizing.test.ts, apps/api/tests/unit/services/gcp-boot-disk-candidate-refresh.test.ts (real SQLite, real publication, real reuse authority), apps/api/tests/unit/services/gcp-boot-disk-admin-settings.test.ts, apps/api/tests/unit/services/gcp-price-table.test.ts.

Untested Gaps

  • The VM-agent-reported disk on a real node is checked on staging only (below), not in automated tests.

Post-Mortem

What broke

Running GCP nodes were refused for reuse on disk long before CPU or memory ran out, so SAM provisioned a new t2d-standard-8 per task, hit the 24-vCPU T2D quota after three, and fell back to Hetzner.

Root cause

GcpProvider was introduced with a fixed diskSizeGb = 50 constructor default, and the catalog advertised the same constant for every machine type; GCP_DISK_SIZE_GB was declared and documented but never wired.

Class of bug

A per-resource capacity dimension sized as a constant while the other dimensions scale with the machine, so the constant becomes the binding limit on large machines.

Why it wasn't caught

No test asserted the advertised disk of a large GCP offering, and placement refusals ("disk reservation budget would be exceeded") are recorded per task, not surfaced as a pool-level signal.

Process fix included in this PR

Docs (google-cloud.md) now state the disk policy, its precedence and how to size the SSD quota; the settings are admin-visible. No rule change: the existing rules 74/81 already cover "state the bound and its throughput"; the gap was the missing wiring.

Post-mortem file

tasks/archive/2026-11-14-gcp-boot-disk-scales-with-machine.md

Specialist Review Evidence

  • All local reviewers completed and findings addressed before merge
  • If any reviewer did NOT complete: needs-human-review label added and merge deferred to human (N/A: all completed)
Reviewer Status Outcome
task-completion-validator ADDRESSED WARN, 0 CRITICAL/HIGH. 2 MEDIUM (no test for lowering the policy; admin edit not shown reaching the candidate) fixed in 03c2272; LOW formatter churn reverted
cloudflare-specialist ADDRESSED 0 HIGH. 2 MEDIUM (old stored price table stays "fresh" without disk prices; empty disk map silent) fixed in 03c2272; LOW malformed disk map, outage test added
architecture-reviewer ADDRESSED 2 MEDIUM (static API fallback bypassed the policy; positional constructor) fixed in 03c2272/8434f597c — direct construction kept with a comment because tests substitute the GcpProvider class; LOWs fixed; parseGcpUnitSku rename skipped (cosmetic)
doc-sync-validator ADDRESSED 3 LOW doc fixes (blog price note, admin-settings rows, google-cloud precedence/quota/citation) in 03c2272

CodeRabbit Review Evidence

  • CodeRabbit requested after local review, staging if applicable, and CI gates passed
  • Waited about 15 minutes, or up to about 45 minutes in total while a review CodeRabbit had started was still in progress
  • Either CodeRabbit reviewed and no CodeRabbit feedback is unresolved, or it did not review and the observed outcome is recorded below

CodeRabbit Notes

Requested at 15:10:31Z by adding the coderabbit-review label once CI was green on 1003d20 (workflow run 43608746220 posted the request). CodeRabbit answered "Review limit reached — You've used all free OSS reviews for now" and "Action not completed — Review rate limited". No review arrived by 15:21Z; recorded and not blocking (rule 25).

Exceptions (If any)

  • Scope: apps/api/src/services/provider-credentials.ts is over 500 lines; this PR changes it by +1 net line (call-site swaps), so it is not split here.
  • Rationale: rule 18 split would be an unrelated refactor of credential resolution.
  • Expiration: next functional change to that file.

Agent Preflight (Required)

  • Preflight completed before code changes

Classification

  • external-api-change
  • cross-component-change
  • business-logic-change
  • public-surface-change
  • docs-sync-change
  • security-sensitive-change
  • ui-change
  • infra-change

External References

Codebase Impact Analysis

packages/shared (boot disk default constants), packages/providers (gcp-boot-disk, gcp, gcp-catalog, gcp-pricing, gcp-metadata, native-vm-config, types, index), apps/api (gcp-provider-factory, provider-credentials, provider-catalogs-build, default-capacity-source-credentials, gcp-price-table, admin-settings-gcp-catalog-definitions, env). Placement authority read but not changed.

Documentation & Specs

apps/www/src/content/docs/docs/guides/google-cloud.md, guides/admin-settings.md, reference/configuration.md, blog cloud-compute-pools-provider-fallback.md, .claude/skills/env-reference/SKILL.md, scripts/quality/runtime-tunables-baseline.json.

Constitution & Risk Check

Principle XI: the sizing numbers are admin settings with typed defaults and ranges, not hardcoded. Risks: (1) reuse of existing nodes after candidate republish — tested on real SQL in both directions; (2) settings outage — falls back to defaults, tested; (3) price table rollout — old tables refresh at once, tested.

🤖 Generated with Claude Code

raphaeltm and others added 8 commits November 14, 2026 13:22
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rice it

The GCP provider created every VM with a fixed 50 GB boot disk and the
catalog advertised 50 GB, so an 8-vCPU node admitted about one default
workspace and disk ran out before CPU or memory.

- gcpBootDiskSizeGb(): max(minGb, gbPerVcpu x vCPUs); admin settings
  gcpCatalog.bootDiskGbPerVcpu (20) and gcpCatalog.bootDiskMinGb (50)
- catalog offerings, static offerings and createVM share that policy;
  a pool plan's resources.diskGb (the candidate disk) decides the VM size
- offering price adds the region's pd-balanced capacity price
- every GcpProvider in the API is built by createGcpProviderForEnv()
- remove the dead GCP_DISK_SIZE_GB env var and DEFAULT_GCP_DISK_SIZE_GB

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…admin settings

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- route the static catalog fallback through the boot disk policy
- build GCP providers with createProvider (GcpProviderConfig gains catalog)
- refresh a stored price table that predates boot disk prices at once;
  warn when a refresh finds no disk prices; a malformed disk map drops
  only the disk prices
- drop unread catalogMetadata.bootDiskGb; revert formatter churn in
  native-vm-config.ts; import GcpBootDiskPolicy in GcpProviderConfig
- tests: lowering the policy keeps nodes reusable, an admin edit reaches
  the candidate row, settings outage falls back to defaults, static
  fallback follows the policy, old price tables refresh
- docs: precedence, refresh path, quota guidance; blog price note

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests that mock drizzle-orm or the providers package broke once
provider-credentials statically reached the admin settings registry.
Load the settings module on first use (as gcp-sts already is), move the
boot disk default constants to shared next to the other GCP defaults,
and keep constructing GcpProvider directly so tests that substitute the
class still intercept teardown and provisioning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… GB)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a7d0523 and 1003d20.

Files selected for processing: 33

  • .claude/skills/env-reference/SKILL.md
  • apps/api/.env.example
  • apps/api/src/env.ts
  • apps/api/src/services/admin-settings-gcp-catalog-definitions.ts
  • apps/api/src/services/default-capacity-source-credentials.ts
  • apps/api/src/services/gcp-price-table.ts
  • apps/api/src/services/gcp-provider-factory.ts
  • apps/api/src/services/provider-catalogs-build.ts
  • apps/api/src/services/provider-credentials.ts
  • apps/api/tests/helpers/gcp-compute-stub.ts
  • apps/api/tests/unit/services/gcp-boot-disk-admin-settings.test.ts
  • apps/api/tests/unit/services/gcp-boot-disk-candidate-refresh.test.ts
  • apps/api/tests/unit/services/gcp-price-table.test.ts
  • apps/www/src/content/blog/cloud-compute-pools-provider-fallback.md
  • apps/www/src/content/docs/docs/guides/admin-settings.md
  • apps/www/src/content/docs/docs/guides/google-cloud.md
  • apps/www/src/content/docs/docs/reference/configuration.md
  • packages/providers/src/gcp-boot-disk.ts
  • packages/providers/src/gcp-catalog.ts
  • packages/providers/src/gcp-metadata.ts
  • packages/providers/src/gcp-pricing.ts
  • packages/providers/src/gcp.ts
  • packages/providers/src/index.ts
  • packages/providers/src/native-vm-config.ts
  • packages/providers/src/types.ts
  • packages/providers/tests/unit/gcp-boot-disk-sizing.test.ts
  • packages/providers/tests/unit/gcp-boot-disk-type.test.ts
  • packages/providers/tests/unit/provider-native-vm-contract.test.ts
  • packages/shared/src/constants/hetzner.ts
  • packages/shared/src/constants/index.ts
  • packages/shared/src/constants/resource-defaults.ts
  • scripts/quality/runtime-tunables-baseline.json
  • tasks/archive/2026-11-14-gcp-boot-disk-scales-with-machine.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@codspeed

codspeed Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 5 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing sam/sam-actually-use-gcp-1f4yv4 (1003d20) with main (669293f)2

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports. ↩

  2. No successful run was found on main (a7d0523) during the generation of this report, so 669293f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

SonarCloud flagged the duplicated stub (4.3% duplication on new code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@simple-agent-manager simple-agent-manager Bot added the coderabbit-review Trigger CodeRabbit review for opt-in PRs label Nov 14, 2026
@raphaeltm

Copy link
Copy Markdown
Owner

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@simple-agent-manager
simple-agent-manager Bot merged commit 1d234cf into main Nov 14, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coderabbit-review Trigger CodeRabbit review for opt-in PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant