Skip to content

fix(relay): accept MIG version-name reconciliation and recreate stranded cells without rewriting the MIG - #24373

Merged
Jinwoo-H merged 2 commits into
mainfrom
fix/relay-mig-version-name-drift
Oct 1, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
fix/relay-mig-version-name-drift

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​203 $\color{#cf222e}{\Huge{\mathbf{−}}}$​88 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​115
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​48 $\color{#cf222e}{\Huge{\mathbf{−}}}$​28 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​20

ELI5

When a relay cell gets stuck mid-rollout ("stranded"), the recovery restarts its server with a gcloud command. That command also quietly renamed a label on the cell's server group. The next time Terraform looked at the cell, it wanted to put the label back, and our safety check refused that as an unreviewed change. From then on the cell could be neither upgraded nor rolled back. This PR lets the safety check accept putting things back the way Terraform declares them, and changes the recovery so it no longer renames anything.

What Changed

Before: production-gce-c29's same-cap canary apply (run 36856633548) was refused at "Apply only the selected same-cap template and MIG". The plan's only extra change was the managed instance group (MIG) version name going from 0/2026-10-01 10:41:28... back to primary. Every later apply or rollback for that cell would be refused the same way.

After:

  • Plan validator (cloud/dev/scripts/validate-relay-capacity-plan.mjs): a MIG field may change only when it moves back to the value relay-gce-cells.tf declares. The fields are the version name (primary) and the update policy (type, minimal_action, most_disruptive_allowed_action, replacement_method, max_surge_fixed, max_unavailable_fixed). This applies in every mode that reviews the MIG. It replaces a narrower rule that accepted the version name only when paired with a RESTART to REPLACE policy flip. Any other MIG change, or any field moving away from its declared value, is still refused. A new test reads relay-gce-cells.tf and fails if the validator's declared values drift from it.
    A plan whose only MIG change is such a revert, with the template left in place, is now accepted too. This is c29's stranded-rollback shape, because its template already carries the image it serves.
  • Stranded rollback (.github/workflows/cloud-deploy-relay-production-same-cap-job.yml): instead of rolling-action replace, the job lists the MIG's instances, asserts there is exactly one, and runs recreate-instances on it, then waits for the group to be stable as before. It now does this whenever the template was not replaced, which is fewer than two reviewed changes. Before, it fired only at zero changes, so a label-only reconciliation would have left the instance, and its drain flag, in place. recreate-instances rebuilds the instance from the MIG's current template, which is the template the plan just reviewed, and it does not touch the MIG's version or update policy.
  • Docs (cloud/docs/relay-workflows.md): the stranded recovery description now says what it does and why it avoids a rolling action.

Why

Putting a field back to its declared value is never a capacity change, so allowing exactly that is safe. The values come from a fixed list that a test ties to the Terraform file. Fixing only the workflow would leave c29, and any other cell an older rolling action touched, permanently blocked. Fixing only the validator would keep producing drift on every stranded recovery. Alternatives considered:

  • Hand-editing the MIG back to primary with gcloud. It unblocks one cell once, needs a production mutation outside the reviewed path, and leaves the cause in place.
  • Making the validator ignore version.name entirely. A label move to an arbitrary value would then pass unreviewed.

This PR touches files in the relay evidence same-code set (validator and same-cap job), so a fresh aggregate monitor run is required after merge before the next same-cap dispatch.

Not changed: a resume rollback still requires either no changes or the template-and-MIG pair. A resume on a cell carrying only the label drift is refused, as before. The stranded and roll paths are the ones that reconcile it.

Linked Issue

N/A, production rollout tooling fix for production-gce-c29.

Visual Proof

N/A. This changes CI workflow and validation script behaviour, with no UI.

Testing

  • node --test over the full cloud/package.json test list: all 652 tests touching this code pass. The one failure, relay-load-control-peer, cannot resolve @orca-cloud/relay-contract in a lane without cloud workspace packages built, and is unrelated.

  • New validator cases cover several plans. A same-cap plan whose MIG diff is the new template plus version name back to primary passes. The same plan with an unrelated MIG change fails. Each update policy field passes when reverting to its declared value and fails when moving away from it.

  • Mutation checks: disabling the declared-value comparison, changing the declared version name, or requiring a template move on a label-only plan each fail the suite.

  • A label-only plan with the template in place passes. The same plan fails with a resize, a second version, or a label moving away from primary. The shipped stranded gate recreates at zero and one changes, and not at two.

  • Workflow shape tests assert the stranded branch uses recreate-instances on the one listed instance, never a rolling action, and waits for stability afterwards. The shipped jq instance filter is run against zero, one, and two instances.

  • Automated tests added/updated

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

Cloud tooling only. There is no desktop, SSH, or mobile impact.

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)

…ded cells without rewriting the MIG

The stranded-rollback recovery ran a gcloud rolling action, which renames the
MIG version outside Terraform. Every later plan for that cell then reverted the
label, and the capacity-plan validator refused the revert as an unreviewed MIG
change, so the cell could be neither rolled nor rolled back.

The validator now accepts a MIG field moving back to what relay-gce-cells.tf
declares (version name and update policy), in every mode, and a test pins those
values to the Terraform file. The stranded branch recreates the cell's single
instance with recreate-instances, which leaves the MIG untouched.

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

pullfrog Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

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

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Critical risk] Changes how production infrastructure recovery recreates instances.

The PR does not appear safe to merge until stranded recovery avoids a second instance recreation after a MIG-only template correction.

Findings

  1. P1 Stranded cell recreated twice ▶

Summary

The PR allows MIG version-name and update-policy reconciliation to declared Terraform values and changes stranded recovery to recreate a single instance without a rolling action.

  • The revised recovery gate also treats every one-change plan as template-stable, although a permitted MIG-only template correction can already replace the instance.

Reviews (2) · Last reviewed commit: "fix(relay): let a label-only MIG plan th..."

… stranded rollback

A stranded rollback whose template is already in place plans only the version
name revert. The validator still required the MIG template to move, so that
plan was refused, and the recreate gate (changes == 0) would have skipped a
plan of one change and left the drain flag set. Require the template move only
when no declared field reconciles, and recreate whenever the template was not
replaced (changes < 2).

Claude-Session: ced32ebb-7155-4413-adad-1eccd14c2010
gcloud compute instance-groups managed rolling-action replace "${MIG_NAME}" \
--project "${GCP_PROJECT_ID}" --zone "${TARGET_ZONE}" \
--replacement-method recreate --max-surge 0 --max-unavailable 1
&& jq -e '.changes < 2' <<< "${PLAN_REVIEW}" >/dev/null; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Stranded cell recreated twice A one-change plan does not always mean the MIG's template stayed put: the validator also accepts a MIG-only template correction. In a stranded rollback, that correction can replace the instance during Terraform apply under the MIG's proactive RECREATE policy. This condition then recreates the instance again, causing a second, unnecessary interruption. Check whether the reviewed MIG template changed instead of relying on the resource-change count.

@Jinwoo-H
Jinwoo-H merged commit 744e772 into main Oct 1, 2026
25 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