Skip to content

fix(relay): let a same-cap cell plan delete the deposed template a failed wave left behind - #22170

Merged
Jinwoo-H merged 1 commit into
mainfrom
same-cap-cell-allow-deposed-template
Sep 22, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
same-cap-cell-allow-deposed-template

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​74 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​74
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6

ELI5

When we roll one relay cell, Terraform builds the new machine template before
throwing the old one away. If the roll dies in between, the old template is left
half-removed in Terraform's records. A safety check then refused every later plan
for that cell, because it saw a third thing changing and only expected two. The
cell got stuck. This teaches the safety check that cleaning up exactly that
leftover is allowed.

What Changed

Before: production run 35684694704 (cell production-gce-c7) created template
orca-cloud-relay-gce-c7-20260922035935010000000001, pointed the managed instance
group at it, then failed on an unrelated permission error (a backend-service
target since removed by #22140). The September 18 template stayed in Terraform
state as a deposed object. Every wave or rollback planned for that cell from
then on included ... (deposed object 4cb19f83) will be destroyed, and
cloud/dev/scripts/validate-relay-capacity-plan.mjs refused it with cell plan must change only the exact instance template and MIG. Recovery run 35698133226
applied nothing and the cell stayed stranded until someone edited Terraform state
by hand.

After: the same plan is accepted. The wave replaces the template, updates the
group, and deletes exactly one deposed template at that same cell's address.

Mechanism: cellPlan already recognised deposed changes at the cell's template
address (obsoleteTemplates), but allowsObsoleteTemplates was gated on
config.mode === 'same-cap-image'. The same-cap wave job calls the validator
with --mode same-cap-cell. That gate now also admits same-cap-cell, capped at
one deposed object, matching the bound convergenceCellPlan already applies to
every non-image mode. The delete-only requirement is unchanged: any other action
on a deposed object is still refused, as is a deposed delete at another cell's
address.

The reported count is split rather than grown. A template + group + deposed
delete plan would otherwise report changes: 3 and fail the job's
jq -e '.changes == 2' resume gate. In same-cap-cell mode the validator now
reports changes: 2 plus obsoleteTemplates: 1, the same way the cell backend
update is already lifted out of changes. A stranded cell whose only remaining
plan item is the deposed delete now reports changes: 0, so the job's explicit
MIG roll still fires and clears the drain flag. same-cap-image output is
untouched: it keeps its own total and names obsolete deletes through
changeKind, which two staging workflows gate on, and two of their readbacks
assert changes == 0 as proof of full convergence.

Why

Deleting a deposed template is safe. The group and the running instance reference
the current template, and GCE refuses to delete a template that is still in use.
The alternative is terraform state rm on the deposed object before each wave.
That is manual, needs state write access during an incident, and drops a real
resource from state instead of destroying it, leaving an orphaned template in the
project. Letting the wave plan its own cleanup keeps the fail-closed validator in
charge of what the apply may touch.

Linked Issue

N/A. Found while recovering production cell production-gce-c7 from the failed
wave run 35684694704.

Visual Proof

N/A. Command-line validator used by a deploy workflow; no user interface.

Testing

node --test dev/scripts/*.test.mjs from cloud/: 771 passing, 1 failing.
The one failure, relay-load-control-peer.test.mjs, is a missing tweetnacl
dependency in a fresh worktree with no install, unrelated to this change.

New cases in cloud/dev/scripts/validate-relay-capacity-plan.test.mjs, built on
that file's existing same-cap fixtures:

  • template create+delete, group update, one deposed delete at the cell's address,
    same-cap-cell -> accepted, changes: 2, obsoleteTemplates: 1
  • the same deposed object with ['update'] instead of ['delete'] -> refused
  • a deposed delete at production-gce-c8's template address -> refused
  • two deposed deletes in same-cap-cell -> refused
  • only the deposed delete left -> accepted, changes: 0, obsoleteTemplates: 1

same-cap-image assertions in that file are unchanged and still pass, as do
relay-same-cap-script-census.test.mjs (which pins the job's changes == 2 and
changes == 0 predicates) and relay-regional-rehome-workflow.test.mjs.

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

AI Disclosure

Review

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

No security, cross-platform, SSH, or mobile surface. The validator is Node run by
a GitHub Actions job. Backwards compatible for same-cap-image callers, whose
output shape is unchanged; the new obsoleteTemplates key appears only in
same-cap-cell mode and only when a deposed template is present.

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)

…iled wave left behind

A same-cap wave applies with create_before_destroy. When run 35684694704 died
after the new template was made, the previous template stayed in Terraform state
as a deposed object, so every later plan for that cell carried its delete. The
plan validator only tolerated deposed deletes in same-cap-image mode, so the
recovery run 35698133226 was refused with "cell plan must change only the exact
instance template and MIG" and the cell was stranded.

Allow exactly one deposed delete at the cell's own template address in
same-cap-cell mode too, mirroring the one-deposed bound the convergence path
already applies to non-image modes. Report it as `obsoleteTemplates` rather than
in `changes`, the way the cell backend update is already split out, so the job's
`changes == 2` resume gate and `changes == 0` stranded roll keep reading the
template-and-MIG count.

Claude-Session: ced32ebb-7155-4413-adad-1eccd14c2010
@pullfrog

pullfrog Bot commented Sep 22, 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 | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 3489e928-b5fb-4ac6-b526-02c110043e6c

📥 Commits

Reviewing files that changed from the base of the PR and between 90d363a and 628ae3e.

📒 Files selected for processing (2)
  • cloud/dev/scripts/validate-relay-capacity-plan.mjs
  • cloud/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.


📝 Walkthrough

Walkthrough

The validator now allows one valid obsolete instance-template deletion in same-cap-cell plans. It excludes that deletion from changes and reports it through obsoleteTemplates. It preserves same-cap-image counting and classification. Tests cover valid deletions, invalid actions or cell addresses, multiple obsolete templates, and zero-change plans.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 628ae

The validator narrowly permits one valid deposed-template deletion, reports it separately from active changes, and preserves existing behavior; supplied tests cover the supported and rejected plan shapes, leaving no concrete merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: allowing same-cap cell plans to delete a deposed template left by a failed wave.
Description check ✅ Passed The description follows the required structure and clearly explains the problem, behavior change, rationale, testing, compatibility, and checklist status. The Linked Issue section contains N/A instead…
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.
  • 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.

@Jinwoo-H
Jinwoo-H merged commit 8568d77 into main Sep 22, 2026
26 of 27 checks passed
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