device-add: the foreground landing runs netbird-mesh up before the guest's mesh daemon is up — a red 'setup key refused / netbird absent' for a join the standing service lands 20 s later #2013

Closed
opened 2026-09-30 03:35:14 +00:00 by ben · 2 comments
Owner

Symptom

A VM-mode join on bens-mac-04 → Whakatōhea Demo (2026-09-30, release 3061, code Helper) walked create → pair → approve, then the foreground install printed:

✓ creating VM… ✓ VM online — it is the joining node
✓ connection request sent to WHAKATOHEA DEMO
waiting for the operator's decision…
level=ERROR msg="install command reached Pending but failed during landing" err="join: guest mesh join: vm: guest `netbird-mesh up` failed — the setup key was refused, or netbird is absent from the guest image (ADR 0223): ssh … root@127.0.0.1 netbird-mesh up --setup-key … : exit status 1: … retrying Login to the Management service … context canceled … Error: daemon up failed: call service up method: rpc error: code = Unknown desc = client gave up to connect"

Twenty seconds later the standing idss-agent join service resumed the anchor and landed it cleanly — ✓ joined the community network / ✓ community trust installed / ✓ this machine is enrolled, "resumed a stranded join whose terminal is gone" — and the device is enrolled (node-req-0002, mesh peer 1/1 connected). The owner was left with a red ERROR for a join that succeeded.

Cause

Timing. idss-guest.service started at 22:32:00 (local); the operator approved at once; GuestMeshJoin ran netbird-mesh up over loopback SSH at 22:32:33 — 33 s after first boot, before the guest's netbird daemon was accepting its own RPC socket. "VM online" (DDR 0131) is the SSH hostfwd accepting, which says nothing about the daemon. The netbird CLI's "client gave up to connect" is exactly "no daemon yet"; the error text blames the setup key or a missing binary, neither of which was true. The resume at 22:32:54 hit a ready daemon and succeeded.

Fix

  • GuestMeshJoin waits for the daemon before up: poll netbird-mesh status (or the daemon socket) over the same SSH until it answers, with a bounded budget (the guest boots in well under a minute), then run up. A refusal AFTER the daemon answers keeps today's setup-key/absent-binary text; "client gave up to connect" gets its own honest line ("the guest's mesh daemon is not up yet").
  • The foreground landing retries the mesh join the way the resume path effectively does, rather than exiting non-zero and leaving the owner to notice the service finishing the job in the journal.
  • A seam test with a scripted guest whose daemon answers only on the Nth call.

Sibling of #2002–#2007 (the same machine's first attempt). ADR 0223 §2 (GuestMeshJoin over loopback), DDR 0131 (readiness = hostfwd accepting).

## Symptom A VM-mode join on `bens-mac-04` → Whakatōhea Demo (2026-09-30, release 3061, code Helper) walked create → pair → approve, then the foreground install printed: ``` ✓ creating VM… ✓ VM online — it is the joining node ✓ connection request sent to WHAKATOHEA DEMO waiting for the operator's decision… level=ERROR msg="install command reached Pending but failed during landing" err="join: guest mesh join: vm: guest `netbird-mesh up` failed — the setup key was refused, or netbird is absent from the guest image (ADR 0223): ssh … root@127.0.0.1 netbird-mesh up --setup-key … : exit status 1: … retrying Login to the Management service … context canceled … Error: daemon up failed: call service up method: rpc error: code = Unknown desc = client gave up to connect" ``` Twenty seconds later the standing `idss-agent join` service resumed the anchor and landed it cleanly — `✓ joined the community network / ✓ community trust installed / ✓ this machine is enrolled`, "resumed a stranded join whose terminal is gone" — and the device is enrolled (`node-req-0002`, mesh peer 1/1 connected). The owner was left with a red ERROR for a join that succeeded. ## Cause Timing. `idss-guest.service` started at 22:32:00 (local); the operator approved at once; `GuestMeshJoin` ran `netbird-mesh up` over loopback SSH at 22:32:33 — 33 s after first boot, before the guest's netbird **daemon** was accepting its own RPC socket. "VM online" (DDR 0131) is the SSH hostfwd accepting, which says nothing about the daemon. The netbird CLI's "client gave up to connect" is exactly "no daemon yet"; the error text blames the setup key or a missing binary, neither of which was true. The resume at 22:32:54 hit a ready daemon and succeeded. ## Fix - `GuestMeshJoin` waits for the daemon before `up`: poll `netbird-mesh status` (or the daemon socket) over the same SSH until it answers, with a bounded budget (the guest boots in well under a minute), then run `up`. A refusal AFTER the daemon answers keeps today's setup-key/absent-binary text; "client gave up to connect" gets its own honest line ("the guest's mesh daemon is not up yet"). - The foreground landing retries the mesh join the way the resume path effectively does, rather than exiting non-zero and leaving the owner to notice the service finishing the job in the journal. - A seam test with a scripted guest whose daemon answers only on the Nth call. ## Related Sibling of #2002–#2007 (the same machine's first attempt). ADR 0223 §2 (GuestMeshJoin over loopback), DDR 0131 (readiness = hostfwd accepting).

swarm-claim host=matou-dev-server-01 run=36239
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=36239 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #2013 — status success

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

envelope
{
  "issue": 2013,
  "status": "success",
  "commits": [
    "8c96cc2aac22cdba9bb1b6c438c27954c059a8bb"
  ],
  "changed_files": [
    "internal/vm/manager.go",
    "internal/vm/manager_test.go",
    "docs/GOTCHAS.md"
  ],
  "tests": [
    {
      "command": "go test ./internal/vm/",
      "exit_code": 0
    }
  ],
  "criteria": {
    "GuestMeshJoin waits for the daemon before `up`: poll netbird-mesh status until it answers, bounded budget, then run up": "internal/vm/manager.go waitGuestMeshDaemon() polls plain `netbird-mesh status` until isMeshDaemonDown is false, bounded by cfg.ReadyTimeout; called in GuestMeshJoin before the `up` redeem. Proven by TestGuestMeshJoin_WaitsForTheDaemonThenRedeems (daemon answers on the 3rd probe; join lands and `up` ran only after) and TestGuestMeshJoin_DaemonNeverUpFailsWithinCeiling (never-up daemon fails loud, no `up`).",
    "A refusal AFTER the daemon answers keeps setup-key/absent-binary text; 'client gave up to connect' gets its own honest line": "internal/vm/manager.go isMeshDaemonDown branch in GuestMeshJoin returns the honest daemon-not-up line; the setup-key text stays for a genuine non-daemon non-transport `up` exit. Proven by TestGuestMeshJoin_UpDaemonDownGetsItsOwnHonestLine and the unchanged TestGuestMeshJoin_UpCommandFailureBlamesSetupKey.",
    "The foreground landing retries the mesh join the way the resume path effectively does, rather than exiting non-zero": "The retry now lives inside GuestMeshJoin (the daemon gate), so the foreground join walked by RunInstallCommand->AwaitAndLand->Enroll->GuestMeshJoin waits for the daemon internally instead of firing `up` once and exiting red — the same job the standing resume did 20s later. internal/join/land.go's VM branch is unchanged and drives the now-waiting GuestMeshJoin.",
    "A seam test with a scripted guest whose daemon answers only on the Nth call": "internal/vm/manager_test.go TestGuestMeshJoin_WaitsForTheDaemonThenRedeems with guestStatusQueue (daemon-down, daemon-down, NeedsLogin) — `up` held until the 3rd probe answered."
  },
  "summary": "GuestMeshJoin waits for the guest's netbird daemon's RPC socket before `netbird-mesh up`, so a VM-mode foreground landing succeeds on the first run instead of reding 'client gave up to connect'; a still-down daemon gets its own honest line, never the setup-key/absent-binary text.",
  "blockers": []
}
**close-report** for #2013 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 2013, "status": "success", "commits": [ "8c96cc2aac22cdba9bb1b6c438c27954c059a8bb" ], "changed_files": [ "internal/vm/manager.go", "internal/vm/manager_test.go", "docs/GOTCHAS.md" ], "tests": [ { "command": "go test ./internal/vm/", "exit_code": 0 } ], "criteria": { "GuestMeshJoin waits for the daemon before `up`: poll netbird-mesh status until it answers, bounded budget, then run up": "internal/vm/manager.go waitGuestMeshDaemon() polls plain `netbird-mesh status` until isMeshDaemonDown is false, bounded by cfg.ReadyTimeout; called in GuestMeshJoin before the `up` redeem. Proven by TestGuestMeshJoin_WaitsForTheDaemonThenRedeems (daemon answers on the 3rd probe; join lands and `up` ran only after) and TestGuestMeshJoin_DaemonNeverUpFailsWithinCeiling (never-up daemon fails loud, no `up`).", "A refusal AFTER the daemon answers keeps setup-key/absent-binary text; 'client gave up to connect' gets its own honest line": "internal/vm/manager.go isMeshDaemonDown branch in GuestMeshJoin returns the honest daemon-not-up line; the setup-key text stays for a genuine non-daemon non-transport `up` exit. Proven by TestGuestMeshJoin_UpDaemonDownGetsItsOwnHonestLine and the unchanged TestGuestMeshJoin_UpCommandFailureBlamesSetupKey.", "The foreground landing retries the mesh join the way the resume path effectively does, rather than exiting non-zero": "The retry now lives inside GuestMeshJoin (the daemon gate), so the foreground join walked by RunInstallCommand->AwaitAndLand->Enroll->GuestMeshJoin waits for the daemon internally instead of firing `up` once and exiting red — the same job the standing resume did 20s later. internal/join/land.go's VM branch is unchanged and drives the now-waiting GuestMeshJoin.", "A seam test with a scripted guest whose daemon answers only on the Nth call": "internal/vm/manager_test.go TestGuestMeshJoin_WaitsForTheDaemonThenRedeems with guestStatusQueue (daemon-down, daemon-down, NeedsLogin) — `up` held until the 3rd probe answered." }, "summary": "GuestMeshJoin waits for the guest's netbird daemon's RPC socket before `netbird-mesh up`, so a VM-mode foreground landing succeeds on the first run instead of reding 'client gave up to connect'; a still-down daemon gets its own honest line, never the setup-key/absent-binary text.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#2013
No description provided.