deploy-takeover: the kexec installer rejoins the mesh as a NEW peer on a NEW wt0 address, so every post-kexec phase deploys to the dead pre-kexec IP #1068

Closed
opened 2026-08-31 10:59:11 +00:00 by matou-build-agent · 1 comment

Failure

Drive 20260831T102457Z (target device, commit 4b01ae58) red at deploy-takeover after 661s, whole journey otherwise green (26/27 legs, artifacts/legs.json, artifacts/verdict.json):

clan: target_lost on node-req-0003: the takeover's deploy target root@100.82.251.189 stopped
answering during the kexec phase, before any disk work completed
[node-req-0003] ssh: connect to host 100.82.251.189 port 22: No route to host   (x8)

This is NOT a recurrence of #1057. That fix (commit 082daa34, in this drive's tree) holds: the installer's netbird DAEMON stood, the oneshot ran clean and exited successfully.

Evidence — the installer rejoined, at a different address

From logs/device-journal.txt (the post-kexec installer environment):

  • :877 — client/internal/profilemanager/config.go:294: generated new Wireguard key
  • :905 — client/internal/auth/auth.go:307: peer has been successfully registered on Management Service
  • :946 — client/internal/connect.go:387: Netbird engine started, the IP is: **100.82.232.94**/16
  • :950 — idss-installer-mesh: the takeover installer rejoined the mesh on wt0
  • :952 — systemd[1]: Finished IDSS takeover installer — rejoin the community mesh (wt0).

Corroborated by logs/device-units.txt:7 — the installer's netbird binds 100.82.232.94:53 and nothing on 100.82.251.189; and by logs/device-stall.txt:2,:9 — uptime 0:04 at 10:55:32 with a 2.0G tmpfs root, i.e. the box was alive in the kexec installer the whole time the deploy was getting No route to host. logs/device-do-forensics.txt confirms the droplet itself never faulted (tcp/22: a FRESH connect succeeded; the only DO action on droplet 596561468 is its create).

So: the box was up, on the mesh, reachable — at an address the deploy never tried.

Defect

Two lines encode an assumption this drive disproves.

  1. internal/provision/takeover.go:172-173 pins the enrollment's target once, at takeover start, to the device's pre-kexec wt0 address:

    if d.MeshAddress != "" {
        req.Target = clan.SSHTarget("root@" + d.MeshAddress)
    }
    

    That target drives every phase, including all post-kexec ones.

  2. internal/clan/netbird.go:653-730 (renderInstallerMesh) has the installer redeem a fresh single-use setup key (internal/clan/clan.go:397-406, minted per takeover at internal/provision/takeover.go:207-220 → control-plane/cmd/control-plane/whole_composition.go:913-922). A fresh key redeemed by a fresh WireGuard key is, to the management plane, a new peer — and a new peer is allocated a new mesh IP.

The doc comment asserts the opposite. internal/clan/netbird.go:624-626: "so the device reappears at its wt0 address in the installer environment and every post-kexec phase (disko, install, reboot) deploys to the ONE mesh target ADR 0209 rules, before AND after the kexec." The identity is not preserved across the kexec, so the address is not either. Same claim in internal/clan/clan.go:372-384 and in the ADR 0209 amendment (2026-08-30, #1011/#1012) it implements.

Suspected layer

The ADR 0209 amendment's addressing model — not the installer image, not the daemon wiring. The amendment already ruled on addressing once (it rejected "option A", a public/NetworkFacts.Address split, because a NAT'd member device has no such address — internal/clan/netbird.go:646-649), so re-opening it is a design call, which is why this is filed rather than healed.

What plugging it needs

Two candidate remedies; they differ in secret-handling posture, so pick one at design before coding:

  • (A) Re-resolve the target after the rejoin. The minted key auto-groups the new peer into node-<requestID> (internal/enroll/mesh_minter.go, NetbirdMinter doc — "auto-grouped into a group named for the request (node-) so the peer it admits is identifiable and revocable by request id"), and the gateway already holds a management-API client on that port. So the gateway can look the installer's new IP up by group after the kexec. Needs: a resolve-peer-address-by-node port beside MintInstaller, plus a way for clan.Enrollment to re-point its SSH target mid-run (today it cannot — the target is fixed at Enroll). Keeps the amendment's "never the device's original join key" invariant intact.
  • (B) Preserve the peer identity across the kexec. Bake the device's live netbird WireGuard private key into the installer image so it re-registers as the SAME peer and keeps 100.82.251.189. This directly contradicts the reasoning recorded at internal/clan/netbird.go:641-649, which justifies the baked copy precisely because the key is fresh, single-use and short-TTL ("a baked copy in a transient, locally-built image widens no standing blast radius") — a standing peer key would not clear that bar. Do not take this path without an explicit ADR ruling.

Whichever is chosen, internal/clan/netbird.go:624-626, internal/clan/clan.go:372-384 and the ADR 0209 amendment must be corrected: the current text states an invariant the mesh does not provide.

Also check as part of the fix (not proven by this run, since the takeover never got past kexec): whether the installed system likewise comes back on a third address, which would leave the stale d.MeshAddress wrong for the files placement at internal/provision/deploy.go:751,778 too.

Cost note. Each rediscovery of this costs a full one-droplet stand-up plus ~11 minutes of leg ceiling; the drive should stay blocked until the addressing model is ruled on.

drive 20260831T102457Z red at deploy-takeover: deploy failed (rescue): clan: target_lost on node-req-0003: the takeover's deploy target root@100.82.251.189 stopped answering during the kexec phase, before any disk work completed — the session wa
evidence: /home/swarm/swarm/Matou/idss/test-results/drive-device/20260831T102457Z on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured

## Failure Drive `20260831T102457Z` (target `device`, commit `4b01ae58`) red at `deploy-takeover` after 661s, whole journey otherwise green (26/27 legs, `artifacts/legs.json`, `artifacts/verdict.json`): ``` clan: target_lost on node-req-0003: the takeover's deploy target root@100.82.251.189 stopped answering during the kexec phase, before any disk work completed [node-req-0003] ssh: connect to host 100.82.251.189 port 22: No route to host (x8) ``` This is NOT a recurrence of #1057. That fix (commit `082daa34`, in this drive's tree) holds: the installer's netbird DAEMON stood, the oneshot ran clean and **exited successfully**. ## Evidence — the installer rejoined, at a different address From `logs/device-journal.txt` (the post-kexec installer environment): - `:877` — `client/internal/profilemanager/config.go:294: generated new Wireguard key` - `:905` — `client/internal/auth/auth.go:307: peer has been successfully registered on Management Service` - `:946` — `client/internal/connect.go:387: Netbird engine started, the IP is: **100.82.232.94**/16` - `:950` — `idss-installer-mesh: the takeover installer rejoined the mesh on wt0` - `:952` — `systemd[1]: Finished IDSS takeover installer — rejoin the community mesh (wt0).` Corroborated by `logs/device-units.txt:7` — the installer's netbird binds `100.82.232.94:53` and nothing on `100.82.251.189`; and by `logs/device-stall.txt:2,:9` — uptime 0:04 at 10:55:32 with a 2.0G tmpfs root, i.e. the box was alive in the kexec installer the whole time the deploy was getting `No route to host`. `logs/device-do-forensics.txt` confirms the droplet itself never faulted (`tcp/22: a FRESH connect succeeded`; the only DO action on droplet 596561468 is its `create`). So: the box was up, on the mesh, reachable — at an address the deploy never tried. ## Defect Two lines encode an assumption this drive disproves. 1. `internal/provision/takeover.go:172-173` pins the enrollment's target once, at takeover start, to the device's **pre-kexec** wt0 address: ```go if d.MeshAddress != "" { req.Target = clan.SSHTarget("root@" + d.MeshAddress) } ``` That target drives every phase, including all post-kexec ones. 2. `internal/clan/netbird.go:653-730` (`renderInstallerMesh`) has the installer redeem a **fresh single-use setup key** (`internal/clan/clan.go:397-406`, minted per takeover at `internal/provision/takeover.go:207-220` → `control-plane/cmd/control-plane/whole_composition.go:913-922`). A fresh key redeemed by a fresh WireGuard key is, to the management plane, a **new peer** — and a new peer is allocated a **new mesh IP**. The doc comment asserts the opposite. `internal/clan/netbird.go:624-626`: "so the device reappears **at its wt0 address** in the installer environment and every post-kexec phase (disko, install, reboot) deploys to the ONE mesh target ADR 0209 rules, before AND after the kexec." The identity is not preserved across the kexec, so the address is not either. Same claim in `internal/clan/clan.go:372-384` and in the ADR 0209 amendment (2026-08-30, #1011/#1012) it implements. ## Suspected layer The ADR 0209 amendment's addressing model — not the installer image, not the daemon wiring. The amendment already ruled on addressing once (it rejected "option A", a public/`NetworkFacts.Address` split, because a NAT'd member device has no such address — `internal/clan/netbird.go:646-649`), so re-opening it is a design call, which is why this is filed rather than healed. ## What plugging it needs Two candidate remedies; they differ in secret-handling posture, so **pick one at design before coding**: - **(A) Re-resolve the target after the rejoin.** The minted key auto-groups the new peer into `node-<requestID>` (`internal/enroll/mesh_minter.go`, `NetbirdMinter` doc — "auto-grouped into a group named for the request (node-<requestID>) so the peer it admits is identifiable and revocable by request id"), and the gateway already holds a management-API client on that port. So the gateway *can* look the installer's new IP up by group after the kexec. Needs: a resolve-peer-address-by-node port beside `MintInstaller`, plus a way for `clan.Enrollment` to re-point its SSH target mid-run (today it cannot — the target is fixed at `Enroll`). Keeps the amendment's "never the device's original join key" invariant intact. - **(B) Preserve the peer identity across the kexec.** Bake the device's live netbird WireGuard private key into the installer image so it re-registers as the SAME peer and keeps `100.82.251.189`. This directly contradicts the reasoning recorded at `internal/clan/netbird.go:641-649`, which justifies the baked copy precisely because the key is fresh, single-use and short-TTL ("a baked copy in a transient, locally-built image widens no standing blast radius") — a standing peer key would not clear that bar. Do not take this path without an explicit ADR ruling. Whichever is chosen, `internal/clan/netbird.go:624-626`, `internal/clan/clan.go:372-384` and the ADR 0209 amendment must be corrected: the current text states an invariant the mesh does not provide. **Also check as part of the fix** (not proven by this run, since the takeover never got past kexec): whether the *installed* system likewise comes back on a third address, which would leave the stale `d.MeshAddress` wrong for the files placement at `internal/provision/deploy.go:751,778` too. **Cost note.** Each rediscovery of this costs a full one-droplet stand-up plus ~11 minutes of leg ceiling; the drive should stay blocked until the addressing model is ruled on. drive `20260831T102457Z` red at `deploy-takeover`: `deploy failed (rescue): clan: target_lost on node-req-0003: the takeover's deploy target root@100.82.251.189 stopped answering during the kexec phase, before any disk work completed — the session wa` evidence: `/home/swarm/swarm/Matou/idss/test-results/drive-device/20260831T102457Z` on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured <!-- rehearsal-sig: 800a2936720b -->
Author
Member

Close report — #1068 fixed (option A), commit 03fb43cf

Ruled by agent under ADR 0174 — veto anytime. The ticket asked the addressing model to be ruled on before coding. Ruling: adopt option A (re-resolve the target after the rejoin). It is a two-way door — a revertible code change, proven at the clan + enroll seams, that keeps the #1012 amendment's "never the device's original join key" invariant intact. Option B (bake the device's live netbird WireGuard private key so it re-registers as the same peer) is rejected: a standing peer key in a baked image is a security-posture widening — a one-way door under ADR 0174 — and does not clear the bar the amendment set for the fresh, single-use, short-TTL key. Its trust residue would need an explicit human ruling; option A needs none.

Root cause confirmed

The #1012 amendment assumed the installer "reappears at its wt0 address." It does not: a fresh single-use node-scoped setup key redeemed by a fresh WireGuard key is, to the Netbird management plane, a new peer → a new mesh IP. Drive 20260831T102457Z proved it (installer up at 100.82.232.94, deploy knocking the dead 100.82.251.189). Not a #1057 recurrence — the declared daemon held.

What landed (all offline-proven, revertible)

  • enroll.NetbirdMinter.ResolveInstallerAddress(node, exclude) — reads GET /api/peers, returns the connected peer in the node-<requestID> group whose IP ≠ the pre-kexec address (the dead peer lingers, disconnected); polls until the installer rejoins or the ctx deadline. No rejoined peer → error, never a fabricated address (ADR 0100).
  • clan.InstallerAddressResolver port + EnrollRequest.InstallerResolver (request-only). On a kexec-phase connectivity fault before any disk work, enrollment.repointToRejoinedInstaller re-points snap.Target and continues disko/install/reboot against the rejoined address; a box that never rejoins still reds the honest target_lost (naming the dead target, no resume promise). The re-pointed target is persisted, so a resume needs no resolver.
  • Wiring: provision.InstallerMeshMinter gains ResolveInstallerAddress; takeover sets req.InstallerResolver = o.installerMinter; the whole-composition adapter delegates to the NetbirdMinter. The gateway already held that management-API client (the one the mint rode).

Proof

Red-first offline seams: internal/clan/installer_repoint_test.go (re-point → new address; never-rejoins → target_lost with no disk work; no resolver → unchanged pre-#1068 terminal), internal/enroll/mesh_minter_test.go (ResolveInstallerAddress returns / skips-the-pre-kexec-address / errs-loud). go build/vet/test ./internal/clan ./internal/enroll ./internal/provision ./control-plane/... + gofmt green.

Docs corrected (the ticket's requirement)

The false invariant is fixed everywhere it was stated: internal/clan/netbird.go, internal/clan/clan.go, internal/clan/adapter.go, internal/provision/provision.go, and a new ADR 0209 amendment (2026-08-31) recording the ruling + the corrected model. GOTCHAS #142 records the hazard.

Residue (not this ticket)

  • Live re-green of deploy-takeover rides the next paid device drive — the mechanism is proven at the seams; the nixos-anywhere reconnect timing is the loop-closer, as with every prior drive-found defect.
  • #1069 filed: whether the installed system likewise returns on a third address (staling d.MeshAddress for the front-door files route and possibly the post-reboot verify reconnect) — unprovable here because this drive never got past the kexec.

Closing as done + proven at the offline seams. Re-open if the next device drive shows the re-point missed a frame.

## Close report — #1068 fixed (option A), commit `03fb43cf` **Ruled by agent under ADR 0174 — veto anytime.** The ticket asked the addressing model to be ruled on before coding. Ruling: **adopt option A (re-resolve the target after the rejoin).** It is a two-way door — a revertible code change, proven at the clan + enroll seams, that keeps the #1012 amendment's **"never the device's original join key"** invariant intact. **Option B (bake the device's live netbird WireGuard private key so it re-registers as the same peer) is rejected**: a *standing* peer key in a baked image is a security-posture widening — a one-way door under ADR 0174 — and does not clear the bar the amendment set for the *fresh, single-use, short-TTL* key. Its trust residue would need an explicit human ruling; option A needs none. ### Root cause confirmed The #1012 amendment assumed the installer "reappears at its `wt0` address." It does not: a **fresh** single-use node-scoped setup key redeemed by a **fresh** WireGuard key is, to the Netbird management plane, a **new peer** → a **new mesh IP**. Drive `20260831T102457Z` proved it (installer up at `100.82.232.94`, deploy knocking the dead `100.82.251.189`). Not a #1057 recurrence — the declared daemon held. ### What landed (all offline-proven, revertible) - **`enroll.NetbirdMinter.ResolveInstallerAddress(node, exclude)`** — reads `GET /api/peers`, returns the **connected** peer in the `node-<requestID>` group whose IP ≠ the pre-kexec address (the dead peer lingers, disconnected); polls until the installer rejoins or the ctx deadline. No rejoined peer → error, never a fabricated address (ADR 0100). - **`clan.InstallerAddressResolver`** port + `EnrollRequest.InstallerResolver` (request-only). On a kexec-phase connectivity fault before any disk work, `enrollment.repointToRejoinedInstaller` re-points `snap.Target` and continues disko/install/reboot against the rejoined address; a box that never rejoins still reds the honest `target_lost` (naming the dead target, no resume promise). The re-pointed target is persisted, so a resume needs no resolver. - **Wiring**: `provision.InstallerMeshMinter` gains `ResolveInstallerAddress`; `takeover` sets `req.InstallerResolver = o.installerMinter`; the whole-composition adapter delegates to the `NetbirdMinter`. The gateway already held that management-API client (the one the mint rode). ### Proof Red-first offline seams: `internal/clan/installer_repoint_test.go` (re-point → new address; never-rejoins → `target_lost` with no disk work; **no resolver → unchanged pre-#1068 terminal**), `internal/enroll/mesh_minter_test.go` (`ResolveInstallerAddress` returns / skips-the-pre-kexec-address / errs-loud). `go build`/`vet`/`test ./internal/clan ./internal/enroll ./internal/provision ./control-plane/...` + gofmt green. ### Docs corrected (the ticket's requirement) The false invariant is fixed everywhere it was stated: `internal/clan/netbird.go`, `internal/clan/clan.go`, `internal/clan/adapter.go`, `internal/provision/provision.go`, and a new **ADR 0209 amendment (2026-08-31)** recording the ruling + the corrected model. `GOTCHAS #142` records the hazard. ### Residue (not this ticket) - **Live re-green** of `deploy-takeover` rides the next paid device drive — the mechanism is proven at the seams; the nixos-anywhere reconnect timing is the loop-closer, as with every prior drive-found defect. - **#1069** filed: whether the *installed* system likewise returns on a **third** address (staling `d.MeshAddress` for the front-door files route and possibly the post-reboot verify reconnect) — unprovable here because this drive never got past the kexec. Closing as done + proven at the offline seams. Re-open if the next device drive shows the re-point missed a frame.
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#1068
No description provided.