Refresh nspawn device config before machine startup - #412
Refresh nspawn device config before machine startup#412hbc (bcho) with Copilot wants to merge 5 commits into
Conversation
hbc (bcho)
left a comment
There was a problem hiding this comment.
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 |
|
Copilot resolve conflicts |
…nfig-hook # Conflicts: # pkg/agent/phases/rootfs/nspawn.go # pkg/agent/phases/rootfs/nspawn_render_test.go
Resolved the conflicts by merging |
|
Copilot resolve conflict |
…nfig-hook # Conflicts: # pkg/agent/phases/rootfs/nspawn.go # pkg/agent/phases/rootfs/nspawn_render_test.go Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Resolved the latest conflicts by merging |
There was a problem hiding this comment.
Pull request overview
Adds pre-start regeneration of nspawn device mappings so host reboot path changes are refreshed.
Changes:
- Adds a systemd oneshot regeneration dependency.
- Adds hidden regeneration commands and persisted-config loading.
- Updates cleanup, documentation, render tests, and snapshots.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
cmd/agent/internal/cmd/cmd.go |
Registers regeneration commands. |
cmd/agent/internal/cmd/nspawn_config.go |
Implements persisted-config regeneration. |
docs/content/reference/agent/nspawn.md |
Documents refresh behavior and artifacts. |
pkg/agent/goalstates/constants.go |
Defines regeneration unit naming. |
pkg/agent/phases/reset/nspawn.go |
Removes generated units during cleanup. |
pkg/agent/phases/rootfs/assets/config-regeneration.service |
Defines the pre-start oneshot. |
pkg/agent/phases/rootfs/assets/service-override.conf |
Adds regeneration ordering. |
pkg/agent/phases/rootfs/nspawn.go |
Renders regeneration units and nspawn configuration. |
pkg/agent/phases/rootfs/nspawn_render_test.go |
Tests rendered dependencies and unit content. |
pkg/agent/phases/rootfs/testdata/render/cpu-only.service-override.conf.golden |
Updates CPU snapshot. |
pkg/agent/phases/rootfs/testdata/render/nvidia-all-helpers.service-override.conf.golden |
Updates NVIDIA helper snapshot. |
pkg/agent/phases/rootfs/testdata/render/nvidia-gb300-rack-full.service-override.conf.golden |
Updates GB300 snapshot. |
pkg/agent/phases/rootfs/testdata/service-override-kube1.conf.golden |
Updates kube1 snapshot. |
pkg/agent/phases/rootfs/testdata/service-override-kube2.conf.golden |
Updates kube2 snapshot. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if err := utilio.WriteFile(goalState.ServiceOverrideFile, overrideBuf.Bytes(), 0o644); err != nil { | ||
| return fmt.Errorf("write service override %s: %w", goalState.ServiceOverrideFile, err) |
| gs, err := goalstates.ResolveMachine(log, cfg, machineName, nil) | ||
| if err != nil { | ||
| return fmt.Errorf("resolve machine goal state: %w", err) |
| func regenerateNSpawnConfig(ctx context.Context, log *slog.Logger, machineName string) error { | ||
| cfg, ok, err := loadAppliedConfigForMachine(log, machineName) |
| [Unit] | ||
| Description=Regenerate configuration for {{.MachineName}} |
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
unbounded-agent-nspawn-config@<machine>.servicesystemd-nspawn@<machine>.serviceafter the refresh unitConfig regeneration
.nspawnconfig and service drop-inLifecycle cleanup
Docs and tests