device-add: a COLD VM-mode install can never create the guest — the VM manager resolves the staged slot before StageGuest fills it (BaseImage ""); drives hide it by running the one-liner twice #2004

Closed
opened 2026-09-30 01:12:28 +00:00 by ben · 2 comments
Owner

Symptom

A VM-mode join on a machine that has never had the agent always fails at guest Create, even though the guest bundle was downloaded and unpacked correctly:

> 2
Dedicate to the community: …
level=ERROR msg="install command did not reach Pending" component=agent err="join: create vm guest: vm: the private-path payload is not carried — missing NixOS guest base image (\"\"); …"

bens-mac-04 joining Whakatōhea Demo by hand, 2026-09-30. /var/lib/idss/vm-guest/nixos-guest.qcow2 (2.2 GB) landed at 00:51:43Z; the create failed at 00:51:51Z looking for an image at the empty path.

Cause

Order of operations in the install command. runInstall (agent/cmd/agent/main.go:622) calls joinAdapters() first, which builds the VM manager with vm.NewResolvedWithGuestKey → vm.ResolveConfig() (internal/vm/resolve.go:81). ResolveConfig reads stagedGuestSlot() at that moment: on a cold machine the slot does not exist yet, so BaseImage resolves to "". Only later does join.RunInstallCommand → InstallAgent → StageGuest (internal/join/cli.go:102) download and unpack the slot. The manager never looks again.

The same stale resolution sits in the standing idss-agent join service, started by the service installer (00:37:36Z) before the slot existed — its manager also carries BaseImage="" until the service restarts.

Every drive missed this because the byo/device drives run the one-liner in an agent-install leg and then run it again in join — by then the slot exists and ResolveConfig finds it (ADR 0264 fires 6–8). A single cold run has never worked.

Fix

  • Resolve the guest artefacts after staging, or lazily at Create: ResolveConfig re-reads the staged slot when BaseImage is empty (the cheapest fix — Manager.Create calls stagedGuestSlot() again before missingPayload), or the install command builds the VM manager after InstallAgent returns.
  • The standing service picks up a slot that appears after it started (same lazy re-read, or the install command restarts the service once the slot is staged).
  • A seam test that stages the slot AFTER the manager is built and proves Create finds the image; a drive leg or the device-vm-byo target running the one-liner once on a clean machine (today's double run hides the defect — make the second run a red).

Workaround (for the hand run)

Re-run the install (re-downloads, see the silent-download ticket) — or sudo systemctl restart idss-agent and sudo IDSS_COMMUNITY_ORIGIN=<apex> idss-agent enroll <code>, which skips the stage and resolves the slot that is now present.

Siblings

Found in the one hand run (bens-mac-04 → Whakatōhea Demo, 2026-09-30): #2002 #2003 #2005 #2006 #2007

## Symptom A VM-mode join on a machine that has never had the agent **always fails at guest Create**, even though the guest bundle was downloaded and unpacked correctly: ``` > 2 Dedicate to the community: … level=ERROR msg="install command did not reach Pending" component=agent err="join: create vm guest: vm: the private-path payload is not carried — missing NixOS guest base image (\"\"); …" ``` `bens-mac-04` joining Whakatōhea Demo by hand, 2026-09-30. `/var/lib/idss/vm-guest/nixos-guest.qcow2` (2.2 GB) landed at 00:51:43Z; the create failed at 00:51:51Z looking for an image at the **empty** path. ## Cause Order of operations in the install command. `runInstall` (`agent/cmd/agent/main.go:622`) calls `joinAdapters()` first, which builds the VM manager with `vm.NewResolvedWithGuestKey` → `vm.ResolveConfig()` (`internal/vm/resolve.go:81`). `ResolveConfig` reads `stagedGuestSlot()` **at that moment**: on a cold machine the slot does not exist yet, so `BaseImage` resolves to `""`. Only later does `join.RunInstallCommand` → `InstallAgent` → `StageGuest` (`internal/join/cli.go:102`) download and unpack the slot. The manager never looks again. The same stale resolution sits in the standing `idss-agent join` service, started by the service installer (00:37:36Z) before the slot existed — its manager also carries `BaseImage=""` until the service restarts. Every drive missed this because the byo/device drives run the one-liner in an `agent-install` leg and then run it **again** in `join` — by then the slot exists and `ResolveConfig` finds it (ADR 0264 fires 6–8). A single cold run has never worked. ## Fix - Resolve the guest artefacts **after** staging, or lazily at Create: `ResolveConfig` re-reads the staged slot when `BaseImage` is empty (the cheapest fix — `Manager.Create` calls `stagedGuestSlot()` again before `missingPayload`), or the install command builds the VM manager after `InstallAgent` returns. - The standing service picks up a slot that appears after it started (same lazy re-read, or the install command restarts the service once the slot is staged). - A seam test that stages the slot AFTER the manager is built and proves Create finds the image; a drive leg or the `device-vm-byo` target running the one-liner **once** on a clean machine (today's double run hides the defect — make the second run a red). ## Workaround (for the hand run) Re-run the install (re-downloads, see the silent-download ticket) — or `sudo systemctl restart idss-agent` and `sudo IDSS_COMMUNITY_ORIGIN=<apex> idss-agent enroll <code>`, which skips the stage and resolves the slot that is now present. ## Siblings Found in the one hand run (bens-mac-04 → Whakatōhea Demo, 2026-09-30): #2002 #2003 #2005 #2006 #2007

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

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

close-report for #2004 — status success

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

envelope
{
  "issue": 2004,
  "status": "success",
  "commits": [
    "2fa0d35e"
  ],
  "changed_files": [
    "STATUS.md",
    "internal/vm/manager.go",
    "internal/vm/manager_test.go",
    "internal/vm/resolve.go"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci -c go test ./internal/vm/ ./internal/join/...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c go vet ./internal/vm/",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c go build -tags dev ./internal/vm/",
      "exit_code": 0
    }
  ],
  "criteria": {
    "A seam test stages the slot AFTER the manager is built and proves Create finds the image": "TestCreate_ColdSlotResolvedLazilyAtCreate in internal/vm/manager_test.go — red-first on the exact `missing NixOS guest base image (\"\")` message, green after the fix",
    "Resolve the guest artefacts after staging / lazily at Create (ResolveConfig re-reads the staged slot when BaseImage is empty)": "reresolveStagedGuest in internal/vm/resolve.go, called by Manager.Create in internal/vm/manager.go before missingPayload — re-reads stagedGuestSlot() when BaseImage==\"\"",
    "The standing service picks up a slot that appears after it started (same lazy re-read)": "The standing idss-agent join service uses the same vm.Manager; its next Create call runs reresolveStagedGuest and resolves the now-present slot — covered by the same lazy read"
  },
  "summary": "Manager.Create lazily re-reads the staged guest slot when BaseImage is empty, so a single cold VM-mode install stands the guest up instead of failing on BaseImage \"\".",
  "blockers": []
}
**close-report** for #2004 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 2004, "status": "success", "commits": [ "2fa0d35e" ], "changed_files": [ "STATUS.md", "internal/vm/manager.go", "internal/vm/manager_test.go", "internal/vm/resolve.go" ], "tests": [ { "command": "nix develop .#go-ci -c go test ./internal/vm/ ./internal/join/...", "exit_code": 0 }, { "command": "nix develop .#go-ci -c go vet ./internal/vm/", "exit_code": 0 }, { "command": "nix develop .#go-ci -c go build -tags dev ./internal/vm/", "exit_code": 0 } ], "criteria": { "A seam test stages the slot AFTER the manager is built and proves Create finds the image": "TestCreate_ColdSlotResolvedLazilyAtCreate in internal/vm/manager_test.go — red-first on the exact `missing NixOS guest base image (\"\")` message, green after the fix", "Resolve the guest artefacts after staging / lazily at Create (ResolveConfig re-reads the staged slot when BaseImage is empty)": "reresolveStagedGuest in internal/vm/resolve.go, called by Manager.Create in internal/vm/manager.go before missingPayload — re-reads stagedGuestSlot() when BaseImage==\"\"", "The standing service picks up a slot that appears after it started (same lazy re-read)": "The standing idss-agent join service uses the same vm.Manager; its next Create call runs reresolveStagedGuest and resolves the now-present slot — covered by the same lazy read" }, "summary": "Manager.Create lazily re-reads the staged guest slot when BaseImage is empty, so a single cold VM-mode install stands the guest up instead of failing on BaseImage \"\".", "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#2004
No description provided.