Restore and rollback

Go back to an earlier snapshot, with a preflight that checks images, secrets and the target first, and an automatic rollback when a job fails.

Every snapshot is kept, so a deployment can go back to any earlier one: the exact objects that ran before, not a fresh render of an old commit. That is what makes a rollback fast and predictable. The commit might have been force-pushed, a base image might have moved, a Helm chart might have changed; the snapshot is unaffected.

Pick the right tool for what went wrong:

What happenedUse
A bad change was pushed and is runningRestore the last good snapshot, then fix git.
Someone changed the cluster by handDrift: revert, adopt or ignore.
A job failed during an applyAutomatic rollback, if the job asks for it.
A render was held or a prune is waitingHeld snapshots.

You need deployment:rollback on the deployment. Contributors and above on the app's team hold it, and so do the owners of the deployment, its cluster, environment and app.

Restore a snapshot

Open the deployment, then Snapshots, and choose the snapshot to go back to. Its page has Back to an earlier snapshot, which opens the restore dialog. The action is not offered on the snapshot that is running, and a held or discarded snapshot cannot be restored.

The dialog shows, before anything happens:

  • What changes: how many of the deployment's apps change ("1 of 3 apps"), with the kinds of change per app and the commits.
  • Where it runs: the cluster, or every cluster of the environment.
  • Before you restore: the checks, each passing or not. They are the preflight: the cluster and environment still exist, every image is still in its registry, secrets still match their fingerprints, no database migration ran after this snapshot, and no approval is needed. The note "Jobs that run after a deploy run after the restore too" applies.
  • Why restore: a reason, kept in Activity. Optional unless the preflight is bypassed.

The button reads "Restore 1 app on prod" (the number of apps that change and the deployment's target). It queues the restore, and the toast says "Restore queued".

If a check is blocking, the dialog shows Restore blocked and "Blocked by the preflight". A person with restore:bypass can enter a Bypass reason, and the button becomes "Restore with bypass on prod".

A restore makes that snapshot the one the deployment wants and applies it through the normal path: the same operator, the same waves and the same prune limit. Jobs run their undo job in place of their forward work, and a job with no undo is skipped. For a deployment on an environment, the restore is queued for every cluster it holds. A deployment set to Observe only cannot be restored.

A restore does not turn off sync on push

The next push to the tracked branch renders and applies a new snapshot as usual, so after restoring, fix the commit in git (revert it, for example) or the branch will move the deployment forward again. If you need time, set the deployment to Observe only in its settings first.

A restore meets only the guardrails that say they govern restores, and a freeze holds one only if the freeze says so. It is the way back from a bad deploy, so nothing that was written for releases stands in its way. With no such guardrail, who may restore is controlled by deployment:rollback alone.

Guardrails for restores

A guardrail names the actions it governs: release, restore, rollback or emergency apply. A guardrail saved before it named any governs release and rollback, which is what it always did, so none starts to hold restores on its own. Choose Restore under Governs in the guardrail editor to make one apply.

The restore dialog lists every requirement of those guardrails under Rules, each with where it comes from ("Guardrail · Restore baseline: ran here before") and whether it is met. A requirement whose fact is not known holds the restore, as everywhere in Wardn: unknown is never read as a pass. The sample world ships four, and you can change or turn off each:

RuleReadsHolds when
The snapshot ran on this deployment beforesnapshot.previously_live_hereIt never ran here, or the history cannot be read.
At most 30 days oldsnapshot.age_daysIt is older.
No critical vulnerabilitiessnapshot.critical_vulnsOne is found. Nothing scans snapshots yet, so the fact is unknown and the sample rule only warns.
Production needs one approver unless an incident is linkedapprovals.human_count, incident.linked_open_sevNo approver, and no open Sev 1 or 2 incident is linked.

When only the approval holds a restore, the dialog's button reads "Ask for approval" and opens an approval request for that snapshot on that deployment. It is the same request approvals opens for a release: it shows in the approvals inbox as a restore, the person who asked cannot approve it, delegation and Slack approvals work as they do for releases, and the restore goes ahead as soon as the request is approved. Linking a Sev 1–2 incident, or a bypass by someone with restore:bypass, still releases it at once. A restore held by anything besides approvals opens no request.

Past the guardrails

  • Bypass: someone with restore:bypass restores past a hold with a reason. Activity records the reason and the guardrails it skipped.
  • Break-glass: link an open Sev 1 or 2 incident (by id or number, INC-12) and someone with restore:bypass restores past the guardrails that hold it, with a reason. Activity marks it breakGlass with the incident, and the break-glass is recorded as a restore.break_glass event. Slack routes can name that event, but it is not posted to Slack yet. A Sev 3 or lower incident, a closed one, or one that does not exist is not enough.

Restores are never throttled by quotas.

api "$WARDN_API_URL/api/v1/deployments/$DEPLOYMENT_ID/snapshots/$SNAPSHOT_ID/preflight?incidentId=INC-12"   # rules, and whether break-glass is available
api -X POST "$WARDN_API_URL/api/v1/deployments/$DEPLOYMENT_ID/snapshots/$SNAPSHOT_ID/restore" \
  -d '{"incidentId": "INC-12", "reason": "checkout is down"}'

The preflight

Before anything is applied, the preflight checks that the snapshot can still run. Each finding is blocking or a warning.

FindingSeverityMeaning
cluster.gone, environment.goneblockingThe cluster or environment the deployment targets no longer exists.
environment.emptyblockingThe environment has no clusters to restore to.
image.unresolvableblockingThe registry no longer has an image digest in the snapshot, so pods could not pull it.
secret.missingblockingA secret reference the snapshot needs is gone.
secret.changed, secret.stalewarningA referenced secret's value changed since the snapshot ran, or is out of date.
image.unchecked, secret.uncheckedwarningThe server could not check (no registry reachable, secrets not checkable), so it did not.
migration.olderwarningA newer snapshot ran a schema-migration Job (annotated wardn.dev/schema-migration: "true") that this one does not have. Going back may need the database moved back too.

A warning does not stop a restore: read it first. In particular, migration.older is the case where the old code meets a database that has moved on; check that the migration is reversible before you restore.

If the preflight has a blocking finding and no bypass was given, nothing is applied and Activity records deployment.restore_blocked.

Bypass

Someone with restore:bypass can restore anyway, giving a reason:

api -X POST "$WARDN_API_URL/api/v1/deployments/$DEPLOYMENT_ID/snapshots/$SNAPSHOT_ID/restore" \
  -d '{"bypass": {"reason": "the image was rebuilt under the same digest in the mirror"}}'

Both the findings and the reason are recorded in Activity (deployment.restore). A bypass covers this one restore only. restore:bypass is a duty, held by people designated for it; see Roles and grants. It is a different permission from the production branch rule's one-time bypass, release:bypass, which lifts a different check (Guardrails).

Automatic rollback

A job with failurePolicy set to roll_back asks Wardn to restore the previous snapshot when it fails. Wardn restores the newest snapshot that applied successfully, with undo jobs, unless:

  • there is none,
  • its preflight is blocked, or
  • the failed apply was itself a rollback, so a bad rollback cannot loop.

An automatic rollback runs without a person, so it never bypasses a blocking finding. The skipped cases are recorded as deployment.auto_rollback_skipped, and a rollback that runs as deployment.auto_rollback.

What is recorded

deployment.restore, deployment.restore_blocked, deployment.auto_rollback and deployment.auto_rollback_skipped are in Activity with who did it, the snapshot restored from and to, the number of findings and any reason. The snapshot a restore creates has the origin restore or rollback, and shows in the deployment's history as "Rolled back".

The restore dialog also draws Mark the running snapshot as rejected, which needs a pipeline stage that judges the running snapshot. Linked incident takes an incident id or number.

Permissions

ActionPermission
Read the snapshots and the preflightsnapshot:read
Restoredeployment:rollback
Restore past a blocking finding or a guardrailrestore:bypass, with a reason
Restore past guardrails on an open Sev 1 or 2 incidentrestore:bypass, with the incident and a reason

Next

Related: Snapshots, Drift.

On this page