Repository navigation
fix(relay): keep the backend service out of the same-cap wave; the capacity role cannot update it - #22140
Conversation
The capacity role the same-cap wave authenticates as, orcaRelayProductionCapacity, has no compute.backendServices.update. Since #21860 added `google_compute_backend_service.relay_gce_cell["${TARGET_CELL_ID}"]` to both of the job's plan invocations, every wave has therefore created the new instance template, modified the MIG, and then failed 403 on the backend, leaving the cell isolated with its trust probe, admission restore, and shadow gate all skipped. Run 35684694704 on production-gce-c7 is the first one that hit it in production. Drop the backend target from both plans and restore the resume gate to exactly `.changes == 2` (the template-and-MIG rollback-image drift) or a converged plan, removing the backend-only resume apply #21865 added on top. A resume applies nothing again, which is what a resume means. The validator keeps its bound on a cell backend update, so it still reports one and refuses anything wider, but a wave plan can no longer contain one. The drain timeout from #21848 and the log_config from #21860 need a root apply by a principal that holds the permission; granting the capacity role that permission is itself a root apply, so it can follow as its own change rather than blocking every wave in the meantime. Claude-Session: ced32ebb-7155-4413-adad-1eccd14c2010
|
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 (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe same-cap Relay production workflow no longer targets Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The workflow now targets only the selected template and MIG, rejects unexpected resume plans, and avoids the backend permission failure. No actionable merge-blocking risk is established. 🚥 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 2 functions across 3 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.
✅ No new issues found.
Reviewed changes
- Same-cap wave targets narrow to the template and MIG — both
terraform planinvocations incloud-deploy-relay-production-same-cap-job.ymldrop thegoogle_compute_backend_servicetarget, restoring the pre-Sep-20 plan shape (.github/workflows/cloud-deploy-relay-production-same-cap-job.yml:605,:664). - Resume gate tightens to
.changes == 2— thechanges == 0 and backendUpdate > 0clause and the embeddedterraform applyof a backend-only resume plan are removed, so a resume applies nothing (.github/workflows/cloud-deploy-relay-production-same-cap-job.yml:646). - Validator comment only —
validate-relay-capacity-plan.mjskeeps its same-cap backend bound unchanged;takeCellBackendUpdatenow always returns an empty list because no plan carries a backend change (cloud/dev/scripts/validate-relay-capacity-plan.mjs:304). - Tests repinned — census and rehome-workflow tests now assert two targets, no
terraform applyin the resume step, the exact.changes == 2predicate, and that the workflow never namesgoogle_compute_backend_service.
I read the full diff and traced both plan/apply paths and the resume/stranded/rollback stage split. The removed resume branch is genuinely unreachable now: -target on the template and MIG cannot pull in the backend service (the backend depends on the MIG, not the reverse), so backendUpdate is always empty. The new .changes == 2 predicate is a strict subset of the old one, so no accepted resume scenario is lost, and the census, rehome-workflow, and validator suites pass locally (40 + 116, 0 fail).
ℹ️ Stale comment after the removal
cloud/dev/scripts/validate-relay-capacity-plan.test.mjs:1220 still reads "Only the same-cap wave targets a backend service; every other mode still refuses one." No wave targets a backend service any more, so the first clause is no longer accurate. The assertion it comments on (a cell-mode plan with a backend is refused) is unaffected, and the validator's own explanatory comment was already updated in this PR — this test comment just wasn't in the diff.
Technical details
# Refresh one stale clause in a test comment
## Affected sites
- `cloud/dev/scripts/validate-relay-capacity-plan.test.mjs:1220` — "Only the same-cap wave targets a backend service" is now false; the validator still *accepts* a same-cap backend update, but no production caller targets one.
## Required outcome
- The comment should describe what the following assertion actually proves: a non-same-cap mode still refuses a backend change (the validator's bound), not that the wave targets one.
## Open questions for the human
- Whether the now-unreachable-in-production `takeCellBackendUpdate` path is intended as a long-term guard or should be pruned in a follow-up. Keeping it is a reasonable, documented choice; flagging only so the decision is visible.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
When we roll one Relay cell to a new image, a GitHub Actions job logs in as a
restricted identity that is only allowed to touch two things for that one cell: the
recipe for its virtual machines, and the group that runs them. Two weeks ago we added a
third thing to that list, the cell's load balancer. Nobody checked that the restricted
identity is allowed to change a load balancer. It is not. So every roll now gets most of
the way through, is told "you are not allowed to do that", and stops with the cell still
taken out of service. This removes the load balancer from the list, which is exactly how
it worked before.
What Changed
.github/workflows/cloud-deploy-relay-production-same-cap-job.ymlplans and applies onlythis cell's instance template and its managed instance group again:
terraform planinvocations (the resume plan and the apply plan) lose-target=google_compute_backend_service.relay_gce_cell["${TARGET_CELL_ID}"]..changes == 2, thetemplate-and-MIG rollback-image drift, again. The
.changes == 0 and backendUpdateclause and the backend-only
terraform applyon resume are gone, so a resume appliesnothing, which is what a resume means.
cloud/dev/scripts/validate-relay-capacity-plan.mjsis unchanged in behaviour. It stillbounds a cell backend update to this cell and to the reviewed drain and request-logging
attributes and still reports it as
backendUpdate, so nothing wider can slip through ifsome future caller does target one. Only its explanatory comment changed, because a wave
plan can no longer carry a backend change at all.
Before, as the operator sees it: since Sep 20 every production same-cap wave creates the
new instance template, modifies the MIG, and then fails the "Apply only the selected
same-cap template and MIG" step with
The failure lands after the cell has already been isolated and drained, so the trust
probe, the admission restore, and the shadow health gate are all skipped and the cell is
left out of service. Run 35684694704 on
production-gce-c7is the evidence.After: a wave plans and applies the template and the MIG only, as it did before Sep 20,
and reaches its verification and restore steps. That run can be resumed for c7.
No Terraform and no IAM role changed here.
Why
The 403 is not a transient error and it is not recoverable inside the wave. The custom
role
orcaRelayProductionCapacityincloud/infra/terraform/relay-github-actions.tflists its permissions explicitly and never gained
compute.backendServices.update, sothe wave's service account cannot update a backend service at all. Every wave will keep
failing at the same point until the target is removed or the permission is granted.
Two ways to fix it:
Terraform root, and a root plan pulls in every
google_compute_instance_template.relay_gce_cell; standing image drift turns all ofthem into replacements, which would roll the whole fleet. That apply needs its own
review and its own window.
shape that ran many waves successfully before Sep 20, and unblocks tonight's roll now.
This takes option 2 because it unblocks the waves immediately and costs nothing that the
waves were relying on. What it gives up is the convenience of the reason the target was
added in the first place: the 60-second
connection_drain_secondsfrom #21848 and thelog_configblock that has been declared but never applied both wanted a per-cell applypath, and the wave was the only one available. Those settings still need an apply, and
they still need a principal that holds the permission, so they go out in a root apply
(or in a wave again, after the role grant lands). Neither of them changes how a cell
serves traffic today, which is why they can wait and the waves cannot.
Linked Issue
N/A — operational regression found in production run 35684694704, no tracking issue.
Visual Proof
N/A — CI workflow and test changes only, no user-visible surface.
Testing
macOS,
node --testfromcloud/. No install was needed; these are plainnode:test.mjsfiles.Every test that reads this workflow, so a stale text pin cannot hide:
Test changes, all in
cloud/dev/scripts/:relay-same-cap-script-census.test.mjs: the target census expects the template and MIGand a target count of two; a new case asserts the workflow never names
google_compute_backend_serviceanywhere. The resume-outcome test runs the shippedpredicate and now asserts accept-or-refuse with no apply branch, and the stranded-roll
test drops its unreachable
backendUpdatecase.relay-regional-rehome-workflow.test.mjs: the resume-gate regex pinsjq -e '.changes == 2', and the resume step is asserted to contain noterraform applyat all.
Both edited shell blocks were extracted from the YAML and checked with
bash -n.Not run locally:
pnpm lintand root gates. The rootoxlintconfig excludescloud/,and any
pnpm runin this worktree triggers a full install, so CI covers those.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
Security: the wave's targets narrow, so the identity acts on strictly less than before.
Backwards compatibility: this restores the pre-Sep-20 plan shape, so a cell rolled by a
wave since then is not left in a state this cannot plan. Cross-platform, SSH, mobile, and
performance: not applicable, GitHub Actions and Node test scripts only.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)