feat: roll back a failed restore and say when a safety copy is gone
- a restore whose apply failed can be undone from its safety copy, which is its recovery: the failed apply stops fencing the target in the transaction that starts the undo (job phase rolled_back, audited restore.rolled_back); an apply whose agent went silent still waits for an administrator to reconcile it; reconciled restores can be undone - run views carry undo_state (available, superseded, expired), undo_kept_until, undo_of and restore_job_id - undo state for a list is worked out in one database pass and a file lookup per copy; the vault is read only for the newest restore of each target - eligibility is checked again inside the transaction that creates the run Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -378,13 +378,22 @@ orbit's); otherwise the answer is `422 snapshot_unusable` and nothing is started
|
||||
everything else is the same: one run per target at a time, idempotency, cancelling until the target is overwritten, and
|
||||
the authorisation checks right before overwriting. The same snapshot can be restored to several targets, and again later.
|
||||
|
||||
A completed restore can be undone: `undo_of` (the id of that run) restores the safety copy the restore took of its target
|
||||
A restore can be undone: `undo_of` (the id of that run) restores the safety copy the restore took of its target
|
||||
back onto the same target, through the same checks, countdown, progress and a new safety copy, so the undo can itself be
|
||||
undone. It is refused with `422 nothing_to_undo` when the run is not a completed restore of this relation, when something
|
||||
was restored onto the target after it (only the newest restore of a target can be undone), or when the safety copy has
|
||||
been removed. A safety copy is only ever accepted as a source for the target it was taken from, whether it arrives through
|
||||
undone. A restore that completed, one an administrator reconciled, and one whose apply failed (the agent reported it) can
|
||||
be undone; for the last, undoing is the recovery: the failed apply stops fencing the target in the same transaction
|
||||
that starts the undo (job phase `rolled_back`, audited as `restore.rolled_back`). An apply whose agent went silent
|
||||
(`lease_lost`) may still be writing, so it waits for an administrator to reconcile it first. The request is refused with
|
||||
`422 nothing_to_undo` when the run is none of these for this relation, when something was restored onto the target after
|
||||
it (only the newest restore of a target can be undone), or when the safety copy has been removed. A safety copy is only ever accepted as a source for the target it was taken from, whether it arrives through
|
||||
`undo_of` or `snapshot_id`; the check is made by the hub, and again by the agent (its restore artifact carries
|
||||
`rollback`). Run views say `undo` and `undo_available`, never where the copy is. The run is audited as
|
||||
`rollback`). Run views say `undo`, `undo_of` (the restore an undo puts back), `restore_job_id` and `undo_available`, never where
|
||||
the copy is. A restore that took a safety copy also says `undo_state`: `available` (with `undo_kept_until`, when retention
|
||||
may first forget the copy: a week after it was taken, and later while it is one of the target's newest few),
|
||||
`superseded` (something was restored after it) or `expired` (retention has forgotten the copy; this wins over
|
||||
`superseded`). The Activity log shows `expired` as "Safety backup expired" in place of a link, and lists an undo
|
||||
under the restore it reverses. Run lists work out all of this with one database pass and a file lookup per copy, and
|
||||
read the vault only for the newest restore of each target. The run is audited as
|
||||
`refresh.undo_started`. Undoing needs the same permission as restoring.
|
||||
|
||||
In the web UI there is no separate Refresh screen. Restoring lives in the Vault: pick an orbit, capture it if you want the
|
||||
@@ -392,7 +401,7 @@ latest data (or click a snapshot that is already there), and in the snapshot det
|
||||
disabled with "No restore point" when no relation has been set up for the orbit. The modal offers the restore points
|
||||
(Development and/or Staging) that the person may use, shows what will be overwritten, and after **Begin restore** counts
|
||||
ten seconds in the browser, during which **Abort** sends nothing. Then it follows four steps (Checking, Safety copy,
|
||||
Applying, Completed) from the run, and Abort still works until Applying starts. A finished restore offers **Undo this restore**, and the modal offers
|
||||
Applying, Completed) from the run, and Abort still works until Applying starts. A finished restore offers **Undo this restore** (**Roll back** when it was interrupted), and the modal offers
|
||||
**Undo last restore** for the chosen restore point while that is still possible. Safety copies are not listed with the
|
||||
backups. A person needs to see the orbit's snapshots (for example the viewer role on the orbit) and a relation grant;
|
||||
administrators can also restore to any other registered target from the same modal.
|
||||
|
||||
Reference in New Issue
Block a user