Roll Back and Recover
Every way of undoing a change in ConfigHub goes forward: it writes new Revisions that carry the earlier configuration, or take a change back out of the current one, and the change and its undo both stay in each Unit's history, as git revert keeps both commits where git reset would drop one. helm rollback works the same way, cutting a new Helm release revision from an old one's values. Nothing reaches a cluster until a Release is published, so undoing a change that has been released is two steps: undo it in ConfigHub, then publish. This guide says which undo to use when, and links to the section that describes each in full.
Two questions decide it. What are you undoing: one change to one Unit, a ChangeSet, a ChangeOrder that has been promoted into several Spaces, or everything since a Release that worked? And should the changes made after it survive? A restore goes back to an earlier Revision and drops everything since, while a revert takes back only the change named and keeps what came after it.
Choosing how to undo
| To undo | Keeping later changes | Use |
|---|---|---|
| The latest change to a Unit | cub unit revert --space <space> <unit> HeadRevisionNum |
|
| An earlier change to a Unit, or a range of its Revisions | Yes | cub unit revert |
| A ChangeSet, wherever its Units are | Yes | cub variant revert ChangeSet:<changeset> |
| A ChangeSet, wherever its Units are | No | --restore Before:ChangeSet:<changeset> |
| What was done between two Tags | Yes | cub variant revert <space> Tag:<from>..Tag:<to> |
| A change promoted into several Spaces by a ChangeOrder | No | Abort it, and cub variant demote |
| Everything since a Release that worked | No | Restore the Release's Tag and publish |
An upload, or a cub apply of backing Units |
No | The restore command the upload prints, or restoring before its ChangeSet |
| A draft that has not landed | cub draft abandon; see drafts |
|
A delete made with --archive |
unarchive |
|
| A change made in the cluster during an incident | Keep it with cub k8s refresh, or let the next Release overwrite it |
Every one of them takes --dry-run, and the reverts and restores take -o mutations to show what they would change, Unit by Unit, before anything is written. A revert or restore made without a ChangeOrder or ChangeSet in a Space that requires one is refused like any other change, so open a ChangeSet on the Units first, as in Change Sets. A demote names its ChangeOrder, so it needs none.
Finding what to undo
When a Release breaks something, cub release list --space <space> shows the sync and health reported for each Release, if something reports live status. cub variant diff <space> Release:<number> compares what the Space holds now with what a Release bundled, cub revision list lists a Unit's Revisions with the description and ChangeSet or ChangeOrder of each, and cub unit blame says who set a value, in which Revision, and under which ChangeOrder. Each Release creates a Tag, release-<number>, on the Revisions it bundled, so the state a Release deployed can be named by that Tag in a restore or a revert range.
Rolling a Space back to an earlier Release
A Release never bundles a Revision of a Unit older than one already released, so publishing an earlier Release's Tag is refused once a later one has been released. Restore the earlier configuration as new Revisions, then publish them:
cub unit update --patch --space app-prod --where "Slug != ''" --restore Tag:release-41 \
--change-desc "Roll back to release 41" --dry-run -o mutations
cub unit update --patch --space app-prod --where "Slug != ''" --restore Tag:release-41 \
--change-desc "Roll back to release 41"
cub release publish app-prod
The restore drops every change made since Release 41, released or not. To keep work that has not been released yet, restore LastReleasedRevisionNum instead, which takes back only what is unreleased, or revert the range a bad Release added, Tag:release-41..Tag:release-42, which keeps what was done after it. When the bad change came from a ChangeOrder, demote it instead: the ChangeOrder then records that it was taken back out, and in which Spaces.
Withdrawing the latest Release is faster, and doesn't last. cub release withdraw stops serving it, and serves the Release published before it as latest in its place, so a GitOps operator following latest converges back without anything changing in the Units. Their heads still hold the change, though, and the next publish releases it again. Use it to restore service while you restore and publish as above.
Undoing a promoted change
A change carried through stages by a ChangeOrder is undone with the ChangeOrder, not Space by Space by hand. Abort it, so nothing promotes it any further, demote each Space it reached, and publish the restored Revisions where the change had been released:
cub changeorder update --space web-base release-v452 --aborted-reason "v452 fails health checks"
cub variant demote --change-order web-base/release-v452 --dry-run
cub variant demote --change-order web-base/release-v452
cub release publish web-prod
Without a Space, demote undoes the change in every Space it reached, and --target-stage or --where-space narrows them. Undoing a rollout describes what demote restores, why it requires the abort, and how the ChangeOrder's State records it. Rolling back an image release is the same, with the image's fact Units left as they are.
Guards and conflicts
Reverts and restores are held back by guards like any other change. A path with a guard the undo is not cleared for is left as it is and reported as a conflict, which cub unit conflicts lists and can apply; --clearance names the guards it may write over. A restore brings back the guards the earlier Revision had, as far as it is cleared to change them, so restoring a Revision from before a guard was set neither removes the guard nor writes the value under it. An Override guard does not stand in the way of either, since the value is the Unit's own. See reverting changes.
Keeping a change made in the cluster
During an incident, someone may change a resource in the cluster directly, with kubectl or by pausing the operator. The next Release overwrites that change unless it is brought into ConfigHub. cub k8s refresh reads one live resource, works out what changed in the cluster since its Unit was last released, and writes that back into the Unit, so the next Release keeps it:
cub k8s refresh deployment backend --namespace app --dry-run
cub k8s refresh deployment backend --namespace app
The tutorial shows the alternative: make the urgent change in ConfigHub, release it, and undo it later with a restore, so the cluster never leaves the pull-based loop.
Recovering archived entities
delete --archive keeps the entity and its history, hidden with the reason Archived, and unarchive brings it back, with its slug unless another entity has taken it since. An archived Unit is named by a slug made from its ID; find it by the slug it had:
cub unit list --space app --include-hidden=Archived --where "Labels.ArchivedSlug = 'old-cache'"
cub unit unarchive --space app --where "Labels.ArchivedSlug = 'old-cache'"
A Space archived with --recursive is unarchived with --recursive. A delete without --archive can't be undone. See archiving instead of deleting, and Protect Precious Entities to keep an entity from being deleted at all.
Related reading
- Make Changes: ChangeSets, drafts, reverting, restoring, and merging a range back in
- Track and Promote Changes: ChangeOrders, and abort and demote
- Publish Releases: what a publish bundles and what blocks it, withdraw and delete
- Make and Undo a Change, in the tutorial