Release a restore's address once the VM runs

What

!152 (merged) reserves a VM's address before just lab restore stops it, so the restart keeps the address. Nothing released the reservation afterwards. A rig whose VM deleted itself on max run or idle kept the address, which bills hourly until down or reap ran, and the VM's service account cannot release it.

Fix

GCE keeps the address on a running instance when its reservation is deleted. Restore now deletes the reservation once the VM has started and drops its name from state, so a finished restore holds none. A restore that fails before then keeps the reservation, and down and reap still clear it by the name state records and by the name the instance gives it.

flowchart LR
  A[restore] --> B[reserve the VM's address]
  B --> C[swap the boot disk, stop and start]
  C -->|fails| K[reservation kept for down or reap]
  C --> D[release the reservation]
  D --> E[VM keeps the address, nothing billed]

Checks

  • Live first: on a running GCE omnibus rig, reserving the address and then deleting the reservation left the instance's address unchanged, and sign-in answered 200 at the same URL.
  • The engine self-test asserts that after a restore no reservation exists, state names none and the address is unchanged, including on a second restore. A restore whose start fails keeps the reservation for down.
  • Live restore with this change: snapshot, restore, sign-in 200 at the same URL, no reservation after. Teardown left no instance, snapshot, disk or address under the rig's name.

Merge request reports

Loading
Loading