Repository navigation
fix(relay): let a same-cap cell plan delete the deposed template a failed wave left behind - #22170
Conversation
…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
|
This run was cancelled 🛑 The workflow was cancelled before completion. Please check the link below for details. |
|
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 configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe validator now allows one valid obsolete instance-template deletion in Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to 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)
✅ 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 |

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 templateorca-cloud-relay-gce-c7-20260922035935010000000001, pointed the managed instancegroup 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, andcloud/dev/scripts/validate-relay-capacity-plan.mjsrefused it withcell plan must change only the exact instance template and MIG. Recovery run 35698133226applied 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:
cellPlanalready recognised deposed changes at the cell's templateaddress (
obsoleteTemplates), butallowsObsoleteTemplateswas gated onconfig.mode === 'same-cap-image'. The same-cap wave job calls the validatorwith
--mode same-cap-cell. That gate now also admitssame-cap-cell, capped atone deposed object, matching the bound
convergenceCellPlanalready applies toevery 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: 3and fail the job'sjq -e '.changes == 2'resume gate. Insame-cap-cellmode the validator nowreports
changes: 2plusobsoleteTemplates: 1, the same way the cell backendupdate is already lifted out of
changes. A stranded cell whose only remainingplan item is the deposed delete now reports
changes: 0, so the job's explicitMIG roll still fires and clears the drain flag.
same-cap-imageoutput isuntouched: it keeps its own total and names obsolete deletes through
changeKind, which two staging workflows gate on, and two of their readbacksassert
changes == 0as 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 rmon 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-c7from the failedwave run 35684694704.
Visual Proof
N/A. Command-line validator used by a deploy workflow; no user interface.
Testing
node --test dev/scripts/*.test.mjsfromcloud/: 771 passing, 1 failing.The one failure,
relay-load-control-peer.test.mjs, is a missingtweetnacldependency in a fresh worktree with no install, unrelated to this change.
New cases in
cloud/dev/scripts/validate-relay-capacity-plan.test.mjs, built onthat file's existing same-cap fixtures:
same-cap-cell-> accepted,changes: 2,obsoleteTemplates: 1['update']instead of['delete']-> refusedproduction-gce-c8's template address -> refusedsame-cap-cell-> refusedchanges: 0,obsoleteTemplates: 1same-cap-imageassertions in that file are unchanged and still pass, as dorelay-same-cap-script-census.test.mjs(which pins the job'schanges == 2andchanges == 0predicates) andrelay-regional-rehome-workflow.test.mjs.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
No security, cross-platform, SSH, or mobile surface. The validator is Node run by
a GitHub Actions job. Backwards compatible for
same-cap-imagecallers, whoseoutput shape is unchanged; the new
obsoleteTemplateskey appears only insame-cap-cellmode and only when a deposed template is present.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)