Skip to content

Refresh nspawn device config before machine startup#412

Draft
bcho with Copilot wants to merge 4 commits into
mainfrom
copilot/add-nspawn-config-hook
Draft

Refresh nspawn device config before machine startup#412
bcho with Copilot wants to merge 4 commits into
mainfrom
copilot/add-nspawn-config-hook

Conversation

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Host device paths can change across host reboots, leaving the persisted nspawn config with stale bind mounts. This adds a systemd-managed refresh step so device mappings are rediscovered before an existing nspawn machine starts.

  • Startup hook

    • Writes unbounded-agent-nspawn-config@<machine>.service
    • Orders systemd-nspawn@<machine>.service after the refresh unit
  • Config regeneration

    • Adds hidden agent command:
      unbounded-agent regenerate-nspawn-config kube1
    • Loads the persisted applied config for the machine
    • Resolves fresh host device/GPU state
    • Rewrites the .nspawn config and service drop-in
  • Lifecycle cleanup

    • Removes the generated refresh unit during nspawn reset cleanup
  • Docs and tests

    • Updates nspawn reference docs for the refresh behavior
    • Extends render tests and snapshots for the new systemd dependency

Copilot AI changed the title [WIP] Add hook to regenerate nspawn config on host changes Refresh nspawn device config before machine startup Jul 7, 2026
Copilot finished work on behalf of bcho July 7, 2026 16:17
Copilot AI requested a review from bcho July 7, 2026 16:17

@bcho bcho left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot can we rename the oneshot target to regenerate config so we can further extend it to include other config regeneration in the future

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot can we rename the oneshot target to regenerate config so we can further extend it to include other config regeneration in the future

Addressed in 71158be: the oneshot unit is now unbounded-agent-regenerate-config@<machine>.service and it runs the generalized hidden regenerate-config command.

Copilot finished work on behalf of bcho July 7, 2026 20:15
Copilot AI requested a review from bcho July 7, 2026 20:15
@bcho bcho marked this pull request as ready for review July 7, 2026 23:24
@bcho bcho requested a review from a team July 7, 2026 23:24
@bcho bcho marked this pull request as draft July 7, 2026 23:25
@bcho

bcho commented Jul 7, 2026

Copy link
Copy Markdown
Member

@copilot resolve conflicts

…nfig-hook

# Conflicts:
#	pkg/agent/phases/rootfs/nspawn.go
#	pkg/agent/phases/rootfs/nspawn_render_test.go

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve conflicts

Resolved the conflicts by merging origin/main into the PR branch and preserving the regenerate-config behavior in merge commit 7edafe8.

Copilot finished work on behalf of bcho July 7, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agent: nspawn config should tolerate device mapping changes on the host after host restart

2 participants