Keep the rig's address across restore

What

just lab restore stopped the VM, and a stopped VM comes back at a new ephemeral address. State recorded the new one, but everything built on the old one kept pointing at it: the omnibus external_url, gitlab_url and aigw_url in state, the AI Gateway and LiteLLM URLs, runner registration, OAuth callbacks, the caproni chart's externalIP, and an HTTPS rig's certificate SAN. The rig was broken after a restore. Introduced by !151 (merged).

Fix

Restore reserves the address the VM already holds before it stops the VM, so the restart returns it unchanged and nothing needs rewriting. That covers every base: the address belongs to the VM, not to GitLab, omnibus, caproni or dev. The private address never changed, so the caproni gateway path and Geo's internal addresses were already safe.

down and reap release the reservation with the rig, found by the name state records and by the name the instance gives it, including when the VM is already gone. A reserved address bills hourly until then, like the snapshot. If the address cannot be reserved, restore stops before it changes anything.

flowchart LR
  A[restore] --> B[reserve the VM's address]
  B -->|fails| X[stop, nothing changed]
  B --> C[new disk from snapshot]
  C --> D[stop VM, swap boot disk]
  D --> E[start VM at the same address]
  F[down or reap] --> G[delete VM] --> H[release address and snapshot]

Checks

  • The engine self-test models a VM that loses its address on start unless one is reserved. It asserts the address is unchanged after a restore and after a second one, that a failed reservation changes nothing, and that down (live VM, gone VM, a failed release) and reap release it.
  • Live proof on a GCE omnibus rig: snapshot, restore, and the sign-in page answers 200 at the same URL as before the snapshot. Teardown left no instance, snapshot, disk or address under the rig's name.
Edited by Andrew Dunn

Merge request reports

Loading
Loading