Tear rigs down and bring them up through the engine's own paths
What this changes
Five places where a rig wrapper or a verb's argument parser acted differently from the engine's own path. Each one left a cloud resource behind, ran the wrong lab, or dropped the VM-up announcement. Closes the issue filed with this MR.
| Defect | Fix |
|---|---|
two-plane down leaks the sim-rig-* account and the forge's state record |
tp_down runs each member through down --instance, so what is deleted comes from the state record. A member with no record is left alone and reported. A failed member keeps the pair record, so a second two-plane down finishes the job. |
Geo and Praefect force SIM_PIN_ZONE=true |
The first member takes the operator's setting. A later member pins to the zone an earlier one landed in, read from the cloud. A parallel pair starts its second member once the first has a VM. |
A failed rig up leaves its account behind |
The failed-up hook now releases the account it ensured at the identity and create steps. This was not handled before. |
| A restore that recreates a suspended lab raises no notification | recreate_vm calls the same notify_vm_up as up. |
--instance works only as the first argument; hotpatch has none |
The flag is accepted anywhere among a verb's flags and hotpatch takes it. A verb with no resolvable instance is still refused. |
SIM_NOTIFY_CMD needs a literal $1 and $2 |
A bare executable receives the title and body as its two arguments. A command string still runs under bash -c with them as $1 and $2. Nothing more is evaluated. operations.md says so. |
Two further changes close what the first change made reachable:
| Defect | Fix |
|---|---|
down deletes snapshots and reserved addresses by name and label, with no owner check. Now that two-plane down sends the forge through down, one owner's teardown could delete another owner's snapshot and <forge>-addr when both use the same lab name. |
The snapshot listing also filters on labels.owner. A snapshot with no owner label is logged and kept, never deleted. snapshot is the only create site and it sets the owner label. An address is released only when the rig's own state record holds its name; the listing by name is gone. |
SIM_NOTIFY_CMD resolved a bare name with command -v, which also matches the engine's own shell functions, so SIM_NOTIFY_CMD=state_clear would have run inside the engine. |
have_cmd uses type -P, so only an executable file is run directly. Anything else goes through bash -c, as before. |
The address name is recorded before the reserve call, so a reserve that is killed after the cloud created the address still leaves a record for down to release; a reserve that creates nothing removes the name again.
operations.md was trimmed by the words it gained, so the word budget stays at its ceiling.
The two-plane down path
sequenceDiagram
participant Op as Operator
participant TP as tp_down
participant Down as cmd_down
participant State as State record
participant Cloud as Cloud
Op->>TP: two-plane down
TP->>State: read the forge and enclave names
TP->>State: does the enclave have a record?
alt record
TP->>Down: down --instance enclave
Down->>State: read zone, rig and owner
Down->>Cloud: delete the VM and its rules
Down->>Cloud: release the rig account when no node is left
Down->>State: clear the record
else no record
TP-->>Op: nothing of it was deleted
end
TP->>Cloud: delete the forge registry rule
TP->>State: does the forge have a record?
alt record
TP->>Down: down --instance forge
Down->>Cloud: same steps as the enclave
Down->>State: clear the record
else no record
TP-->>Op: nothing of it was deleted
end
TP->>State: forget the pairNo node deletion is keyed by name. The only name-keyed step is the forge's registry rule, which the old path already removed and which belongs to the pair, not to a node. Snapshots are deleted only when they carry this owner's label or the record names them, and addresses only when the record names them.
Tests
Each defect has cases in gce/engine-selftest.sh. I ran the new selftest against the old engine and then against this tree.
two-plane down: the old engine leaves the account and the forge record; the fix releases the account, clears the record, leaves a member with no record alone, and keeps the pair record when a member fails.- Zone pin: the old rig scripts export
SIM_PIN_ZONE=true; the fix passes the operator's value to the first member and the landed zone to later ones. This replaces the text grep that asserted the old behaviour. - Failed
up: the account ensured at the identity or create step is released, and a later step leaves it alone. - Restore: a recreate raises the notification once.
--instance: accepted after other flags forstatus,downandrestore, and in either position forhotpatch, which no longer passes it to the VM script; a bare verb is refused; arguments after--are not read.SIM_NOTIFY_CMD: a bare executable gets two arguments; a string with$1and$2still works; the name of an engine function is not run directly.- Owner isolation: owner
bholds a snapshot, an unlabelled snapshot and an address for a forge name. Ownerarunstwo-plane downand a plaindown, and nosnapshots deleteoraddresses deleteis logged. The old listing deletes them. The existing teardown cases now find an address through the record, not by name.
Against the old engine the new selftest fails the cases above, and the unrelated reds are checks on archive artifacts. This tree passes in full. scan-accept.yml moves engine-selftest.sh from 75 to 79 for the four commands the new cases add, and the first hosted run is what showed the count.
Live run
One two-plane rig with SIM_PIN_ZONE=false and no GCP_ZONE, instances sim-rl-*.
two-plane up. The forge hit a real stockout inus-central1-aand fell back tous-central1-b, which is the fallback the old rig scripts removed. The enclave then pinned tob. Both VM-up notifications fired.down --keep-snapshot --instance sim-rl-forge, with the flags in that order, was accepted and suspended the forge.restorerecreated the forge inb. The disk is zonal, so a restore keeps its zone. It met stockouts on four attempts and succeeded on the fifth. The VM-up notification fired at the recreate.two-plane downran both members throughdown --instanceand exited 0.
After the down:
- no
sim-rig-*service account - no files in the state directory and no
two-plane.json - no instance, disk, snapshot, address or firewall rule named
sim-rl*or labelledowner=fix-riglife - project
ssh-keyscount unchanged at[4]
No other VM was touched.
For the owner check, one Omnibus lab (up --no-gitlab, sim-rl-o1) was brought up, snapshotted, taken down with --keep-snapshot, and then taken down plainly. The snapshot carried this owner's label. The suspend reserved sim-rl-o1-addr and sim-rl-o1-iaddr. The plain down deleted the snapshot and released both addresses from the record, and the project ssh-keys count stayed at [4]. The VM-up notification fired at the create.
Notes
- A restore stockout cannot fall back to another zone, because the disk is zonal. That is existing behaviour and is not changed here.
- The notification title is
<SIM_OWNER>: VM up.
Closes #61 (closed)