Repository navigation
fix(relay-ops): roll a cell a wave stranded after its drain - #21321
Conversation
A wave that stops any time after its drain leaves the cell migration-only and draining on the rollback image, and nothing clears it: the drain flag is a one-way latch on the running process, and the failsafe restarts nothing. Both recovery modes then refuse the cell. Apply wants it general and not draining. Rollback sees the rollback image, reads it as a resume, refuses the draining, and would not have restarted it anyway. The image alone cannot separate a rollback that failed after its template apply from a wave that stopped before one. The restart can: the first left a fresh process, the second did not. Classify on that, so the cell that never restarted takes the rolling path instead of the resuming one. Its template still carries the image it serves, so that is the predecessor its plan is reviewed against, and a template already moved on to the target is refused rather than rolled backwards under a stale review. When the reviewed template is already in place the plan changes nothing, so the MIG is rolled explicitly on the same replacement policy a template change uses; the existing incarnation check is what proves the instance came back. Every other combination of mode, live image, and drain flag keeps the value it had, held by a census that runs the real block over all nine.
|
This run was cancelled 🛑 The workflow was cancelled before completion. Please check the link below for details. |
📝 WalkthroughWalkthroughThe same-cap rollback workflow now distinguishes Priority: ⬇️ Low Merge Risk: 🔵 Low · up to The recovery command is currently correct, but its regression test could miss a later change that makes stranded replacement fall back to default policy settings. Bind the assertion to the command before merging or accept the bounded test-coverage gap. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 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: af57ae17-177e-4ebf-844f-2ad814c0e310
📒 Files selected for processing (3)
.github/workflows/cloud-deploy-relay-production-same-cap-job.ymlcloud/dev/scripts/relay-same-cap-script-census.test.mjscloud/docs/relay-workflows.md
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| if test "${ROLLBACK_STAGE}" = stranded \ | ||
| && test "$(jq -er '.changes' <<< "${PLAN_REVIEW}")" = 0; then |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -euo pipefail
validator="$(fd -a '^validate-relay-capacity-plan\.mjs$' . | head -n1)"
test -n "${validator}"
rg -n -C6 \
'changes|obsolete|delete|instance_group_manager|instance_template|no-op|read' \
"${validator}" cloud/dev/scriptsRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- validator files ---'
fd -a '^validate-relay-capacity-plan\.mjs$' .
printf '%s\n' '--- workflow ---'
sed -n '620,710p' .github/workflows/cloud-deploy-relay-production-same-cap-job.yml
printf '%s\n' '--- validator source ---'
for validator in $(fd -a '^validate-relay-capacity-plan\.mjs$' .); do
printf '\n### %s\n' "$validator"
wc -l "$validator"
cat -n "$validator"
doneRepository: stablyai/orca
Length of output: 33266
Use replacement semantics, not total change count, for stranded cells. In same-cap-cell mode, convergenceCellPlan accepts a deposed template delete as the only mutation and returns changes: 1. The workflow then skips rolling-action replace, so the stranded drain flag can persist. Base the explicit replacement decision on whether the accepted plan replaces an instance, including zero-change and obsolete-template-only plans.
gcloud persists every rolling-action bound into the group's update policy, and it defaults the replacement method to substitute on a group with no stateful config. Passing surge and unavailable without the method would patch the policy off the declared RECREATE, and the next targeted plan would then carry a MIG change outside version.0.instance_template, which the plan validator refuses. Pass all three so the patch is identical to the declared policy, and read the declared values in the census instead of restating two of them. Dropping the flag, or moving any of the three in Terraform, now fails the census.
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: c4526034-17d2-493f-a536-a59031fb8544
📒 Files selected for processing (2)
.github/workflows/cloud-deploy-relay-production-same-cap-job.ymlcloud/dev/scripts/relay-same-cap-script-census.test.mjs
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| assert.match(apply, /rolling-action replace "\$\{MIG_NAME\}"/) | ||
| const declared = migUpdatePolicy() | ||
| assert.deepEqual(declared, { | ||
| replacementMethod: 'recreate', | ||
| maxSurge: '0', | ||
| maxUnavailable: '1' | ||
| }) | ||
| assert.match( | ||
| apply, | ||
| new RegExp( | ||
| `--replacement-method ${declared.replacementMethod}` + | ||
| ` --max-surge ${declared.maxSurge} --max-unavailable ${declared.maxUnavailable}` | ||
| ) | ||
| ) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '640,715p' cloud/dev/scripts/relay-same-cap-script-census.test.mjs
sed -n '640,700p' .github/workflows/cloud-deploy-relay-production-same-cap-job.yml
rg -n -C3 'const apply|apply =|rolling-action replace|replacement-method|max-surge|max-unavailable' cloud/dev/scripts/relay-same-cap-script-census.test.mjs .github/workflows/cloud-deploy-relay-production-same-cap-job.ymlRepository: stablyai/orca
Length of output: 11158
Bind the policy flags to the replacement command.
apply contains the entire shell step. The test checks that rolling-action replace exists and separately checks that the flag sequence exists somewhere in apply. The test can therefore pass if the flags move to unrelated shell text while the replacement command uses gcloud defaults. Capture the rolling-action replace invocation and assert the three flags within that command.
…#21321) * fix(relay-ops): roll a cell a wave stranded after its drain A wave that stops any time after its drain leaves the cell migration-only and draining on the rollback image, and nothing clears it: the drain flag is a one-way latch on the running process, and the failsafe restarts nothing. Both recovery modes then refuse the cell. Apply wants it general and not draining. Rollback sees the rollback image, reads it as a resume, refuses the draining, and would not have restarted it anyway. The image alone cannot separate a rollback that failed after its template apply from a wave that stopped before one. The restart can: the first left a fresh process, the second did not. Classify on that, so the cell that never restarted takes the rolling path instead of the resuming one. Its template still carries the image it serves, so that is the predecessor its plan is reviewed against, and a template already moved on to the target is refused rather than rolled backwards under a stale review. When the reviewed template is already in place the plan changes nothing, so the MIG is rolled explicitly on the same replacement policy a template change uses; the existing incarnation check is what proves the instance came back. Every other combination of mode, live image, and drain flag keeps the value it had, held by a census that runs the real block over all nine. * fix(relay-ops): pin the replacement method on the explicit MIG roll gcloud persists every rolling-action bound into the group's update policy, and it defaults the replacement method to substitute on a group with no stateful config. Passing surge and unavailable without the method would patch the policy off the declared RECREATE, and the next targeted plan would then carry a MIG change outside version.0.instance_template, which the plan validator refuses. Pass all three so the patch is identical to the declared policy, and read the declared values in the census instead of restating two of them. Dropping the flag, or moving any of the three in Terraform, now fails the census.

ELI5
Before a cell is upgraded it is told to shed its connections. That instruction is a
one-way switch inside the running program: the only thing that turns it off is the
program starting again.
If the upgrade then fails before the machine is replaced, the switch stays on. The
cell is left half way through an upgrade that will never finish, and neither
recovery path will touch it. Retrying the upgrade says the cell is in the wrong
state, and rolling back thinks the work is already done. This teaches the rollback
to recognise that cell and actually roll it.
What Changed
Before. A general cell whose wave failed between its drain and its template
apply was stuck.
applyrefused it, because apply needs the cell general and notdraining, and it is neither.
rollbackrefused it too: it still serves therollback image, so rollback classified it as a resume, and the resume path both
refuses a draining cell and skips the isolate, the drain, and the template apply,
so it could not have cleared the flag even if it had accepted it.
After. That cell is classified
strandedand rolled. It comes back on a newinstance, so the drain clears, and it is restored to general.
The mechanism. Two different failures leave a cell on the rollback image, and
the image alone cannot separate them. The restart can:
resumestrandedrollstrandedruns the ordinary rolling path. Three things follow from the cell havingnever restarted:
its plan is reviewed against, not the target the wave was heading for. A template
that already moved on to the target is refused rather than rolled backwards under
a stale review.
rename that is identical on every existing path.
apply replaces no instance. The MIG is then rolled explicitly, with
--max-surge 0 --max-unavailable 1, which is exactly theupdate_policyatemplate change uses. The existing check that the incarnation must change is what
proves the instance came back.
Why
The brief proposed classifying on the MIG's current template digest as well as the
incarnation and the drain flag. I used the drain flag alone, and let the plan
review cover what the template digest would have told us.
Reading the MIG's template needs a second gcloud call, an extraction of the relay
digest from a startup script, and a fourth branch for "template applied, instance
not replaced". Validating the plan against the image the cell serves already
rejects that case, fail-closed, with no new code: if the template carries the
target,
relayImage(before)does not match the reviewed rollback image and theplan is refused. That state also self-heals, because the MIG keeps replacing the
instance on its own, after which the cell reads as
rolland takes the path italready had.
The incarnation is not usable as a classifier across dispatches. Nothing durable
records what it was before, so a fresh read cannot tell a restarted cell from one
that never moved.
I considered clearing the flag instead of rolling the cell, which would be far
smaller. There is no route for it:
drainingis set inhost-session-registry.tsand never assigned false anywhere, so a restart is the only way out.
Linked Issue
N/A - operational follow-up to #21315, needed before populated general cells roll.
Visual Proof
N/A. No UI. This changes a GitHub Actions rollout workflow.
Testing
All from
cloud/.pnpm test— 625 pass, 0 fail in the dev-script suite; 156 pass, 0 fail inpretest; relay-ops 134, relay 717 passed / 121 skipped, push 139 passed / 4skipped, postgres-schema 108, relay-contract 35, push-contract 30,
relay-fence-broker 16. No failures.
pnpm typecheck,pnpm lint,pnpm build— clean.actionlint— clean apart from the pre-existing unknown blacksmith runner label.The unchanged-paths claim is measured, not asserted. I extracted the
classification block from
origin/mainand from this branch and ran both overevery combination of mode, live image, and drain flag, comparing the stage, the
predecessor image, the predecessor protocol, and the plan's reviewed rollback
image. One row differs:
The census now runs the same nine combinations against the committed block, plus a
tenth where the runtime reports no drain flag at all, which must never read as
stranded. Two further census tests hold the explicit MIG roll, its gating on a
zero-change plan, its surge and unavailable values against the Terraform
update_policythey have to match, the drain wait's image, and the incarnationcheck that proves the restart. The eight-combination draining test from #21315 is
unchanged and still passes.
Not verified: the explicit
rolling-action replaceagainst a live MIG. It isgated on a stage no cell is in right now, and it uses the same surge and
unavailable values the MIG's own update policy declares, which the census asserts.
AI Disclosure
Review
The judgement worth checking is dropping the MIG template digest from the
classifier in favour of the plan review. If you would rather the stage were read
directly off the MIG, that is a bigger change and a fourth branch, and I would
rather add it deliberately than tonight.
The same-cap job workflow is in
TRUSTED_EVIDENCE_CODE_PATHS, so merginginvalidates any canary authority sealed before it.
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: no identity, audience, lock, confirmation, or evidence rule changes. The
stranded path runs the same isolate, drain, plan review, and verification the
ordinary rolling path runs, and is reviewed against a stricter predecessor than
before, because the plan must match the image the cell is actually serving.
Backwards compatibility: measured above. Eight of nine combinations are unchanged.
Cross-platform, SSH, mobile, performance: N/A. CI-only.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)