enroll-activate calls the switch finished off /run/current-system, so the deploy's switch-to-configuration boot collides with the still-running switch and exits 11 #1009

Closed
opened 2026-08-30 00:42:05 +00:00 by matou-build-agent · 3 comments

Failure

Drive 20260830T002134Z (target device) red at leg standing (and its inner activation leg), signature 25304f657c24, commit d1870664. Operator-facing text: the gateway deploy failed — The gateway deploy failed.

15 of 17 legs green. enroll-activate returned green, then the very next deploy/activation work died.

What actually killed it

The deploy's remote switch-to-configuration boot never ran — it could not take the NixOS switch lock, because the previous leg's switch was still running on the box.

From logs/founding-state.log (standup.deploy.failure.tail), the CLI's own transcript:

[gateway] $ systemd-run --pipe --wait … --unit=clan-boot-gateway-834da81d -- \
            …/bin/switch-to-configuration boot
[gateway] Could not acquire lock
[gateway] failed with error: switch-to-configuration boot failed on 'gateway' (exit code 11)

The box's own journal, logs/gateway-journal.txt, gives the collision precisely:

  • :1202-1203 — 00:34:21 clan-switch-gateway-15495c5e.service starts switch-to-configuration switch (this is the enroll-activate leg's switch).
  • :1258, :1274 — 00:34:22-00:34:23 PID 1885 (.switch-to-conf) requests systemd reexec + reload — i.e. the activation script phase, which is where /run/current-system is flipped.
  • :1347-1351 — 00:37:18 the deploy's clan-boot-gateway-834da81d.service starts and Main process exited, code=exited, status=11/n/a in the same second.
  • :1854, :1891 — 00:37:28, i.e. ten seconds after the deploy already failed, PID 1885's switch is still in its unit-start phase, starting idss-mesh-self-admit.service.

And logs/gateway-stall.txt (captured 00:37:41) still lists both the wrapper and the switch alive:

1884  systemd-run --pipe --wait … --unit=clan-switch-gateway-15495c5e … switch-to-configuration switch
1885  …/bin/switch-to-configuration switch

So the switch from enroll-activate held /run/nixos/switch-to-configuration.lock for at least 3m20s, spanning the whole deploy attempt.

Suspected layer — the completion signal is false

internal/clan/enrollment.go treats /run/current-system == s.Toplevel as proof the switch finished. It is not: that symlink is written by the activation script, which runs before the stop/start unit phase. Two sites share the bad signal, both fed by probeCurrentSystem (internal/clan/enrollment.go:1263-1283):

  • internal/clan/enrollment.go:1181-1188 — the #714 post-interrupt completion probe. On err == nil && current == s.Toplevel it emits "the switch finished on the box after the interrupted activate — /run/current-system matches the built system; the node is a clan member" and returns green.
  • internal/clan/enrollment.go:1234-1250 — the #992 watchdog. Comment at :1240 states "The switch is DONE on the box", then after activateWatchdogGrace (90s, :108) it cancels the CLI and emits the reap message at :1248.

Both fired this run — founding-state.log standup.events carries the reap sentence and the completion sentence back to back. The leg then reported the node a clan member while the box's switch had minutes of unit-starting left, and the pipeline immediately ran a second clan machines update into the held lock.

Note also that the switch was genuinely slow, not merely un-awaited: gateway-journal.txt:1310 shows the user-session dbus-broker.service: Reload operation timed out. Killing reload process. burning ~90s at 00:35:54, with another ~83s of silence before the unit-start phase resumed at 00:37:18.

Second, smaller defect — the failure is labelled as the wrong hazard

switchDeathNote (internal/clan/adapter.go:485-489) hard-codes one sentence for every non-zero switch exit found by switchExitFromLog (:461-482):

the remote switch died at exit 11 (a switch-to-configuration panic) — on the self-deploy path the switch was killed with the unit it stopped … (see GOTCHAS #86)

Exit 11 here is a lock collision, not a panic; GOTCHAS #86's panic is exit 101 (docs/GOTCHAS.md, #86). The operator — and the next healer — are pointed at the wrong hazard by a message that asserts a cause it did not establish.

What plugging it needs

  1. Replace the completion signal. /run/current-system matching is necessary but not sufficient. The switch is done only when the remote activation unit has exited — probe clan-switch-* / clan-boot-* (Adapter.UnitActive, internal/clan/adapter.go:210, already speaks the right ssh/host-key discipline) or check the switch lock directly. Both call sites at enrollment.go:1183 and :1237 need it; the watchdog must not reap on the symlink alone.
  2. Decide the budget for a still-running switch. Once detected, enroll-activate must either wait it out under a named bound or block resumable naming the in-flight switch — rather than returning green. This is the one judgement call; existing ceilings in enrollment.go (activateWatchdogInterval/activateWatchdogGrace, :107-108, and activateCeiling()) are the reference points.
  3. Make the deploy leg lock-aware. Could not acquire lock → exit 11 should be classified as a collision (retry once the lock frees), not routed through switchDeathNote. Gate switchDeathNote on the panic code it actually describes, or have it name the observed exit without asserting GOTCHAS #86.
  4. Add a GOTCHAS entry for the lock collision, distinct from #86, so exit 11 is not read as exit 101 again.

Why this was not self-healed

  • Not verifiable on this machine: artifacts/host.json records "qemu": "exit ENOENT: spawn qemu-system-x86_64 ENOENT" — there is no box here. A Go test would assert against a fake ssh, i.e. against my own account of when switch-to-configuration writes /run/current-system, not against the real thing.
  • Not mechanical: item 2 is a design decision about wait budget and about whether a previously-green leg becomes blocking.
  • Signature 25304f657c24 already resisted a heal one drive ago (20260829T213942Z, commit 9ef8509a). That heal gave idss-mesh-self-admit a bounded wait for the netbird plane — visible working as intended here at gateway-journal.txt:1891-1997 — but it lengthens the unit-start phase that holds this lock, so it plausibly widened this collision window rather than causing it.

drive 20260830T002134Z red at standing: the gateway deploy failed — The gateway deploy failed. [There is no old operating system to roll back to — this server was rented fresh for the community, so nothing of yours was overwritten.]
evidence: /home/swarm/swarm/Matou/idss/test-results/drive-device/20260830T002134Z on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured

## Failure Drive `20260830T002134Z` (target `device`) red at leg `standing` (and its inner `activation` leg), signature `25304f657c24`, commit `d1870664`. Operator-facing text: *the gateway deploy failed — The gateway deploy failed.* 15 of 17 legs green. `enroll-activate` returned **green**, then the very next `deploy`/`activation` work died. ## What actually killed it The deploy's remote `switch-to-configuration boot` never ran — it could not take the NixOS switch lock, because the **previous leg's switch was still running on the box**. From `logs/founding-state.log` (`standup.deploy.failure.tail`), the CLI's own transcript: ``` [gateway] $ systemd-run --pipe --wait … --unit=clan-boot-gateway-834da81d -- \ …/bin/switch-to-configuration boot [gateway] Could not acquire lock [gateway] failed with error: switch-to-configuration boot failed on 'gateway' (exit code 11) ``` The box's own journal, `logs/gateway-journal.txt`, gives the collision precisely: - `:1202-1203` — `00:34:21` `clan-switch-gateway-15495c5e.service` starts `switch-to-configuration switch` (this is the **enroll-activate** leg's switch). - `:1258`, `:1274` — `00:34:22`-`00:34:23` PID 1885 (`.switch-to-conf`) requests systemd reexec + reload — i.e. the *activation script* phase, which is where `/run/current-system` is flipped. - `:1347-1351` — `00:37:18` the deploy's `clan-boot-gateway-834da81d.service` starts and `Main process exited, code=exited, status=11/n/a` in the same second. - `:1854`, `:1891` — `00:37:28`, i.e. **ten seconds after the deploy already failed**, PID 1885's switch is *still* in its unit-start phase, starting `idss-mesh-self-admit.service`. And `logs/gateway-stall.txt` (captured `00:37:41`) still lists both the wrapper and the switch alive: ``` 1884 systemd-run --pipe --wait … --unit=clan-switch-gateway-15495c5e … switch-to-configuration switch 1885 …/bin/switch-to-configuration switch ``` So the switch from `enroll-activate` held `/run/nixos/switch-to-configuration.lock` for at least 3m20s, spanning the whole deploy attempt. ## Suspected layer — the completion signal is false `internal/clan/enrollment.go` treats `/run/current-system == s.Toplevel` as proof the switch **finished**. It is not: that symlink is written by the activation script, which runs *before* the stop/start unit phase. Two sites share the bad signal, both fed by `probeCurrentSystem` (`internal/clan/enrollment.go:1263-1283`): - **`internal/clan/enrollment.go:1181-1188`** — the #714 post-interrupt completion probe. On `err == nil && current == s.Toplevel` it emits *"the switch finished on the box after the interrupted activate — /run/current-system matches the built system; the node is a clan member"* and returns green. - **`internal/clan/enrollment.go:1234-1250`** — the #992 watchdog. Comment at `:1240` states *"The switch is DONE on the box"*, then after `activateWatchdogGrace` (90s, `:108`) it cancels the CLI and emits the reap message at `:1248`. Both fired this run — `founding-state.log` `standup.events` carries the reap sentence *and* the completion sentence back to back. The leg then reported the node a clan member while the box's switch had minutes of unit-starting left, and the pipeline immediately ran a second `clan machines update` into the held lock. Note also that the switch was genuinely slow, not merely un-awaited: `gateway-journal.txt:1310` shows the user-session `dbus-broker.service: Reload operation timed out. Killing reload process.` burning ~90s at `00:35:54`, with another ~83s of silence before the unit-start phase resumed at `00:37:18`. ## Second, smaller defect — the failure is labelled as the wrong hazard `switchDeathNote` (`internal/clan/adapter.go:485-489`) hard-codes one sentence for **every** non-zero switch exit found by `switchExitFromLog` (`:461-482`): > the remote switch died at exit 11 (a switch-to-configuration panic) — on the self-deploy path the switch was killed with the unit it stopped … (see GOTCHAS #86) Exit 11 here is a lock collision, not a panic; GOTCHAS #86's panic is exit **101** (`docs/GOTCHAS.md`, #86). The operator — and the next healer — are pointed at the wrong hazard by a message that asserts a cause it did not establish. ## What plugging it needs 1. **Replace the completion signal.** `/run/current-system` matching is necessary but not sufficient. The switch is done only when the remote activation unit has exited — probe `clan-switch-*` / `clan-boot-*` (`Adapter.UnitActive`, `internal/clan/adapter.go:210`, already speaks the right ssh/host-key discipline) or check the switch lock directly. Both call sites at `enrollment.go:1183` and `:1237` need it; the watchdog must not reap on the symlink alone. 2. **Decide the budget for a still-running switch.** Once detected, `enroll-activate` must either wait it out under a named bound or block resumable naming the in-flight switch — rather than returning green. This is the one judgement call; existing ceilings in `enrollment.go` (`activateWatchdogInterval`/`activateWatchdogGrace`, `:107-108`, and `activateCeiling()`) are the reference points. 3. **Make the deploy leg lock-aware.** `Could not acquire lock` → exit 11 should be classified as a *collision* (retry once the lock frees), not routed through `switchDeathNote`. Gate `switchDeathNote` on the panic code it actually describes, or have it name the observed exit without asserting GOTCHAS #86. 4. **Add a GOTCHAS entry** for the lock collision, distinct from #86, so exit 11 is not read as exit 101 again. ## Why this was not self-healed - Not verifiable on this machine: `artifacts/host.json` records `"qemu": "exit ENOENT: spawn qemu-system-x86_64 ENOENT"` — there is no box here. A Go test would assert against a fake ssh, i.e. against my own account of when `switch-to-configuration` writes `/run/current-system`, not against the real thing. - Not mechanical: item 2 is a design decision about wait budget and about whether a previously-green leg becomes blocking. - Signature `25304f657c24` already resisted a heal one drive ago (`20260829T213942Z`, commit `9ef8509a`). That heal gave `idss-mesh-self-admit` a bounded wait for the netbird plane — visible working as intended here at `gateway-journal.txt:1891-1997` — but it *lengthens* the unit-start phase that holds this lock, so it plausibly widened this collision window rather than causing it. drive `20260830T002134Z` red at `standing`: `the gateway deploy failed — The gateway deploy failed. [There is no old operating system to roll back to — this server was rented fresh for the community, so nothing of yours was overwritten.]` evidence: `/home/swarm/swarm/Matou/idss/test-results/drive-device/20260830T002134Z` on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured <!-- rehearsal-sig: 25304f657c24 -->
Author
Member

swarm-claim host=elitebook-distributed-server-03 run=14200
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=14200 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

Ruled by agent under ADR 0174 — veto anytime.

Item 2 of the ticket ("decide the budget for a still-running switch") is the one judgement call. Ruling: when the completion probe finds /run/current-system matching the built toplevel but a clan-switch-*/clan-boot-* activation unit STILL running, enroll-activate blocks resumable naming the in-flight switch — it never returns green on the symlink alone. The #992 watchdog waits the switch out under the existing activateCeiling() (it keeps the ceiling as arbiter while the switch is in flight and reaps only once the unit has exited), so no new wait-budget constant is introduced. An unreadable in-flight probe also blocks resumable rather than greening (a symlink match is not completion).

Why a two-way door: the choice is entirely a behaviour policy inside internal/clan — revertible by a later commit (e.g. to switch to an in-process bounded wait, or to add a dedicated budget constant) with no external residue. It touches no personal credential, no security-posture widening, no member-facing trust accept, no data destruction, and no spend. It only ever downgrades a previously-green leg to an honest resumable block — strictly safer than the false green it replaces.

What proves it: offline seam tests against a scripted ssh double — TestEnroll_InterruptedActivateBlocksWhileSwitchStillRunningUnits, TestEnroll_InterruptedActivateBlocksWhenInflightProbeUnreadable, TestEnroll_ActivateWatchdogNeverReapsWhileSwitchStillStartingUnits (all red before the fix). LIVE confirmation (a generation-apart switch that greens only after the box's activation unit exits) rides the next paid drive-device past standing, recorded as named residue.

**Ruled by agent under ADR 0174 — veto anytime.** Item 2 of the ticket ("decide the budget for a still-running switch") is the one judgement call. **Ruling:** when the completion probe finds `/run/current-system` matching the built toplevel but a `clan-switch-*`/`clan-boot-*` activation unit STILL running, enroll-activate **blocks resumable naming the in-flight switch** — it never returns green on the symlink alone. The `#992` watchdog **waits the switch out under the existing `activateCeiling()`** (it keeps the ceiling as arbiter while the switch is in flight and reaps only once the unit has exited), so no new wait-budget constant is introduced. An unreadable in-flight probe also blocks resumable rather than greening (a symlink match is not completion). **Why a two-way door:** the choice is entirely a behaviour policy inside `internal/clan` — revertible by a later commit (e.g. to switch to an in-process bounded wait, or to add a dedicated budget constant) with no external residue. It touches no personal credential, no security-posture widening, no member-facing trust accept, no data destruction, and no spend. It only ever downgrades a previously-green leg to an honest resumable block — strictly safer than the false green it replaces. **What proves it:** offline seam tests against a scripted ssh double — `TestEnroll_InterruptedActivateBlocksWhileSwitchStillRunningUnits`, `TestEnroll_InterruptedActivateBlocksWhenInflightProbeUnreadable`, `TestEnroll_ActivateWatchdogNeverReapsWhileSwitchStillStartingUnits` (all red before the fix). LIVE confirmation (a generation-apart switch that greens only after the box's activation unit exits) rides the next paid `drive-device` past `standing`, recorded as named residue.
Author
Member

close-report for #1009 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1009,
  "status": "success",
  "commits": [
    "6247527"
  ],
  "changed_files": [
    "STATUS.md",
    "docs/GOTCHAS.md",
    "internal/clan/adapter.go",
    "internal/clan/deploy_switch_journal_test.go",
    "internal/clan/enroll_activate_interrupted_test.go",
    "internal/clan/enroll_activate_watchdog_test.go",
    "internal/clan/enrollment.go"
  ],
  "tests": [
    {
      "command": "go build ./...",
      "exit_code": 0
    },
    {
      "command": "go vet ./...",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/clan/ ./internal/enroll/ ./internal/provision/ -count=1",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci (pre-push gate, full seam)",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Replace the completion signal — /run/current-system match is necessary but not sufficient; probe the activation unit": "enrollment.switchInFlight (internal/clan/enrollment.go) queries the box's own systemd for a live clan-switch-*/clan-boot-* activation unit over the same ssh discipline probeCurrentSystem uses; both call sites (the #714 post-interrupt probe and the #992 watchdog) now require it before conceding completion",
    "Decide the budget for a still-running switch — wait it out or block resumable rather than returning green": "the #714 probe blocks RESUMABLE naming the in-flight switch (never green on the symlink alone; an unreadable probe also blocks); the #992 watchdog waits under the existing activateCeiling() and reaps only once the unit has exited. Ruled under ADR 0174 (issue comment #31072)",
    "Make the deploy leg lock-aware — classify Could not acquire lock -> exit 11 as a collision, gate switchDeathNote on the panic code": "switchDeathNote (internal/clan/adapter.go) asserts the #86 panic only for exit 101; switchLockCollision/switchLockCollisionNote name a Could not acquire lock -> exit 11 as a collision pointing at GOTCHAS #131; switchUnitExitRE also matches clan-boot-*",
    "Add a GOTCHAS entry for the lock collision distinct from #86": "docs/GOTCHAS.md #131 added — symlink is not completion; exit 11 collision vs #86's exit-101 panic"
  },
  "summary": "enroll-activate now gates completion on the switch activation unit having exited (not just the /run/current-system symlink), blocking resumable while a switch is still running so the pipeline never drives a second switch into the held NixOS lock; exit-11 lock collisions are named as GOTCHAS #131, not #86's exit-101 panic.",
  "reason": "",
  "blockers": []
}
**close-report** for #1009 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1009, "status": "success", "commits": [ "6247527" ], "changed_files": [ "STATUS.md", "docs/GOTCHAS.md", "internal/clan/adapter.go", "internal/clan/deploy_switch_journal_test.go", "internal/clan/enroll_activate_interrupted_test.go", "internal/clan/enroll_activate_watchdog_test.go", "internal/clan/enrollment.go" ], "tests": [ { "command": "go build ./...", "exit_code": 0 }, { "command": "go vet ./...", "exit_code": 0 }, { "command": "go test ./internal/clan/ ./internal/enroll/ ./internal/provision/ -count=1", "exit_code": 0 }, { "command": "nix develop .#go-ci (pre-push gate, full seam)", "exit_code": 0 } ], "criteria": { "Replace the completion signal — /run/current-system match is necessary but not sufficient; probe the activation unit": "enrollment.switchInFlight (internal/clan/enrollment.go) queries the box's own systemd for a live clan-switch-*/clan-boot-* activation unit over the same ssh discipline probeCurrentSystem uses; both call sites (the #714 post-interrupt probe and the #992 watchdog) now require it before conceding completion", "Decide the budget for a still-running switch — wait it out or block resumable rather than returning green": "the #714 probe blocks RESUMABLE naming the in-flight switch (never green on the symlink alone; an unreadable probe also blocks); the #992 watchdog waits under the existing activateCeiling() and reaps only once the unit has exited. Ruled under ADR 0174 (issue comment #31072)", "Make the deploy leg lock-aware — classify Could not acquire lock -> exit 11 as a collision, gate switchDeathNote on the panic code": "switchDeathNote (internal/clan/adapter.go) asserts the #86 panic only for exit 101; switchLockCollision/switchLockCollisionNote name a Could not acquire lock -> exit 11 as a collision pointing at GOTCHAS #131; switchUnitExitRE also matches clan-boot-*", "Add a GOTCHAS entry for the lock collision distinct from #86": "docs/GOTCHAS.md #131 added — symlink is not completion; exit 11 collision vs #86's exit-101 panic" }, "summary": "enroll-activate now gates completion on the switch activation unit having exited (not just the /run/current-system symlink), blocking resumable while a switch is still running so the pipeline never drives a second switch into the held NixOS lock; exit-11 lock collisions are named as GOTCHAS #131, not #86's exit-101 panic.", "reason": "", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/idss#1009
No description provided.