Roll back when
The change is isolated, a known-good artifact still exists, the schema is compatible with the old code, and users are actively impacted.
Checkout started returning 500 at 01:40. The rollback command is one line; the decision is not. A rollback restores code. It does not restore schema, cache, queue offsets, or the config that changed in the same window.
This page is free. It covers how to choose between rollback and fix-forward, how to check that the target still exists, and what to verify after the command returns.
The change is isolated, a known-good artifact still exists, the schema is compatible with the old code, and users are actively impacted.
The rollback reopens a security hole, the migration already wrote data the old code cannot read, or the fix is a one-line config change you can verify in minutes.
If you cannot state the blast radius in one sentence, do not run the command. Rolling back is a deploy with its own failure modes.
Target revision, expected effect, who is watching, and the abort condition. Two minutes of writing prevents a second incident.
| Command | What it tells you |
|---|---|
| kubectl rollout history deployment/<name> | Revisions the controller still retains; the one you want may already be pruned. |
| kubectl rollout status deployment/<name> --timeout=30s | Whether a rollout is still in progress. Rolling back mid-rollout races the controller. |
| kubectl get deploy <name> -o jsonpath='{..image}' | The image actually running, not the tag in git. |
| kubectl diff -f <manifest> | Drift between the repo and the cluster, including config you did not deploy. |
| wrangler deployments list | Worker versions and timestamps available for rollback. |
| wrangler pages deployment list | Pages production deployments. Preview deployments are not valid rollback targets. |
| git log --oneline <last-good>..HEAD -- <path> | The change set, including migrations and config, not just application code. |
| curl -sS -o /dev/null -w '%{http_code} ' https://host/health | The symptom you are rolling back, measured before and after. |
| # | Failure mode | What you see | What to do |
|---|---|---|---|
| 1 | Code rolls back, the schema does not | The old code starts returning column "..." does not exist or a not-null violation. | Use expand/contract migrations, roll back the app first, and keep the previous release compatible with the new schema for one deploy. Test the previous image against the migrated database before you need it. |
| 2 | The rollback target no longer exists | error: unable to find specified revision 3; Pages refuses a preview deployment as a target. | Pin and retain several known-good artifacts, record the deployment ID in the incident channel, and never assume "the previous version" is listed. |
| 3 | Config and secrets are not versioned with the artifact | The old image starts but calls the new upstream, or crashes on a variable the old code never needed. | Roll back config with the code. Diff the running environment, not just the image, and keep env changes in the same reviewed change. |
| 4 | The cache keeps serving the bad asset | HTML is old, hashed JS returns 404, or cf-cache-status: HIT on a file you just replaced. | Use content-hashed filenames, purge by tag or URL, and verify with a cache-busting request from a second network. |
| 5 | Stateful side effects do not rewind | Messages already consumed, emails sent, payments captured, webhooks delivered. | Decide before rolling back. Make handlers idempotent, use an outbox, and check queue lag and dead letters after the rollback. |
| 6 | Partial rollback across services | The API is old and the worker is new; a contract field disappears and the worker retries forever. | Version the contract, roll back in reverse dependency order, and watch retries and lag, not only pod status. |
| 7 | Rollback during an in-flight rollout | The undo command returns success, but pods keep churning and a new rollout starts from the old template. | Wait for the rollout to settle or pause it first (kubectl rollout pause), then undo and watch the status. |
| Platform | What a rollback does | What to watch |
|---|---|---|
| Kubernetes Deployment | Rolling replacement; old and new pods coexist and the undo waits for readiness. | Readiness, restarts, and whether the controller actually moved the template. |
| Cloudflare Workers | Instant and global. A split deployment collapses to 100% on the version you choose. | The version ID, and whether traffic was split before the rollback. |
| Cloudflare Pages | Instant and global for the static build. The HTML and the assets it references must move together. | Asset hashes, cache status, and any function or redirects file in the build. |
| Database migration | Affects every running version at once; the app rollback does not undo it. | Whether old code can read the new schema, and whether a down migration really restores data. |
Not "roll back the deploy": the command, the target ID, and the person who owns it. Put it in the runbook next to the deploy steps.
A Pages rollback is seconds; a Kubernetes undo can take minutes and stall on readiness. Know which one you have.
Retention policies delete the thing you need. Pin the image digest or deployment ID you would roll back to.
A successful command is not a working site. Hit the failed path and read one log line before declaring recovery.
| Check | Why |
|---|---|
| The failed request now succeeds, from a second network | Your cache or your laptop can hide the result. |
| The running version matches the target | A successful command and a moved template are different facts. |
| Error rate, latency and queue lag are back to baseline | Rollback can move the failure rather than remove it. |
If the config changed with the deploy, yes: roll it back explicitly and restart the process that reads it. If the config lives in the same artifact, roll back the artifact.
Then rollback is not the safe move. Prefer a fix-forward patch that keeps the new schema, or restore from a snapshot with the data loss that implies. Decide with the data owner, not alone at 2am.
Enough to cover the longest incident plus the slowest deploy: usually the last five to ten, pinned by digest rather than tag. Retention is a policy, not a default.
Yes. It is a production change made under pressure, and the next one will be easier if you record what the target was and what did not move with it.
The paid runbooks cover the surrounding changes: production defaults, cache behaviour, certificate rollovers, and the checks that only fail on a real domain.
This page is free, no checkout. Paid runbooks are $9.99 each and covered by the 7-day refund policy at /runbooks/refund.