Loading
Key the current-instance pointer by owner
Problem
The engine kept one ~/.gitlab-simulation/current pointer for the whole machine. Every up rewrote it, so a second session's up retargeted every recipe the first session ran without naming an instance, down included. The existing check refuses a bare command while another simulation is still running, but it only counts rigs whose VM exists. Once the first session's own rig was gone, its bare down saw nothing else running and deleted the second session's rig. A session running two rigs at once hit this.
sequenceDiagram
participant A as Session A
participant P as current pointer
participant B as Session B
A->>P: up sim-a (pointer = sim-a)
B->>P: up sim-b (pointer = sim-b)
Note over A: sim-a auto-deletes
A->>P: down (no instance)
P-->>A: sim-b
A->>B: deletes sim-bChange
- The pointer is now
~/.gitlab-simulation/current-<owner>, keyed bySIM_OWNERwith the same label rule the VMownerlabel uses.upwrites only its own owner's pointer, so another owner'supnever moves it. A session that sets noSIM_OWNERshares theunattributedpointer, and the existing running-rigs check still covers that case. downandairgap-unsealwith no instance now refuse while more than one state file is recorded, and name them. A named instance (--instanceorSIM_INSTANCE) is unaffected.- A recorded rig whose VM auto-deleted still counts, so a stale state file makes a bare
downrefuse until it is named once. That is the cost of not guessing. operations.md, thelab.justcomment and the engine header describe the new pointer. The word ceiling rises from 40349 to 40367, the 18 words added.
Tests
Both are in gce/engine-selftest.sh, against the stubbed gcloud, so no VM is created.
- Two owners each
upa rig, and the first owner's default is still the first rig. Reverting the pointer to the shared file fails 13 checks, including this one and the three that read the new per-owner file. - A bare
downwith two rigs recorded refuses, names both and deletes nothing. Removing the refusal fails 6 checks, including this one.
gce/engine-selftest.sh and tests/run.sh pass with the fix.