Loading
feat(lab): Snapshot and restore a rig's boot disk
What
just lab snapshot --instance <name> snapshots a rig's boot disk, labelled with the rig id, and records the id in state. just lab restore --instance <name> returns the rig to that point. down and reap delete the snapshot with the rig. Closes #27 (closed).
flowchart TD
A[lab snapshot] --> B[sync, then disks snapshot labelled with the rig id]
B --> C[state: snapshot_id, snapshot_at, snapshot_gb]
C --> D[lab restore]
D --> E[create disk from the recorded id]
E --> F[stop VM, swap boot disk, keep the max-run deadline]
F --> G[start VM, record the new address]
G --> H[delete the old disk]
C --> I[down or reap]
I --> J[delete the recorded snapshot and any carrying the rig label]Behaviour
- One snapshot per rig; a new one replaces the old once it exists.
- Restore builds the new disk first and deletes the old one last, so a failure partway leaves a bootable disk.
- A restart changes an ephemeral address. State records the new one; the GitLab URL is not rewritten.
- Restore refuses a rig with no snapshot, a snapshot that is not ready, a gone VM, or under five minutes to its max run.
downon a rig whose snapshot will not delete fails and keeps the state record, so a seconddownretries.status --jsongainssnapshot_id,snapshot_at,snapshot_gb;schema_version4 to 5.- Docs:
gce/operations.mdsection andCHANGELOG.mdentry. Words cut elsewhere inoperations.mdto hold the word-budget ceiling.
Proof
Engine self-test against the stubbed gcloud: snapshot then restore recreates the disk from the recorded id, state keeps the id, down, gone-VM down and reap delete the snapshot, a snapshot that will not delete fails down.
Live, one GCE omnibus rig (sim-snap-live1): snapshot, wrote /root/marker.txt, restore, the file was gone, state still held the snapshot id, status --json showed schema 5 and the keys. down then left no instance, snapshot or disk.