Skip to content

fix(relay): keep the backend service out of the same-cap wave; the capacity role cannot update it - #22140

Merged
Jinwoo-H merged 1 commit into
mainfrom
same-cap-drop-backend-target
Sep 22, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
same-cap-drop-backend-target

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​30 $\color{#cf222e}{\Huge{\mathbf{−}}}$​49 $\color{#cf222e}{\Huge{\mathbf{−}}}$​19
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​11 $\color{#cf222e}{\Huge{\mathbf{−}}}$​26 $\color{#cf222e}{\Huge{\mathbf{−}}}$​15

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.yml plans and applies only
this cell's instance template and its managed instance group again:

  • Both terraform plan invocations (the resume plan and the apply plan) lose
    -target=google_compute_backend_service.relay_gce_cell["${TARGET_CELL_ID}"].
  • The resume gate accepts exactly a converged plan or .changes == 2, the
    template-and-MIG rollback-image drift, again. The .changes == 0 and backendUpdate
    clause and the backend-only terraform apply on resume are gone, so a resume applies
    nothing, which is what a resume means.
  • A comment at the resume plan records why the backend service is deliberately absent.

cloud/dev/scripts/validate-relay-capacity-plan.mjs is unchanged in behaviour. It still
bounds 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 if
some 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

Error: Error updating BackendService ...: googleapi: Error 403: Required 'compute.backendServices.update' permission

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-c7 is 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 orcaRelayProductionCapacity in cloud/infra/terraform/relay-github-actions.tf
lists its permissions explicitly and never gained compute.backendServices.update, so
the 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:

  1. Grant the permission. It is one line in the custom role, but the role lives in the
    Terraform root, and a root plan pulls in every
    google_compute_instance_template.relay_gce_cell; standing image drift turns all of
    them into replacements, which would roll the whole fleet. That apply needs its own
    review and its own window.
  2. Remove the target, which is this PR. It is contained in one workflow file, restores a
    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_seconds from #21848 and the
log_config block that has been declared but never applied both wanted a per-cell apply
path, 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 --test from cloud/. No install was needed; these are plain node:test
.mjs files.

node --test dev/scripts/relay-same-cap-script-census.test.mjs \
  dev/scripts/relay-regional-rehome-workflow.test.mjs \
  dev/scripts/validate-relay-capacity-plan.test.mjs
# 40 pass, 0 fail

Every test that reads this workflow, so a stale text pin cannot hide:

node --test dev/scripts/relay-admin-endpoint-retry-workflow.test.mjs \
  dev/scripts/relay-production-identity-boundaries.test.mjs \
  dev/scripts/relay-regional-rehome-workflow.test.mjs \
  dev/scripts/relay-monitor-evidence.test.mjs \
  dev/scripts/relay-same-cap-shadow-gate.test.mjs \
  dev/scripts/relay-production-same-cap-wave.test.mjs \
  dev/scripts/relay-gce-terraform-fence.test.mjs \
  dev/scripts/relay-public-workflow-contract.test.mjs \
  dev/scripts/workload-identity-attribute-conditions.test.mjs
# 116 pass, 0 fail

Test changes, all in cloud/dev/scripts/:

  • relay-same-cap-script-census.test.mjs: the target census expects the template and MIG
    and a target count of two; a new case asserts the workflow never names
    google_compute_backend_service anywhere. The resume-outcome test runs the shipped
    predicate and now asserts accept-or-refuse with no apply branch, and the stranded-roll
    test drops its unreachable backendUpdate case.
  • relay-regional-rehome-workflow.test.mjs: the resume-gate regex pins
    jq -e '.changes == 2', and the resume step is asserted to contain no terraform apply
    at all.
  • Validator tests are untouched; they still describe the bound the validator keeps.

Both edited shell blocks were extracted from the YAML and checked with bash -n.

Not run locally: pnpm lint and root gates. The root oxlint config excludes cloud/,
and any pnpm run in this worktree triggers a full install, so CI covers those.

  • 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

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

  • 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)

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
@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: 48d000c0-1f9c-4fc3-a53a-2c3eb9e91d7c

📥 Commits

Reviewing files that changed from the base of the PR and between b964336 and 2ab2650.

📒 Files selected for processing (4)
  • .github/workflows/cloud-deploy-relay-production-same-cap-job.yml
  • cloud/dev/scripts/relay-regional-rehome-workflow.test.mjs
  • cloud/dev/scripts/relay-same-cap-script-census.test.mjs
  • cloud/dev/scripts/validate-relay-capacity-plan.mjs

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


📝 Walkthrough

Walkthrough

The same-cap Relay production workflow no longer targets google_compute_backend_service. Its plans target only the instance template and managed instance group. Resume validation accepts exactly two changes and performs no Terraform apply. Tests enforce the target list, reject backend-service references, and reject other change counts. Validator documentation now distinguishes same-cap plans from backend-targeting callers.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 2ab26

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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… 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 identifies the primary change: removing the backend service from the same-cap wave because the capacity role cannot update it.
Description check ✅ Passed The description is detailed and covers the change, reason, testing, impact, and checklist. The Linked Issue section is incomplete because the template requires an issue link, but this is the only nota…
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: Docstring Coverage

Explanation

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.)

  • 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.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Same-cap wave targets narrow to the template and MIG — both terraform plan invocations in cloud-deploy-relay-production-same-cap-job.yml drop the google_compute_backend_service target, 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 — the changes == 0 and backendUpdate > 0 clause and the embedded terraform apply of 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.mjs keeps its same-cap backend bound unchanged; takeCellBackendUpdate now 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 apply in the resume step, the exact .changes == 2 predicate, and that the workflow never names google_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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit bf8d63b into main Sep 22, 2026
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