Skip to content

fix(deploy): build the previous release so rollback works across a cutover - #408

Merged
corrin merged 1 commit into
mainfrom
shared-disk-space-saving
Jun 25, 2026
Merged

fix(deploy): build the previous release so rollback works across a cutover#408
corrin merged 1 commit into
mainfrom
shared-disk-space-saving

Conversation

@corrin

@corrin corrin commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Follow-up to #407 (merged). Surfaced while rehearsing the legacy→new cutover on msm-uat.

Problem

deploy.sh records PREVIOUS_SHA in deploy-state.env and tells operators to roll back with predeploy_rollback.sh <inst> <prev-sha>, but it never ensured that previous release was built. On a first legacy→new cutover the previous (legacy) SHA has no releases/<sha>, so predeploy_rollback.sh fails its release_complete guard — the supported rollback path is impossible on the first cutover. The cutover itself succeeds cleanly; only rollback was broken.

Fix

A guarded ensure_release "$previous_sha" before the destructive steps in the per-instance loop:

  • No-op on a normal deploy (previous release already complete) — zero steady-state overhead.
  • On a cutover, builds the old release from the shared repo before the switch, so the rollback target always exists (and the migrate-failure rollback hint becomes valid).
  • Fatal if it can't build — don't cut over without a rollback target.

Docs (docs/updating.md, scripts/server/README.md) updated.

Verification

To be confirmed on the msm-uat rehearsal: reset msm-uat to legacy from the on-disk snapshot, pull this fix, re-run deploy.sh msm-uat, confirm releases/<legacy-sha>/.complete builds automatically during the cutover and predeploy_rollback.sh msm-uat <legacy-sha> then completes end-to-end. shellcheck clean.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved rollback reliability during deployment cutovers by ensuring the previous release is available before switching instances.
    • Added a safeguard so rollback targets exist even when transitioning from an older deployment setup.
  • Documentation

    • Updated deployment and rollback instructions to reflect the new behavior and clarify when the extra build step occurs.

…tover

deploy.sh recorded PREVIOUS_SHA and pointed operators at predeploy_rollback.sh <prev-sha>, but never ensured that release was built. On a first legacy->new cutover the previous (legacy) SHA had no releases/<sha>, so the supported rollback path failed its release_complete guard — surfaced rehearsing the msm-uat cutover.

Add a guarded ensure_release "$previous_sha" before the destructive steps: a no-op on a normal deploy (previous release already complete), and on a cutover it builds the old release from the shared repo before the switch, so the rollback target always exists. Fatal if it cannot build — don't cut over without a rollback target.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3025929f-063e-46d2-a856-44c45d2d4398

📥 Commits

Reviewing files that changed from the base of the PR and between 7994d72 and 0773bce.

📒 Files selected for processing (3)
  • docs/updating.md
  • scripts/server/README.md
  • scripts/server/deploy.sh

📝 Walkthrough

Walkthrough

The deploy script now builds the prior release SHA before per-instance cutover when one exists. The rollback guidance in the docs was updated to describe that behavior.

Changes

Rollback target provisioning

Layer / File(s) Summary
Previous release provisioning
scripts/server/deploy.sh, scripts/server/README.md, docs/updating.md
deploy.sh now calls ensure_release for the prior SHA before the backup and cutover sequence, and the rollback documentation and deploy instructions describe that behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A bunny hopped through deploy night air 🐰
Built the old release with gentle care
Cutover twitched, then rolled just right
Now rollback paths gleam soft and bright ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch shared-disk-space-saving

Comment @coderabbitai help to get the list of available commands.

@corrin
corrin merged commit e240881 into main Jun 25, 2026
7 of 9 checks passed
@corrin
corrin deleted the shared-disk-space-saving branch June 25, 2026 04:18
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