Skip to content

fix(relay-ops): accept a drained predecessor on a cell that holds no hosts - #21315

Merged
Jinwoo-H merged 1 commit into
mainfrom
relay-same-cap-drained-predecessor
Sep 18, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
relay-same-cap-drained-predecessor

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​59 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​59
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​33 $\color{#cf222e}{\Huge{\mathbf{−}}}$​15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​18

ELI5

Before a cell is upgraded, the rollout checks it is not already "draining", which
means something is shedding its connections. c17 was flagged as draining, so the
check refused.

It was draining because the previous attempt drained it and then failed before
replacing the machine, so the flag was left behind. And c17 has no connections at
all, so draining it never meant anything in the first place.

What Changed

Before. Canary-apply on c17 (run 35292335415) failed at Verify exact current
generation, digest, cap, and rollback point
with runtime predecessor mismatch fields=draining. Nothing was applied.

After. A cell whose entry class is migration-only is allowed to be draining on
entry. General cells are unaffected.

The flag is residue, not a property of a parked cell. The previous canary,
run 35290908836, passed this exact check at 00:25:59 and then drained c17 one
second later:

00:26:01 {"event":"relay_production_capacity_canary","cellId":"production-gce-c17","mode":"drain","changed":false,"drained":true,"paceWindowMs":0}

Its terraform apply then failed, and the failsafe re-isolates without restarting
the VM, so nothing cleared the flag. c17 is sitting in the state its own
interrupted wave left it in.

The fix. Draining means connections are being shed. A migration-only cell
holds none, so the flag carries no precondition there. PRECHECK_DRAINING becomes
either and the runtime assertion's drainingOk becomes true for that class
only. Both predecessor checks now read one PREDECESSOR_DRAINING_OK decision
rather than recomputing the rule, so the assertion and its diagnostic cannot
disagree.

What still holds on every path: the replacement VM must report draining false
after the apply and again after the restore, and the incarnation must change,
which is what proves the VM was actually replaced.

Why

I want to flag that the brief's premise was not what the evidence showed. The
proposal was that a parked cell is drained by design. It is not: c17 passed this
same check a second before its own drain ran. Accepting draining because "parked
means drained" would have written a false invariant into the workflow and blinded
the check permanently.

The reason that survives the evidence is different and narrower: a cell with no
hosts has nothing to shed, so the flag is not a precondition for it. That happens
to unwedge the same state, and it is true independently of how c17 got here.

The alternative was to clear the residue instead of accepting it, by rolling c17's
VM out of band or via rollback mode. Out of band means an unreviewed production
mutation outside the wave. rollback does not work here either, and that is worth
recording: c17 still serves the rollback image, so ROLLBACK_RESUME is true, and
the resume path both requires a non-draining predecessor and never restarts the
VM, so it could not clear the flag even if it were let through.

A wider gap I did not fix. The same wedge exists for a general cell whose
apply fails between the drain and the terraform apply. It ends up migration-only
and draining on the rollback image; apply refuses the admission class, and
rollback classifies it as a resume and refuses the draining. Nothing in this PR
changes that, and it needs its own decision about whether ROLLBACK_RESUME should
be distinguishable from a wave that stopped before its template apply. Raising it
rather than widening this change.

On the pool question. EXPECTED_DATABASE_POOL_MAX being empty is correct for
c17 and c18, and no change is needed. In variables.tf a cell's region defaults
to us-central1 and database_pool_max to 10; c17 and c18 set neither, so
include_database_pool_max is false and their template emits no pool line. The
captured template from the run confirms it: no ORCA_RELAY_DATABASE_POOL_MAX and
no ORCA_RELAY_CELL_REGION. The pool-16 pin is Asia-only, as suspected. This is
already held by a test: the census asserts every approved cell's resolved pool
equals what production.tfvars carries.

Linked Issue

N/A - operational follow-up to #21307 and #21314.

Visual Proof

N/A. No UI. This changes a GitHub Actions rollout workflow.

Testing

All from cloud/.

  • pnpm test — 622 pass, 0 fail in the dev-script suite; 156 pass, 0 fail in
    pretest; relay-ops 134, relay 717 passed / 121 skipped, push 139 passed / 4
    skipped, 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 new census test extracts the real decision block from the workflow and runs it
under bash for all eight combinations of mode and entry class. Every general-cell
and rollback row asserts the value the old expression produced, which is what holds
those paths unchanged:

mode entry class resume precheck admission precheck draining drainingOk
apply migration-only false migration-only either true
apply general false general forbidden false
verify migration-only false migration-only either true
verify general false general forbidden false
rollback general false general-or-migration-only either true
rollback general true general-or-migration-only either false
rollback migration-only false general-or-migration-only either true
rollback migration-only true general-or-migration-only either false

Only the two migration-only apply and verify rows differ from main.

A second test asserts both predecessor checks read the single decision, that the
old inline expression is gone, and that the post-apply and post-restore steps still
require the fresh VM not to be draining.

Not verified: c17's live draining value right now. The diagnosis rests on the two
run logs, which show the check passing at 00:25:59, the drain at 00:26:01, and the
failure at 00:46:21.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Please look at the Why section rather than the diff. The brief asked for this
change on a premise the logs contradict, and I implemented the mechanism with a
different justification. If you disagree that "a cell with no hosts has nothing to
shed" is enough to drop the precondition, the alternative is clearing the residue
by replacing c17's VM, and this PR should be closed.

The same-cap job workflow is in TRUSTED_EVIDENCE_CODE_PATHS, so merging
invalidates any canary authority sealed before it.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Security: the relaxation is scoped to cells the selector holds in migration-only,
which take no new hosts. Every end-state check is unchanged, including the two that
require the replacement VM not to be draining and the one that requires a new
incarnation.

Backwards compatibility: every general-cell and rollback path keeps the value it
had, held by the table above.

Cross-platform, SSH, mobile, performance: N/A. CI-only.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…hosts

c17's canary stopped at the pre-apply predecessor check with
`runtime predecessor mismatch fields=draining`. The flag is residue: the
previous canary (run 35290908836) drained c17 at 00:26:01, its terraform apply
then failed, and the failsafe re-isolates without restarting the VM, so nothing
cleared it. The same run had passed this very check a second earlier, which is
what proves a parked cell is not draining at rest.

Draining means connections are being shed, and a migration-only cell holds
none, so the flag is not a precondition there. Accept it on entry for that
class only. The replacement VM is still required not to be draining, on every
path, and the incarnation check still proves it was replaced.

Both predecessor checks now read one decision instead of computing the rule
twice, so the assertion and its diagnostic cannot disagree. Every general-cell
and rollback path keeps the value it had; a census test runs the real block
over all eight mode and class combinations to hold that.
@pullfrog

pullfrog Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

This run was cancelled 🛑

The workflow was cancelled before completion. Please check the link below for details.

Pullfrog  | View workflow run | via Pullfrog | 𝕏

@Jinwoo-H
Jinwoo-H merged commit 27bddc6 into main Sep 18, 2026
25 of 26 checks passed
@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The production same-cap workflow now allows migration-only cells to pass the draining precheck. It computes PREDECESSOR_DRAINING_OK and uses it in both predecessor checks. New tests cover mode, entry admission, and rollback-resume combinations. Documentation describes the different handling for drained and migration-only cells.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 34731

Clarify the rollback exception so operators do not reject a supported failed-canary recovery state.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed and covers the change, rationale, testing, risks, and checklist. However, the required Linked Issue field is marked N/A instead of identifying one issue with the required l… Replace the Linked Issue entry with a specific linked issue, such as "Fixes #21307" or "Fixes #21314", as required by the repository template. Retain the other related issue reference in the explanation if needed.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main workflow change: allowing a drained predecessor for a cell with no hosts.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is detailed and covers the change, rationale, testing, risks, and checklist. However, the required Linked Issue field is marked N/A instead of identifying one issue with the required linkage format.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 9549d60a-78ed-4fe9-9f00-11f01d360b8a

📥 Commits

Reviewing files that changed from the base of the PR and between acedcf2 and 3473135.

📒 Files selected for processing (3)
  • .github/workflows/cloud-deploy-relay-production-same-cap-job.yml
  • cloud/dev/scripts/relay-same-cap-script-census.test.mjs
  • cloud/docs/relay-workflows.md

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Comment on lines +395 to +399
A drained cell is refused before a roll, because draining means something is already
shedding its connections. A migration-only cell has none to shed, so the flag decides nothing
there and is accepted on entry; the replacement VM is still required not to be draining, and
the incarnation check still proves it was replaced. That also unwedges the state a failed
canary leaves behind, where the wave's own drain set the flag and no restart followed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '360,475p' .github/workflows/cloud-deploy-relay-production-same-cap-job.yml
sed -n '385,410p' cloud/docs/relay-workflows.md
sed -n '515,590p' cloud/dev/scripts/relay-same-cap-script-census.test.mjs

Repository: stablyai/orca

Length of output: 12487


Document the predecessor-draining rule for rollback.

The workflow accepts a drained predecessor for non-resume rollback, regardless of entry class. It rejects a drained predecessor for rollback-resume, and for apply or verify when the entry class is general. The failed-canary sentence hints at the non-resume case, but it does not name the rollback exception and conflicts with the absolute “before a roll” statement.

Proposed documentation change
-A drained cell is refused before a roll, because draining means something is already
-shedding its connections. A migration-only cell has none to shed, so the flag decides nothing
-there and is accepted on entry; the replacement VM is still required not to be draining, and
-the incarnation check still proves it was replaced. That also unwedges the state a failed
-canary leaves behind, where the wave's own drain set the flag and no restart followed.
+For `apply` and `verify`, a drained general cell is refused before a roll because
+draining means it is already shedding connections. A migration-only cell has none to shed,
+so it is accepted on entry. A non-resume `rollback` accepts a drained predecessor for either
+entry class, including the state a failed canary can leave behind. A rollback-resume requires
+the predecessor not to be draining. The replacement VM is still required not to be draining,
+and the incarnation check still proves replacement after a restart.
📝 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.

Suggested change
A drained cell is refused before a roll, because draining means something is already
shedding its connections. A migration-only cell has none to shed, so the flag decides nothing
there and is accepted on entry; the replacement VM is still required not to be draining, and
the incarnation check still proves it was replaced. That also unwedges the state a failed
canary leaves behind, where the wave's own drain set the flag and no restart followed.
For `apply` and `verify`, a drained general cell is refused before a roll because
draining means it is already shedding connections. A migration-only cell has none to shed,
so it is accepted on entry. A non-resume `rollback` accepts a drained predecessor for either
entry class, including the state a failed canary can leave behind. A rollback-resume requires
the predecessor not to be draining. The replacement VM is still required not to be draining,
and the incarnation check still proves replacement after a restart.

ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…hosts (stablyai#21315)

c17's canary stopped at the pre-apply predecessor check with
`runtime predecessor mismatch fields=draining`. The flag is residue: the
previous canary (run 35290908836) drained c17 at 00:26:01, its terraform apply
then failed, and the failsafe re-isolates without restarting the VM, so nothing
cleared it. The same run had passed this very check a second earlier, which is
what proves a parked cell is not draining at rest.

Draining means connections are being shed, and a migration-only cell holds
none, so the flag is not a precondition there. Accept it on entry for that
class only. The replacement VM is still required not to be draining, on every
path, and the incarnation check still proves it was replaced.

Both predecessor checks now read one decision instead of computing the rule
twice, so the assertion and its diagnostic cannot disagree. Every general-cell
and rollback path keeps the value it had; a census test runs the real block
over all eight mode and class combinations to hold that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant