Repository navigation
fix(gcp): a regional quota refusal rules out only its bucket - #2737
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ask file Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t in the per-tier cap Review findings on slice 2: a GCP quota refusal with nothing left to try was recorded as 'no available capacity', and zone duplicates of one size could take every capped slot of a bucket so the smaller type that still fits was dropped. Tests: synchronous 403 producer, two-source scoping control, zone-duplicate cap, exhausted-bucket reason. 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 3 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. |
|
Owner
|
@coderabbitai review |
Action not completed
|
This was referenced Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
A GCP quota refusal now rules out only the quota bucket it names (metric + region), and the TaskRunner keeps trying the rest of Google Cloud — smaller types of that family, other families, other regions — before it falls back to the next provider. Slice 2 of SAM task 01M7D36PKX3YHK4CTW8T1F4YV4 ("make SAM actually use GCP first"); idea 01M77QAMDKN1FSSFKMYJK63X22.
Problem.
handleProvisioningAttemptFailure(step 2) treated anyquota_exceededas "this source refused" and jumped to the next provider tier. Production placement explanations (taskscron-1a732cc1…35bf,01M758A6F8BHWA5VHBB6N6KDYW,01M79S0WNAMWY7H5C8MDBNRNWH) show attempt 1 (gcp europe-west1-b t2d-standard-8) refused withQuota 'T2D_CPUS' exceeded. Limit: 24.0 in region europe-west1., attempts 2-8 not attempted, then Hetzner. 14 Hetzner VMs followed such a refusal while europe-west4 T2D (0/24), E2_CPUS (0/72) and smaller T2D types were unused. Separately, the 8-offerings-per-tier cut was filled by t2d alone underpack, so no other family was even in the plan.Change.
classifyGcpQuotaBucket()/gcpQuotaBucketCovers()(packages/providers/src/gcp-quota-buckets.ts): parse metric + region from GCP's message;<SERIES>_CPUSrules out the same family in the region needing ≥ the refused vCPUs; genericCPUSonly the refused family;SSD_TOTAL_GBdisks ≥ the refused disk; other regional metrics the region. A quota naming no region (CPUS_ALL_REGIONS) returns null → old behaviour (next tier).node-provisioning-core-quota.ts→node-provisioning-quota-descent.ts,QuotaRejection = hetzner-cores | gcp-bucket. Step 1 of the failure handler descends whenever an un-ruled-out offering remains in the tier; otherwise step 2 moves tiers as before.selectAcrossQuotaBuckets()(node-provisioning-exhaustion.ts): the per-tier cap is dealt round-robin across region+series buckets, distinct sizes before zone repeats, ranked order kept. A single-bucket source (every non-GCP provider) keeps exactly its best-ranked N as before.Consumers of the touched predicates (rule 67): failure-handler steps 1-4, the step loop's skip check,
buildProvisioningExhaustionPlan(one caller),classifyVmProviderCapacityError(Hetzner-only, unchanged, comment only),isProviderCreateRejectedBeforeVmIdentity(Hetzner-only, reviewed, intentionally not extended: a GCP quota refusal leaves the node row inerroranddiscardProviderRejectedNodedeletes it, the same path main took once per task for the tier fallback).Latency (rule 81): one refused create per attempt, at most
operations.provisioningAttemptsPerProviderTier(8) per tier. GCP reports a quota refusal on the insert operation within seconds; the hard bound is 8 × (insert + poll ≤operationPollTimeoutMs, 5 min). Typical: tens of seconds, instead of a new VM on another provider.Cooldown: considered, not built. Each concurrent task may pay up to the per-tier cap of refusals; a region-and-metric TTL cooldown would trim that but needs shared state whose TTL must track how fast quota frees as nodes are deleted. Not worth it at current volume (the 2026-11-12 burst was 7 tasks).
Validation
pnpm lint(changed packages clean; providers export order fixed)pnpm typecheck(exit 0)pnpm test: API 15,179 passed / 0 failed; providers 873 → 888 after rebase; after rebasing on fix(gcp): size the boot disk by vCPU so GCP nodes pack workspaces #2730 + fix(placement): compute pool decides VM provider and location #2731: TaskRunner, boot-disk refresh, placement-authority and pool-decides suites 1,821 passed; after rebasing on main 84d77aa (Reduce project event writes and retention FK scans #2734, Bound CI coverage pools and make lifecycle ties deterministic #2728, no overlap):tests/unit/durable-objects/1,779 passed, gcp-quota-buckets 10 passed, APItsc --noEmitcleanStaging Verification (REQUIRED for all code changes — merge-blocking)
Staging Verification Evidence (2026-11-14, staging at c0629d5, run 43620525214)
Smoke-user pool temporarily set to
fallback-chainwith only t2d-standard-16 enabled in europe-west1-b,europe-west1-c and europe-west4-a (reverted afterwards). Staging T2D_CPUS quota is 24 per region.
capacity-exhausted: "GCP quota T2D_CPUS in europe-west1 is used up forthis offering; trying smaller types of this family, other families and other regions before another
provider. Provider error: GCP operation failed: QUOTA_EXCEEDED: Quota 'T2D_CPUS' exceeded. Limit: 24.0 in
region europe-west1."
not-attempted: "Skipped: needs 16 vCPU, and GCP quota T2D_CPUS ineurope-west1 already rejected a 16-vCPU offering"
succeeded(node 01M7DJ5CG7MJSXPTNCPVMNSRGG).provisionNode+ D1 path: no node row left behind for the refused europe-west1 attempt (only the tworeal nodes existed), which answers the validator's MEDIUM about repeated descents.
freshly provisioned node, and the provisioner failed after 3 placement refusals instead of re-provisioning.
in
destroyingwith its GCP instance already gone (read-onlyaggregated/instancescheck), pool reverted toqueue(revision 78).UI Compliance Checklist (Required for UI changes)
N/A: no UI changes.
End-to-End Verification
handleNodeProvisioningwith errors from the realGcpProvider.createVMproducer; real GCP + D1 on staging)Data Flow Trace
GcpProvider.createVM→withGcpErrorCategory(quota_exceeded) →provisionNode→handleNodeProvisioning(node-provisioning-step.ts) →handleProvisioningAttemptFailure→quotaRejectionFor→classifyGcpQuotaBucket→recordQuotaExclusions/nextEligibleAttemptIndex→ step loop skip viaquotaExclusionReason→ next attempt; plan built bybuildProvisioningExhaustionPlan→selectAcrossQuotaBuckets.Untested Gaps
N/A: full flow covered by automated tests and the staging run above.
Post-Mortem (Required for bug fix PRs)
What broke
A GCP regional quota refusal sent work straight to Hetzner while other GCP regions, families and smaller types had quota.
Root cause
handleProvisioningAttemptFailuretreatedquota_exceededas "the whole source refused" (step 2), and the per-tier cap kept the 8 best-ranked offerings, all of one family underpack.Class of bug
An error category scoped wider than the condition it names (rule 72/74): a region-and-metric quota read as a provider-wide refusal.
Why it wasn't caught
The Hetzner core-quota descent existed, but GCP's regional quota was never mapped to a scope; tests asserted the old "skip the rest of GCP" behaviour.
Process fix included in this PR
The quota descent is now one mechanism for both providers (
node-provisioning-quota-descent.ts) with per-bucket reasons in the placement record, so a future quota shape is a classifier addition, not a new path. Docs: compute-pools guide.Post-mortem file
tasks/archive/2026-11-14-gcp-quota-bucket-descent.mdSpecialist Review Evidence
needs-human-reviewlabel added and merge deferred to human (N/A)CodeRabbit Review Evidence
CodeRabbit Notes
Requested 18:10:42Z via the
coderabbit-reviewlabel (workflow run 43625133835, success). CodeRabbit replied "Review limit reached" / "Review rate limited" (free OSS quota). No review arrived, so per rule 25 it is skipped and the PR merges on its remaining gates.Exceptions (If any)
Agent Preflight (Required)
Classification
External References
T2D_CPUS,CPUSandSSD_TOTAL_GB; the exact refusal wording was read from production placement records (Quota 'T2D_CPUS' exceeded. Limit: 24.0 in region europe-west1.) and staging regional quotas viaregions.get(read-only).Codebase Impact Analysis
packages/providers(gcp-quota-buckets, index),apps/apitask-runner provisioning (quota-descent, failure, exhaustion, step),apps/api/src/services/vm-admission-provider-capacity.ts(comment), docsapps/www/src/content/docs/docs/guides/compute-pools.md.Documentation & Specs
apps/www/src/content/docs/docs/guides/compute-pools.mdupdated; task filetasks/archive/2026-11-14-gcp-quota-bucket-descent.md.Constitution & Risk Check
Principle XI: the per-tier cap stays the existing admin setting
operations.provisioningAttemptsPerProviderTier; no new hardcoded limits. Risks: ambiguous creates (503/timeout) still fail fast (controls unchanged); Hetzner descent unchanged; worst-case latency bounded by the cap.🤖 Generated with Claude Code