Repository navigation
fix(gcp): size the boot disk by vCPU so GCP nodes pack workspaces - #2730
Conversation
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>
|
Warning Review limit reachedYou'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. View limit details
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. |
Merging this PR will not alter performance
Comparing Footnotes
|
SonarCloud flagged the duplicated stub (4.3% duplication on new code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
@coderabbitai review |
Action not completed
|



Summary
GCP nodes always got a 50 GB boot disk (
diskSizeGb = 50default inGcpProvider), 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_GBwas documented but never reached the provider.Slice 1 of 3 for SAM task 01M7D36PKX3YHK4CTW8T1F4YV4 ("make SAM actually use GCP first").
What changes:
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.gcpCatalog.bootDiskGbPerVcpu(1–256) andgcpCatalog.bootDiskMinGb(10–4096), resolved through the per-isolate admin settings cache byresolveGcpBootDiskPolicy(); everyGcpProviderthe API builds goes throughcreateGcpProviderForEnv()(6 construction sites).gcpOfferingsFromMachineTypes), the static catalog and its API fallback (applyGcpBootDiskPolicy), the pool candidateprovider_instance_disk_gb, andcreateVM. createVM precedence: explicitbootDiskSizeGb> the pool plan'sresources.diskGb(the candidate disk, so a plan made before a refresh still gets the disk its node row records) > policy.Balanced PD Capacityprices (SKU names andGiBy.mounit 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 logsgcp_price_table.no_boot_disk_prices.placement-authority.ts, owned by draft PR fix: retain committed compute catalogs and recover accepted wakes #2693, not edited here) compares the candidate'sprovider_instance_boot_disk_size_gbto the node's, and builds the reuse snapshot from the current candidate. This change therefore only movesprovider_instance_disk_gband 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).GCP_DISK_SIZE_GB(env.ts, .env.example, configuration.md, env-reference skill, runtime-tunables baseline) andDEFAULT_GCP_DISK_SIZE_GB.SSD quota worst case (regional
SSD_TOTAL_GB20,480 GB): Raphaël's pool hasmax_nodes = 8; 8 × t2d-standard-16 (largest default type, 320 GB) = 2,560 GB in one region. Independently, disk ≤ 20 GB × regionalCPUSquota (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 lintpnpm typecheckpnpm test— all packages green except one unrelated flaky web test on one run (AccountProjectsDialogunhandledwindow is not definedafter teardown; no web code changed; web passed on the other run). API suite run separately: see below.platform_settingsread per isolate per ≤60 s, shared with every other setting).Staging Verification (REQUIRED for all code changes — merge-blocking)
Staging Verification Evidence
On staging (smoke user
toWz…, Potato project), 2026-11-14: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_gbNULL throughout.01M7D5X04C54BZ6VJCB5D6WTMX(provider gcp) provisioned node01M7D5X7ZP4PDEAVP0X8NN9QFQ: node row disk 80, observed disk 80, heartbeat 14:06:42Z. At GCP (read-only reader):node-01m7d5x7zp4pdeavp0x8nn9qfqRUNNING, e2-standard-4, boot disk pd-balanced 80 GB.01M7D6D0PQ5NYF6Y8MWD5AZ3WBand01M7D6D4WXS6H4RE3WFAYVFJDB, each reserving 1 vCPU / 2 GB / 40,960 MB disk (the production default disk reservation), both ran on that node at once (workspaces01M7D6D5ZQ8SYR2RREB2CP5QTB,01M7D6DAKVSJ5D3Y9PJEBEFDHS): 81,920 MB reserved on an 80 GB disk. At the old 50 GB only one would fit. (An earlier attempt usedvmSize: large, whose legacy workload mapping reserves the whole machine — 4 vCPU / 80 GB — so a secondlargewas correctly refused; that is the legacy size mapping, not this change.)disabled, leftover tasks cancelled.GET /api/capacity-pools/defaults?ensure=true200, catalogGET /api/providers/catalog200, 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 Trace
resolveGcpBootDiskPolicy()(apps/api/src/services/gcp-provider-factory.ts) →createGcpProviderForEnv().GcpProvider.listInstanceOfferings()→gcpOfferingsFromMachineTypes()sizesdiskGbper type and addsgcpBootDiskHourlyPrice(); static fallback →getStaticProviderCatalogOfferings(provider, { gcpBootDiskPolicy }).ensureCandidatesForSource()→candidateValueForOffering()writesprovider_instance_disk_gb, preserves NULLprovider_instance_boot_disk_size_gb.resolveReusableNodeCapacitySnapshot()builds the snapshot from the current candidate →filterReusableNodesByCurrentAuthority()/buildPlacementAuthoritySqlPredicate()(unchanged).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
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
GcpProviderwas introduced with a fixeddiskSizeGb = 50constructor default, and the catalog advertised the same constant for every machine type;GCP_DISK_SIZE_GBwas 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.mdSpecialist Review Evidence
needs-human-reviewlabel added and merge deferred to human (N/A: all completed)GcpProviderclass; LOWs fixed;parseGcpUnitSkurename skipped (cosmetic)CodeRabbit Review Evidence
CodeRabbit Notes
Requested at 15:10:31Z by adding the
coderabbit-reviewlabel 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)
apps/api/src/services/provider-credentials.tsis over 500 lines; this PR changes it by +1 net line (call-site swaps), so it is not split here.Agent Preflight (Required)
Classification
External References
services.skus.list(https://cloud.google.com/billing/docs/reference/rest/v1/services.skus/list); live SKU descriptions for zonal and regional Balanced PD Capacity and unitGiBy.mowere read on 2026-11-14 with the read-only staging identity.instances.insertboot diskinitializeParams.diskSizeGb(https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert); existing usage ingcp-native-instance.ts.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, blogcloud-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