Repository navigation
feat(relay): report a post-wave health verdict on each same-cap cell, without gating on it - #21849
Conversation
… without gating on it After a same-cap cell finishes rolling, an operator reads five things by hand before dispatching the next cell: director 503s against the same clock hour a day and two days earlier, whether the cell's new container announced its listener and has stayed up, the cell's own pool pressure, the asia-east2 pool trio, and Cloud SQL FATALs. This runs those same reads automatically and records PASS / WARN / WOULD_BLOCK with its numbers, so its calls can be compared with the operator's over a full roll before it is ever allowed to stop one. It cannot fail a cell in this change. The script exits 0 on every verdict, and the step is continue-on-error, so even a crash stays off the job's outcome and the failure failsafe cannot fire on anything it observes. It also runs after the restore, so no cell waits on it to go back into admission. Cloud Logging returns only --limit entries and says nothing when it truncates, so every count is split into sub-windows of ten minutes and a sub-window that comes back at the limit is reported unverified rather than as a count. Windows are always explicitly bounded: --freshness does not bind on these logs. Claude-Session: https://claude.ai/session/ced32ebb-7155-4413-adad-1eccd14c2010
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe workflow captures drain, apply-start, apply-completion, and verification-end timestamps. The shadow gate evaluates director errors, cell serving, pool pressure, and Cloud SQL fatal errors through bounded logging reads. Failed or truncated reads produce unverified results. The gate writes a JSON report and step summary without failing the job. Tests cover validation, windowing, verdicts, timeouts, truncation, and workflow wiring. Priority: ➖ Normal 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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: 4
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 69eb3cc5-06b7-437e-9580-81e159d68ecd
📒 Files selected for processing (5)
.github/workflows/cloud-deploy-relay-production-same-cap-job.ymlcloud/dev/scripts/relay-same-cap-shadow-gate-verdict.mjscloud/dev/scripts/relay-same-cap-shadow-gate.mjscloud/dev/scripts/relay-same-cap-shadow-gate.test.mjscloud/package.json
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
… cap every read Four fixes from review, all in the report-only shadow health gate. The boot search opened at apply-completed-at, which is stamped after `terraform apply` and `wait-until --stable`. The new container announces its listener while the MIG is still converging, so that bound is already past the announcement it looks for and a healthy roll read as would-block. The job now stamps apply-started-at immediately before the apply, and the boot search opens there; apply-completed-at is kept, recorded rather than judged, so an operator comparing verdicts can see apply time next to boot time. The crash query started at the newest listener timestamp, which erased any crash before it. A crash-restart loop ends with an announcement that looks like a clean boot, so that is exactly the case it hid: against production, the 2026-09-20 c28 crash at 20:18:10 was dropped because the listener landed at 20:18:27. It now runs from the apply start, still scoped to the instance id the listener identified, and that crash is counted. A runtime-metrics read that came back at its 500-entry limit fed judgePool as though it were a complete sample run. A truncated run has holes and the consecutive-sample rule reads a hole as a recovery, so it now reports unverified. gcloud reads had no timeout. continue-on-error bounds the job's outcome but not its clock, so a stalled read could have spent the rollout's remaining minutes. Each read now gets 60 s and a timed-out read is just a failed read. Claude-Session: https://claude.ai/session/ced32ebb-7155-4413-adad-1eccd14c2010
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: ac724d24-9e45-4dcf-95da-5ea6796b5a0a
📒 Files selected for processing (4)
.github/workflows/cloud-deploy-relay-production-same-cap-job.ymlcloud/dev/scripts/relay-same-cap-shadow-gate-verdict.mjscloud/dev/scripts/relay-same-cap-shadow-gate.mjscloud/dev/scripts/relay-same-cap-shadow-gate.test.mjs
🚧 Files skipped from review as they are similar to previous changes (3)
- .github/workflows/cloud-deploy-relay-production-same-cap-job.yml
- cloud/dev/scripts/relay-same-cap-shadow-gate-verdict.mjs
- cloud/dev/scripts/relay-same-cap-shadow-gate.mjs
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
…ng its order The ordering assertion used indexOf, which answers -1 for an absent stamp, and -1 precedes every real offset. Deleting the apply-started-at line left the test green, so the census could not see the fix it was written to pin. Each stamp's presence is now asserted first, with a message naming the stamp and the step, and presence is judged inside the step that owns the stamp rather than anywhere in the file: a stamp written into a neighbouring step records the wrong instant but would satisfy a whole-file match. Control-run against a scratch copy of the job. Deleting drain-started-at, apply-started-at, or apply-completed-at each reds with its own message, and moving apply-started-at after terraform apply reds on the ordering assertion, so presence and order both fail independently. Claude-Session: https://claude.ai/session/ced32ebb-7155-4413-adad-1eccd14c2010
…ay-roll-shadow-gate
…d update on resume (#21865) * fix(relay): bound the same-cap shadow gate and apply a resumed backend update Two findings both adversarial reviews of tonight's merged set agree on. The report-only shadow health gate (#21849) had `continue-on-error: true` but no step timeout. That bounds the step's contribution to the job outcome, not its clock. Its reads are serialised, and a failure that answers nothing slowly — an expired credential, a project-wide Logging 429 storm — makes every read cost its full 3 x 60 s retry budget, so the cost scales with the roll window: roughly 8S + 2 reads for S ten-minute sub-windows. A 40-minute window is about 34 reads, or 108 minutes, against the job's `timeout-minutes: 75`. A cancelled job cannot be absorbed by continue-on-error, fires the failure-gated cleanup isolation on an already-restored cell, and stops the strict next-cell chain. Give the step `timeout-minutes: 5` and the artifact upload `timeout-minutes: 2`. A timed-out step is a failed step, which continue-on-error covers, so the job stays green. Inside the script, stop reading after an overall four-minute deadline and report the remaining checks unverified, so the normal outcome is a written verdict rather than a killed process; the step timeout is then only for a hung process. The census test pins both timeouts and that the deadline leaves the step time to write its verdict. The resume branch (#21860) accepted `changes == 0` with a non-empty `backendUpdate` as complete and applied nothing, so a resumed cell silently kept the 300-second drain and no request logging behind a green resume. That shape means the template and MIG are converged and only this cell's reviewed backend update is left, so apply the saved resume plan — the validator has already bounded it to this cell's backend and neither attribute restarts an instance — then continue as converged. Template-and-MIG drift still applies nothing, which is what a resume means, and a stranded cell's explicit MIG replace is unchanged. Claude-Session: relay-same-cap-gate-timeout-and-resume * fix(relay): raise the shadow gate bounds clear of a healthy gate's read time A healthy gate is already minutes of serial reads on the 2-vcpu runner, so a four-minute deadline would report unverified tails on ordinary days and stop the shadow roll measuring the comparison it exists for. Raise both together: the step to eight minutes and the script's own deadline to seven, keeping the census pin that the deadline leaves the step room to write its verdict. The job budget is unaffected: a ~14-minute cell plus eight is well inside 75. Claude-Session: relay-same-cap-gate-timeout-and-resume

ELI5
When we roll a Relay cell to a new image, a person watches five dashboards afterwards
and decides whether it is safe to roll the next one. This teaches the rollout job to
watch the same five things itself and write down what it would have decided — but it
is not allowed to decide anything yet. Next roll, a person compares their call with the
job's call. If the job agrees, a follow-up PR lets it start saying no.
What Changed
Before.
cloud-deploy-relay-production-same-cap-job.ymlrolls one cell: drain it,apply the new instance template, wait for the MIG, verify the new incarnation, restore
its admission. Then it stops. Whether the fleet is actually healthy afterwards is
checked by a human in the GCP Logs Explorer, and nothing about that check is recorded
in the run.
After. The same job, plus one new step named
Shadow health gate (report only),placed after the restore. It runs
cloud/dev/scripts/relay-same-cap-shadow-gate.mjs,which reads the same five oracles over the window the cell was rolled in, and writes a
PASS/WARN/WOULD_BLOCKverdict with the numbers behind it to$GITHUB_STEP_SUMMARYand to an uploaded artifact,relay-same-cap-shadow-gate-<cell>-<run_id>.json.The oracles, each verified against production logs tonight (results below):
director503orca-cloud-relayCloud RunhttpRequest.status=503, counted per minute over the roll window, compared against the same clock-hour window 24 h and 48 h earliercellServinglistening on https://<host>line after the Terraform apply, thenthrow er(an unhandled-error-event process crash) on that same instance sincecellPoolorca_relay_runtime_metrics:totalConnections,databasePoolWaitersMax,databasePoolWaiting,sqlFailuresDelta,reconnectsDeltafleetPool:*production-gce-c27/c28/c29, which share a 16-connection pool at 176 ms RTTcloudSqlFatalresource.type="cloudsql_database"entries containingFATALin the windowThe mechanism that makes it safe. Two independent guarantees, either one sufficient:
the script returns a verdict and exits 0 no matter what the verdict is (only an
unhandled crash exits non-zero), and the step carries
continue-on-error: true, so evena crash never reaches the job's conclusion. Because the job never goes to
failure(),the existing
Keep a failed cell isolated and rehome disabledfailsafe cannot betriggered by anything this step sees.
Supporting changes. Three existing steps now also write one timestamp each to
$GITHUB_OUTPUT—drain-started-at,apply-completed-at,verify-ended-at— so thegate knows which window belongs to this cell. Nothing else about those steps changed.
The verdict rules live in a separate pure module,
relay-same-cap-shadow-gate-verdict.mjs, with 14 unit tests.Two things about how it reads logs, both learned the hard way tonight.
gcloud logging readsilently returns only--limitentries, so every count is splitinto sub-windows of at most ten minutes, and a sub-window that comes back at exactly the
limit is reported as
unverifiedrather than as a number. And--freshnessdoes notbind on these logs at all, so every read carries explicit
timestamp>=/timestamp<bounds. An
unverifiedcheck can never settle toPASS.Why
Automated brakes on this rollout produced several false positives this week, each from a
rule that read one number literally:
A fixed rate called it an outage. Here the block threshold is ten times the busier of
the two baselines with an absolute floor of 200, so a ramp passes and a real collapse
does not — validated below on both.
latency percentile is an input, precisely because a percentile over a short window is
dominated by its single worst sample.
databasePoolWaitersMax=71. Here one spike is aWARN; aWOULD_BLOCKneeds the pressure to persist across three consecutive samples, orsqlFailuresDelta > 200.Given that record, a gate that can stop a roll should not be trusted on the strength of
its author's reasoning about it. The alternative — ship it blocking and add overrides
when it misfires — is how the false positives above got normalised in the first place.
Shadow mode produces the evidence instead: one full US roll, and for each cell the
operator's own call sitting next to the gate's verdict and numbers in the same run.
How to compare on the next US roll. After each cell, the run's step summary has the
gate's verdict and its numbers. Make your own call as you do today, then read the summary
and note where they disagree. At the end of the roll, the per-cell artifacts collect the
whole set. The gate flips to blocking only if it agreed on every cell, or if the
disagreements are all ones where it was the more conservative of the two.
What the follow-up PR does. Removes
continue-on-error: true, makes the script exitnon-zero on
WOULD_BLOCK, and moves the step before the restore so a blocked cell staysisolated.
WARNandunverifiedstay non-blocking. That PR is one small diff and thethresholds do not move, so the data collected here is what it is reviewed against.
Production permissions
No permission change in this PR. The job already authenticates as
[email protected](repo variablePRODUCTION_GCP_RELAY_DEPLOY_SERVICE_ACCOUNT), and Terraform already grants that accountproject-level
roles/logging.vieweratcloud/infra/terraform/relay-github-actions.tf:373-380, alongsidemonitoring.viewer,cloudsql.viewerandcompute.viewer. Confirmed against the live policy too —gcloud projects get-iam-policy onorca-cloudreturns exactly those four roles for thataccount. The gate reads logs only; it needs nothing more.
One operational consequence to know about
deploy-relay-production-same-cap-job.ymlis inTRUSTED_EVIDENCE_CODE_PATHS(
cloud/dev/scripts/relay-evidence-code-provenance.mjs), so once this merges, monitordry-run evidence sealed at a commit before the merge can no longer be spent — the next
wave needs a fresh dry-run. That is true of any edit to this file and is not specific to
this change.
The new script is deliberately not added to that trusted list. It cannot mutate
anything and cannot change a mutation's outcome, so pinning it would only mean that
iterating on the shadow thresholds invalidates in-flight evidence for no safety gain.
When the follow-up PR makes it blocking, it must be added.
Linked Issue
N/A — operational hardening for the in-flight same-cap roll, no tracked issue.
Visual Proof
N/A — no UI. The user-visible output is a step summary table and a JSON artifact; a real
run of it is shown under Testing.
Testing
Unit tests: 18 new,
cloud/dev/scripts/relay-same-cap-shadow-gate.test.mjs,registered in
cloud/package.json's test list. All pass. Fullclouddev-scripts suite:624 tests, 623 pass; the one failure is
relay-load-control-peer.test.mjs, which isMODULE_NOT_FOUNDforcloud/apps/relayin this worktree and fails identically withoutthis change.
actionlint: output is byte-identical to
origin/main's for this file — the onlyfinding is the pre-existing
blacksmith-2vcpu-ubuntu-2204self-hosted runner label,which needs an
actionlint.yaml, not a fix.oxlint:
No files found to lint—cloud/**is in the root.oxlintrc.jsonignorelist (line 187), so the repo does not lint these files. Reporting rather than working
around it.
Each query shape validated against production (read-only
gcloud logging read):listening on https://c28.relay.onorca.dev→ one entry at2026-09-20T20:18:27.470Z,instance
5031087219978409220.throw er→ one entry at2026-09-20T20:18:10.652Z, same instance. Confirms thatinstance_iddoes not change across a container restart, which is why the crash read isscoped to the instance the listener line identifies.
jsonPayload.event="orca_relay_runtime_metrics"withjsonPayload.cellId="production-gce-c28"→ samples every ~30 s carrying all five fields.
FATAL→terminating connection due to idle-in-transaction timeoutat2026-09-20T20:18:10.556Z.--limit 5000the window returned exactly 5000 entries across two minutes. Re-read at--limit 20000, the single minute15:34alone was 4722. The 5000 was a truncationreported as a count. Baselines for that same window: 24 h earlier peak 48/min, 48 h
earlier peak 69/min.
End-to-end runs of the actual script against production:
The 2026-09-20 c28 collapse, window 20:00Z-20:30Z →
WOULD_BLOCK, exit 0.It reaches the operator's conclusion and localises it to c28 — c27 and c29 clean over the
same window.
Control, a quiet window, c27 17:30Z-18:00Z → every fleet check
PASS:director503peak 40/min against a 21/min baseline, all poolswaitersMaxat most 2,cloudSqlFatal0. So the thresholds are not simply firing on everything.A gap that control run found, and the fix. In that control window c27 had not been
restarted, so there was no listener line and
cellServingreadwould-block— an absenceoracle with no presence precondition. In the job this matters for a resumed rollback,
which deliberately restarts nothing. The gate now detects that case (neither the drain nor
the apply step ran, so it has no timestamp from either) and reports
unverifiedinstead ofwould-block, with a test covering it. Worth flagging as exactly the class of bug shadowmode exists to surface.
Review round 1 (CodeRabbit), all four fixed in
381ad1a697All four findings were real; two of them changed a verdict against production data.
apply-completed-atis stamped afterterraform applyand
wait-until --stable, but the container announces its listener while the MIG isstill converging — on the 2026-09-19 c28 wave the listener was at 15:29:39Z and the
first metrics sample at 15:30:09Z, both before stability could be reported. So the bound
was always past the line it searched for, and a healthy roll would have read
would-block. The job now stampsapply-started-atimmediately before the apply and thesearch opens there.
apply-completed-atis kept but recorded rather than judged.2026-09-20 c28 window:
cellServingwaspass/crashesAfterBoot 0, and is nowwould-block/crashesSinceApply 1— the 20:18:10Z crash the 20:18:27Z listener hadhidden. My original note that this was "the boot the wave replaced" was wrong: the MIG
recreates the instance, so everything on that instance id since the apply belongs to this
roll. Field renamed so it no longer claims more than it measures.
judgePoolas complete. Truncationthere is worse than a low count: the holes read to the consecutive-sample rule as
recoveries, so a sustained run could have come back
pass. Nowunverified.gcloud.continue-on-errorbounds the job's outcome, not its clock,so a stalled read could have spent the rollout's remaining minutes while still reporting
green. 60 s per read; a timed-out read is a failed read.
Tests went 14 → 18, including the crash-before-listener case and the metrics-truncation
case. The test's gcloud fake now honours the timestamp bounds and instance-id scope in the
filter it is handed — the previous fake ignored them, which is precisely why findings 1 and
2 could pass a green suite.
AI Disclosure
Internal contributor.
Review
Worth a careful look at: the threshold choices in
SHADOW_GATE_THRESHOLDS(they aredeliberately loose, on the theory that a shadow gate that cries wolf teaches nothing);
the decision to place the step after the restore rather than before it; and the decision
to leave the script out of
TRUSTED_EVIDENCE_CODE_PATHSwhile it is report-only.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
(cell id, cell host, project id and service name all match fixed regexes), and the cell
id and host must name the same cell.
gcloudis invoked throughexecFilewith an argvarray — no shell, no string interpolation of an untrusted value. The step's timestamps
reach the script through
env:, not expanded into a shell line.mode: verifyruns are unaffected (the step is skipped).A resumed rollback is handled explicitly. No new dependencies.
admission. Reads are serialised on purpose — a burst of concurrent Logging reads earns a
429, and a 429 is the failure mode that returns a short answer rather than an error.
read-only Cloud Logging queries.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)