Keep reap off a rig whose VM is still being created
just lab reap could delete the state record of a rig whose VM was still being created, which left the VM orphaned.
up writes the rig's state record before it calls gcloud compute instances create. A reap that ran between those two steps found a record with no VM, read it as a gone rig, and removed the record and its firewall rules. The VM then came up with nothing tracking it.
sequenceDiagram
participant U as up
participant S as state record
participant R as reap
participant G as GCE
U->>S: write record (owner, zone)
R->>S: read record
R->>G: describe VM
G-->>R: not found
R->>S: delete record
U->>G: create VM
Note over G: VM runs with no recordThe fix:
upwritesphase=creatingandphase_sincein the record's first write, so a record is never visible without the marker.- Reap leaves a creating record alone for
SIM_REAP_CREATE_GRACE_SECONDS(default 900) fromphase_since, and says so. upmoves the phase tobootingonce the create call returns, so the marker ends with the window.- An
upthat died mid-create leaves a creating record, and reap removes it once the window has passed, so a failed create does not pin its record.
Tests in gce/engine-selftest.sh run reap from inside the create call of a real cmd_up, and run reap on a creating record two hours old. With the fix reverted, the in-flight reap deletes the record and three more assertions on that path fail; the stale-record check passes both ways, so it also asserts the reap message that only the fix prints.
tests/run.sh (641 passed), gce/engine-selftest.sh, just commit-trailers and just word-budget pass locally.