Repository navigation
fix(cloud): pin the asia cell database pool in the same-cap plan validator - #21171
Conversation
…dator Raising `database_pool_max` from 10 to 16 for production-gce-c27, c28 and c29 made every same-cap roll of those three cells fail closed at plan validation. The cell startup template emits `ORCA_RELAY_DATABASE_POOL_MAX` only for a cell whose region differs from the root region or whose pool is off the default, so the asia cells carry that line while the us-central1 cells do not. The plan validator requires the before and after startup scripts to normalize to the same text, masking only the lines it independently pins to a reviewed value. The pool line was neither masked nor pinned, so the live template's `'10'` and the plan's `'16'` were read as unreviewed drift. The validator gains an optional `--database-pool-max`, accepted in `same-cap-cell` mode alone. When it is supplied the after-script must contain exactly that pool line and the line is masked from the equality check; when it is not supplied the after-script must contain no pool line at all. Masking without the pin would have removed the guard rather than moved it. The same-cap job resolves the expected pool next to the hard cap, cross-checks it against the committed `relay_gce_cells` map (asserting the default 10 for the us-central1 cells), and passes the flag to both validator invocations only for the cells that emit the line.
|
Opus review: GO (7/7 checks, no reproduced defects). Merge is deliberately held until the in-flight US same-cap roll finishes: this PR edits a TRUSTED_EVIDENCE_CODE_PATHS file, so landing it now would invalidate the sealed c7 canary authority and fail the remaining batches. Merge right after the US roll, before the Asia cells. |
|
This run was cancelled 🛑 The workflow was cancelled before completion. Please check the link below for details. |
📝 WalkthroughWalkthroughThe deployment workflow now derives database pool expectations per cell. The capacity-plan validator accepts and enforces Priority: ⬇️ Low Merge Risk: 🔵 Low · up to An unpinned cell can retain an unexpected database-pool setting when its startup script uses noncanonical indentation. Broaden pool-line detection before merging. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description is detailed and covers the change, reason, mechanism, testing, scope, and checklist. However, the required Linked Issue section says "N/A" even though the template requires an issue link. Full details: Docstring CoverageExplanation Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 4 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 79414b15-ff98-453f-9183-033b8a64d08f
📒 Files selected for processing (5)
.github/workflows/cloud-deploy-relay-production-same-cap-job.ymlcloud/dev/scripts/relay-regional-rehome-workflow.test.mjscloud/dev/scripts/relay-same-cap-script-census.test.mjscloud/dev/scripts/validate-relay-capacity-plan.mjscloud/dev/scripts/validate-relay-capacity-plan.test.mjs
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| const REHOME_CONFIG = | ||
| /^ printf 'ORCA_RELAY_REHOME_(?:DIRECTOR_SERVICE_ACCOUNT|AUDIENCE)=%s\\n' '[^'\n]+'$/ | ||
|
|
||
| const DATABASE_POOL_MAX = /^ printf 'ORCA_RELAY_DATABASE_POOL_MAX=%s\\n' '[0-9]+'$/ |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,120p' cloud/dev/scripts/validate-relay-capacity-plan.mjs
sed -n '185,295p' cloud/dev/scripts/validate-relay-capacity-plan.mjs
sed -n '430,485p' cloud/dev/scripts/validate-relay-capacity-plan.mjs
rg -n -C 3 'ORCA_RELAY_DATABASE_POOL_MAX|DATABASE_POOL_MAX|unexpectedDatabasePoolMax|normalizedStartupScript' cloud/dev/scripts/validate-relay-capacity-plan.mjs cloud/dev/scripts/validate-relay-capacity-plan.test.mjs cloud/dev/scripts/relay-same-cap-script-census.test.mjsRepository: stablyai/orca
Length of output: 19872
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- validator tests around startup scripts and pool cases ---'
sed -n '680,870p' cloud/dev/scripts/validate-relay-capacity-plan.test.mjs
printf '%s\n' '--- all test references to database pool and same-cap validation ---'
rg -n -C 5 'database-pool-max|DATABASE_POOL_MAX|same-cap-cell|metadata_startup_script|startup script' \
cloud/dev/scripts/validate-relay-capacity-plan.test.mjs \
cloud/dev/scripts/relay-same-cap-script-census.test.mjs
printf '%s\n' '--- candidate startup-script fixtures ---'
rg -n -l 'ORCA_RELAY_DATABASE_POOL_MAX|metadata_startup_script' cloud/dev cloud | head -80Repository: stablyai/orca
Length of output: 50369
Match pool assignments independent of leading whitespace.
DATABASE_POOL_MAX requires exactly two leading spaces. Shell accepts an unindented printf command. For an unpinned same-cap-cell, the validator does not detect a pool assignment with different indentation when the line appears in both the before and planned scripts. The normalized scripts then compare equal, so the plan can pass.
Broaden this detection pattern. hasExactSingleAssignment still requires the expected assignment string exactly for pinned pools.
Proposed fix
-const DATABASE_POOL_MAX = /^ printf 'ORCA_RELAY_DATABASE_POOL_MAX=%s\\n' '[0-9]+'$/
+const DATABASE_POOL_MAX = /^\s*printf 'ORCA_RELAY_DATABASE_POOL_MAX=%s\\n' '[^'\n]+'$/📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const DATABASE_POOL_MAX = /^ printf 'ORCA_RELAY_DATABASE_POOL_MAX=%s\\n' '[0-9]+'$/ | |
| const DATABASE_POOL_MAX = /^\s*printf 'ORCA_RELAY_DATABASE_POOL_MAX=%s\\n' '[^'\n]+'$/ |
…dator (stablyai#21171) * fix(cloud): pin the asia cell database pool in the same-cap plan validator Raising `database_pool_max` from 10 to 16 for production-gce-c27, c28 and c29 made every same-cap roll of those three cells fail closed at plan validation. The cell startup template emits `ORCA_RELAY_DATABASE_POOL_MAX` only for a cell whose region differs from the root region or whose pool is off the default, so the asia cells carry that line while the us-central1 cells do not. The plan validator requires the before and after startup scripts to normalize to the same text, masking only the lines it independently pins to a reviewed value. The pool line was neither masked nor pinned, so the live template's `'10'` and the plan's `'16'` were read as unreviewed drift. The validator gains an optional `--database-pool-max`, accepted in `same-cap-cell` mode alone. When it is supplied the after-script must contain exactly that pool line and the line is masked from the equality check; when it is not supplied the after-script must contain no pool line at all. Masking without the pin would have removed the guard rather than moved it. The same-cap job resolves the expected pool next to the hard cap, cross-checks it against the committed `relay_gce_cells` map (asserting the default 10 for the us-central1 cells), and passes the flag to both validator invocations only for the cells that emit the line. * test(cloud): require the pool pin for a line the live template already carries

ELI5
Three of our relay servers live in Hong Kong, and last week we told them to open more database connections than the servers in the US do. The safety check that runs before we deploy a new version to a server compares the machine's current setup line by line against the setup the deploy is about to write, and refuses to continue if anything it wasn't told about moved. Nobody told it about the connection-count change, so it saw "10" on the machine and "16" in the deploy and stopped every deploy to those three servers. This PR tells the safety check what the reviewed number is, so it can recognise the change instead of treating it as a surprise.
What Changed
Before. Since #21163 raised
database_pool_maxfrom 10 to 16 forproduction-gce-c27,c28andc29, any same-cap roll of those three cells — forward, rollback or resume — stops withcell plan does not contain the reviewed image and capacityat plan validation. Nothing is applied, so the cells cannot take a new relay image at all. The other sixteen same-cap cells are unaffected.After. A roll of an Asia cell validates, with the pool held to exactly the reviewed 16. A roll of a US cell validates as before, and now also fails if its plan grows a pool line at all.
Mechanism. Each cell's startup script is generated from a Terraform template that emits
only when a cell's region differs from the root region or its pool is off the default of 10. So the three Asia cells carry that line and the US cells carry no line at all.
The plan validator (
cloud/dev/scripts/validate-relay-capacity-plan.mjs) proves a roll changes nothing but the image by normalizing the live startup script and the planned one and requiring the two to be byte-identical. It removes a line from that comparison only when it separately pins that line to an exact value supplied on the command line — the image digest, the connection hard cap, the unobserved bound, the capacity service account, and the rehome trust lines all work this way. The pool line was in neither list, so the live'10'and the planned'16'read as unreviewed drift.This adds the pool to both lists at once:
--database-pool-max <1..100>, accepted insame-cap-cellmode only and rejected elsewhere, exactly as--regional-rehome-protocolis.The same-cap job (
.github/workflows/cloud-deploy-relay-production-same-cap-job.yml) resolvesEXPECTED_DATABASE_POOL_MAXfrom the cell id next to the hard cap and region (16 forc27|c28|c29, empty for the US cells), cross-checks it againstdatabase_pool_maxin the committedrelay_gce_cellsmap the way the hard cap is already cross-checked (asserting the default 10 for the cells it leaves unpinned), and passes the flag to both validator invocations — the apply-side one and the resume one — only when it is non-empty.verify-relay-capacity-transition.mjsis untouched: it reads the cell's live admin status, which does not report the pool.Why
The three Asia cells are currently undeployable. The pool value itself is correct and measured (176 ms from the us-central1 Postgres saturates a pool of 10, with 94–156 waiters), so the fix belongs in the gate that reviews it, not in the value.
Alternatives considered:
config.ts), so the startup line would still be emitted and still be unreviewed. It moves the problem rather than solving it.One consequence worth stating: both changed files are in
TRUSTED_EVIDENCE_CODE_PATHS, so any monitor evidence or canary authority sealed before this merge is no longer byte-identical and will be refused. That is the intended behaviour of that check and is not weakened here — a roll after this merge needs a fresh dry run.Linked Issue
N/A — follow-up to #21163, no separate issue filed.
Visual Proof
N/A — no UI. This changes a CI plan-validation gate and the shell that calls it.
Testing
Ran by hand against a synthetic plan for
production-gce-c27whose before and after startup scripts differ only in the pool line, 10 → 16:The first of those is the exact failure a real
c27roll hits today.Automated:
node --test dev/scripts/*.test.mjsfromcloud/— 711 pass, 1 pre-existing failure (relay-load-control-peer.test.mjscannot resolve@orca-cloud/relay-contractwithout a workspace install; it fails the same way onorigin/main).validate-relay-capacity-plan.test.mjs: pin matching passes; pin against a different value fails; no pin with a pool line present fails; no pin with a pool line unchanged on both sides still fails; a pin the plan does not satisfy fails; out-of-range pins are rejected; before 10 / after 16 with the pin passes the equality check; the flag is rejected outsidesame-cap-cell.relay-same-cap-script-census.test.mjsnow resolves the pool from the job's own shell block for every wave cell, cross-checks it againstproduction.tfvars, requires both validator invocations to carry the flag and both steps to build it conditionally, and validates a plan per cell where the live template still says 10 — plus a negative that dropping the pin rejects an Asia cell and adding one rejects a US cell.relay-regional-rehome-workflow.test.mjs's pin on the resume invocation's argument list updated for the added argument.Shell behaviour checked directly: with
EXPECTED_DATABASE_POOL_MAX=16the array expands to--database-pool-max 16; empty, it expands to zero arguments. Both changedrun:blocks passbash -n.Platforms: CI-only change (Ubuntu runner,
bash). No Orca client code touched, so macOS/Linux/Windows/SSH behaviour is unchanged.AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Security: the flag is bounded to 1..100 and reaches the validator only from a case branch keyed on the cell id, cross-checked against the committed Terraform map — an operator cannot supply it. The change strictly narrows what the validator accepts for US cells and keeps Asia cells pinned to a reviewed constant. No production or cloud resource was touched and no Terraform ran against remote state. Mobile, remote-SSH and backwards compatibility: not reachable from this code.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)