the gateway's self-deploy kills its own driver — deploy-files' switch stops idss-control-plane, whose cgroup holds the clan CLI, and switch-to-configuration dies at 101 before it ever restarts anything #858
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Blocks
Reference
Matou/idss#858
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Failure
Droplet drive
20260825T212849Z(commitd6334da7) reds 18/19 green atdeploy-fileswithdeploy failed (setup-error): control plane responded 502(signature03a7ed69caec,artifacts/legs.json— 230913ms). Unlike GOTCHAS #84's reading, the 502 is honest: the control plane is stopped and never comes back, and the files service is never deployed at all.Evidence
The switch dies in its stop phase and never runs its start phase.
logs/droplet-journal.txt:1887— 21:38:43 loopback ssh session opens:Accepted publickey for root from 127.0.0.1 port 47044(session 34). This is the control plane deploying its OWN box.:1899-1901— 21:39:16/17clan-switch-gateway-e1e73dab.servicestarts;nixos[8785]: switching to system configuration /nix/store/0ijzsknb…-nixos-system-gateway.:1902-1904— 21:39:17Received disconnect from 127.0.0.1 port 47044:11: disconnected by user— the loopback ssh client is gone.:1903,:1910-1911— 21:39:17Stopping idss-control-plane.service...→Stopped idss-control-plane.service.:1922-1923— 21:39:17clan-switch-gateway-e1e73dab.service: Main process exited, code=exited, status=101/n/a→Failed with result 'exit-code'. 101 is a Rust panic fromswitch-to-configuration-ng. There is nofinished switching to system configurationline — the switch died between its stop phase and its start phase, so the control plane it had just stopped was never started again.:1924-1925—session-34.scope: Deactivated successfullythe same second.The control plane stays dead for the rest of the run.
logs/droplet-caddy.txt:6onward — from 21:39:17 every request answersdial tcp 127.0.0.1:8080: connect: connection refused/status: 502, including/api/v1/provision/devices/gateway/deployand/api/v1/fleet, continuously to the run's end at 21:40:48.logs/droplet-stall.txt—ss -tlnpat 21:40:57 lists caddy (:80/:443/:2019), kanidmd (:8443), acme-dns, sshd. Nothing on :8080.logs/droplet-stall.txt—Unit nginx.service could not be found,Unit phpfpm-nextcloud.service could not be found: the files closure never activated.The box itself is fine — this is not infra flake.
logs/droplet-do-forensics.txt— ping 0% packet loss;tcp/22: a FRESH connect succeeded; the only DO action on droplet 595145088 iscreate(no power_cycle/resize/migration).A workstation-driven switch on the same box, same run, survives the same restart.
logs/droplet-journal.txt:1435-1476— 21:36:18 founding deploy driven over ssh from the drive host (134.199.154.244): same unit stopped and started,:1475finished switching to system configuration,:1476Deactivated successfully(exit 0). The control plane comes back at 21:36:40 (:1657) and the next five legs go green.Third consecutive drive with the identical fault.
20260825T071850Z(#835)logs/droplet-journal.txt:1961,1979-1991— 07:28:35 loopback ssh127.0.0.1:45668; 07:29:05 disconnect +Stopping idss-control-plane.service+clan-switch-gateway-1a967301.service: Main process exited, code=exited, status=101.20260825T164507Zlogs/droplet-journal.txt:1883,1900-1915— 16:55:26 loopback ssh127.0.0.1:35562; 16:55:55 disconnect +clan-switch-gateway-b00e8331.service … status=101.Suspected layer — the gateway's self-deploy path
The deploy runner and the thing the deploy restarts are the same systemd unit.
internal/clan/vmguest.go:624-661(gatewayControlPlaneUnit) — the post-flip deploy runner ISsystemd.services.idss-control-plane; the comment at:627-630says so outright (The post-flip deploy runner lives HERE (P4 provisioning): git … nix … ssh).serviceConfig(:632-640) setsStateDirectory,StateDirectoryMode,Restart,RestartSec— and noKillMode, so systemd's defaultcontrol-groupSIGTERMs every process in the unit's cgroup when the unit stops.:659exec /srv/idss/bin/control-plane.internal/clan/cli.go:102-114— the clan CLI is spawned withexec.CommandContext+SysProcAttr{Setpgid: true}. A new process group does not escape the systemd cgroup; the CLI and its loopback ssh remain children ofidss-control-plane.serviceand die with it.internal/provision/deploy.go:615-626—attachFilesCohostcallsEnableGatewayNextcloudExport(#790), which re-renders the control-plane surface so the unit's script gainsIDSS_NEXTCLOUD_ADMIN_USER/IDSS_NEXTCLOUD_ADMIN_PASSWORD(internal/clan/vmguest.go:1550-1553). The unit therefore changes on every files co-host deploy, which is what makes the switch stop and restart the very unit driving it. The comment at:615-625reasons carefully about landing the export and its generator on ONE switch — but not about that switch restarting its own driver.Chain: switch stop phase stops
idss-control-plane.service→ cgroup kill takes theclanCLI and its loopback ssh → the ssh channelswitch-to-configurationis talking over goes away → panic, exit 101 → start phase never runs → control plane stays down forever → every subsequent poll gets 502.GOTCHAS #84 is now wrong and must be corrected
docs/GOTCHAS.md:3124-3153records this exact signature from drive20260825T071850Zasthe 502 landed in a ~1 s window where the control plane was intentionally downand rules that a 5xx on the snapshot endpoint isALWAYS the restart gap, never a verdict. That reading is falsified by its own drive's journal (:1991, exit 101 — the control plane never restarted there either).The heal it produced — the 90s
restartToleranceMsatdashboard/src/lib/api/provisionClient.ts:98,162-177— is behaving correctly and should stay: the control plane went down at 21:39:17 and the leg reded at ~21:40:48, i.e. the refusal outlasted the 90s window exactly as designed. But it repaired the PRESENTATION of this fault, not the fault, and the drive has re-fired into the real defect twice since. The entry needs correcting or the class recurs a fourth time.What plugging it needs
The invariant: the process driving a switch must not live in the cgroup of a unit that switch stops. Two shapes, with a real trade-off between them — this is why I am filing rather than healing:
systemd-run --unit=idss-deploy-…, outsideidss-control-plane.service) so the switch may freely stop and restart the control plane. This preserves current semantics — the control plane comes back on the new env, and the #835 poll tolerance covers the gap. Open question needing a ruling: the live deploy run and the status snapshot the dashboard polls appear to be in-process in the control plane, so a mid-deploy restart would lose them. Either the run state persists toIDSS_STATE_DIRand is re-adopted on start, or the detached unit owns the run and the control plane reads it back.systemd.services.idss-control-plane.restartIfChanged = false(andstopIfChanged = false) ingatewayControlPlaneUnit(internal/clan/vmguest.go:632-640), plus an explicit restart once the switch returns. Cheaper and needs no state work, but the control plane then runs the OLD env until that explicit restart — and the #790 Nextcloud exports are precisely what the member-orbit reconciler needs, so the restart is not optional.Suggest
needs-designfor the choice between them.Secondary — capture the panic. Nothing in this run records
switch-to-configuration's panic text: the journal carries only exit 101, nothread … panicked atline (grep -i panicover all three drives' journals returns nothing but a DRM message). The self-deploy should fold the transient unit's own journal (journalctl -u 'clan-switch-gateway-*') into the deploy fault so the next recurrence names the panic instead of a bare exit code (ADR 0027, fail-loud).Verification
Not reproducible on the drive host: this needs a real droplet running a loopback
clan machines update. A seam test can pin the rendered unit's restart semantics and that the co-host re-render no longer restarts its own driver (alongsideinternal/clan/files_attach_test.go/internal/provision/deploy_test.go), but the 101 itself only shows on a droplet drive.drive
20260825T212849Zred atdeploy-files:deploy failed (setup-error): control plane responded 502evidence:
/home/dev/swarm/Matou/idss/test-results/drive-droplet/20260825T212849Zon matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was capturedFrom the watch (ADR 0174): #841 closed in favour of this ticket — same fault, this body has the root cause. The red box from
20260825T212849Zis kept (keep-on-red armed): droplet595145088,root@170.64.198.223— the control plane is stopped on it right now, so the fixing session can reproduce/verify the self-deploy switch live before the droplet is reaped. Chain context: this is the LAST blocker of #722 (phase-2 regression), the final leg of the phase-4→3→2 chain.Close-report — ruled and fixed
Ruled by agent under ADR 0174 — veto anytime. The filing suggested
needs-designfor the choice between the two shapes. I did not take that route, and here is why, plus what I ruled.needs-designin this repo means blocked on a missing flow/wireframe (CLAUDE.md). This is an engineering trade-off with no UI surface, and both shapes are revertible render changes proven by an existing test — squarely rule 1 of ADR 0174. It is also not a genuine toss-up once one fact is checked, which the filing flagged as an open question rather than resolving.The fact that decides it
deployRunStore(internal/controlapi/provision.go) is in-memory, and says so in its own comment: "the run and the store share the control-plane process, so a restart loses both together." So a control-plane restart makesGET /api/v1/provision/devices/{id}/deployanswer404 no_deploy, and the dashboard's poll reds a definitive 4xx at once — #835'srestartToleranceMscovers 5xx/refused, not 404.That kills shape 1 (detach the driver) as a standalone fix. Detaching keeps the CLI alive, but the switch then restarts the control plane mid-deploy, losing the live run — trading a 502 red for a 404 red. It is the stronger invariant long-term and should be revisited, but only after the run store is persisted (filed as #861).
Ruling — shape 2, pinned at the unit
gatewayControlPlaneUnit(internal/clan/vmguest.go) now renders:on
systemd.services.idss-control-plane, soswitch-to-configurationleaves its own driver alone.Restart = "on-failure"stays — the exemption is from the switch, not from crash recovery.Pinned at the unit rather than by discipline in the caller, deliberately: the trap re-arms on every future change to the unit's text, and #790's Nextcloud exports were only what first sprang it. The invariant, stated where a future reader will hit it: a process driving a switch must not live in the cgroup of a unit that switch stops.
Proof
internal/clan/selfdeploy_driver_test.go— new; reded on all five gateway render shapes (VM private/rented-public/IDIP, full-install kanidm/IDIP) before the change, green after. It also pins thatRestart = "on-failure"survives.nix-instantiate --parseover the rendered control-plane surface — PARSE OK.restartIfChangedis used throughoutnixos/modules/system/boot/systemd.nix;stopIfChangedis consumed bynixos/lib/systemd-lib.nix:819.go build ./...,go vet, andgo test ./internal/... ./control-plane/...green.70ed992conorigin/main.GOTCHAS
restartToleranceMs) is right and stands — as the filing said, the refusal outlasted the window exactly as designed. Its diagnosis was wrong and is now marked so inline: it read the 502 as "a ~1 s window where the control plane was intentionally down" and ruled a 5xx always the restart gap and never a verdict. Its own drive's journal falsifies that (20260825T071850Z:1991— exit 101, noStarted idss-control-plane.serviceafterwards; there was no gap). New rule added: a refusal that outlasts the window is a finding, not noise — take it to the box's journal, never widen the window to make it go away.One correction to the filing
The secondary ask — fold
journalctl -u 'clan-switch-gateway-*'into the deploy fault "so the next recurrence names the panic" — will not name the panic. clan-core wraps the remote activation insystemd-run --pipe(internal/clan/enrollment.go:1083), soswitch-to-configuration's stderr goes to the pipe, not the journal — and when the panic is caused by that pipe breaking, the text is written to the broken pipe and lost. That is exactly whygrep -i panicfinds nothing across all three drives. The journal harvest is still worth doing (theStopping idss-control-plane/status=101pair one second apart IS the diagnosis), but it needs the ADR 0039 / #163 per-operation target resolver the deploy seam explicitly declines to fabricate (adapter.go:285-292). Filed as #862 with that correction and a cheap lower-bound alternative.Residue — left OPEN and named, not swept
What is NOT proven
The 101 only reproduces on a real droplet running a loopback
clan machines update, as the filing said. This is seam-proven, not drive-proven. #858 is the sole open blocker of standing-drive #722, so closing it releases the executor — the nextdeploy-filesdrive is the verdict, and I am holding this session open to read it.Amendment — I cannot read the verdict; this session is what is blocking it
Correcting the last line of the close-report above ("I am holding this session open to read it"). Closing #858 did release the executor —
executor: #722 is ready and unblocked — firing the drive— but the drive then declined to start:The session-runner run holding that slot is this one. Waiting for the drive from inside the session that blocks it cannot terminate, so I stopped waiting after ~10 minutes rather than burn the session's budget on a deadlock. The reservation is held, so the drive fires on the first executor tick (every 2 min) after this session exits.
Next session's first step, or whoever reads the next drive: check
deploy-fileson the first drive after20260825T212849Z.clan-switch-gateway-*.service: Main process exited, code=exited, status=101+ noStarted idss-control-plane.serviceafterwards) → reopen this ticket: the exemption did not take, and the first thing to check is whether the drive's gateway actually carried commit70ed992c(GOTCHAS #82's class — a green heal is not a landed heal).deploy-fileswith a DIFFERENT signature → new ticket; the 101 is plugged and something downstream of it is now reachable for the first time in three drives (the files closure has never once activated).idss-control-plane, so the landed binary never runs and Resume (#1567, GOTCHAS #241) can never fire #1636idss-control-plane, so the landed binary never runs and Resume (#1567, GOTCHAS #241) can never fire #1636idss-control-plane, so the landed binary never runs and Resume (#1567, GOTCHAS #241) can never fire #1636idss-control-plane, so the landed binary never runs and Resume (#1567, GOTCHAS #241) can never fire #1636