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-b

Change

  • The pointer is now ~/.gitlab-simulation/current-<owner>, keyed by SIM_OWNER with the same label rule the VM owner label uses. up writes only its own owner's pointer, so another owner's up never moves it. A session that sets no SIM_OWNER shares the unattributed pointer, and the existing running-rigs check still covers that case.
  • down and airgap-unseal with no instance now refuse while more than one state file is recorded, and name them. A named instance (--instance or SIM_INSTANCE) is unaffected.
  • A recorded rig whose VM auto-deleted still counts, so a stale state file makes a bare down refuse until it is named once. That is the cost of not guessing.
  • operations.md, the lab.just comment 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 up a 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 down with 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.

Merge request reports

Loading
Loading