Skip to content

Order nspawn after required host systemd services - #281

Merged
hbc (bcho) merged 3 commits into
mainfrom
phealy/systemd
Aug 19, 2026
Merged

Order nspawn after required host systemd services#281
hbc (bcho) merged 3 commits into
mainfrom
phealy/systemd

Conversation

@phealy

Copy link
Copy Markdown
Contributor

Summary

  • order the AKS Flex Node agent and nspawn machine after systemd-udev-settle.service
  • add bootstrap.additionalRequiredServices for host services that must complete before nspawn starts
  • render configured services into the per-machine nspawn drop-in as both Requires= and After= dependencies
  • validate configured values as systemd .service unit names and document the new setting

Motivation

Some host images run services such as ib_rdma_configure.service that rename or otherwise reconfigure devices during boot. If nspawn starts concurrently, it can capture stale device names and fail to expose the expected objects to the worker node. Explicit ordering ensures host device discovery and renaming finish before the machine starts.

Configuration

{
  "bootstrap": {
    "additionalRequiredServices": [
      "ib_rdma_configure.service"
    ]
  }
}

The generated nspawn drop-in requires each configured service and orders nspawn after it. The dependency configuration is reconciled during bootstrap and repave and remains safe to apply repeatedly.

Validation

  • make check
  • focused config and daemon tests, including invalid unit names and idempotent drop-in reconciliation

Add explicit udev-settle ordering for the Flex agent and nspawn machine, and allow operators to configure required host services that must complete before nspawn starts.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 19, 2026 16:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances AKS Flex Node’s host-boot ordering guarantees by adding explicit systemd dependency wiring so the agent and each systemd-nspawn machine can be started after udev settle and optionally after/with additional host services that must finish device setup before the containerized node starts.

Changes:

  • Add a daemon task to render a per-machine systemd-nspawn drop-in with After= and (optionally) Requires= dependencies, and reload systemd.
  • Introduce bootstrap.additionalRequiredServices config with validation for safe .service unit names, plus tests.
  • Update the agent’s systemd unit to order after systemd-udev-settle.service, plus docs and lifecycle assertions.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/daemon/systemd_dependencies.go New task that writes the nspawn dependency drop-in and reloads systemd.
pkg/daemon/systemd_dependencies_test.go Tests drop-in rendering behavior and repeated application.
pkg/daemon/start.go Wires the new dependency task into the node start sequence.
pkg/daemon/lifecycle_test.go Asserts the agent unit orders after systemd-udev-settle.service.
pkg/daemon/assets/aks-flex-node-agent.service Updates agent unit ordering to include systemd-udev-settle.service.
pkg/config/config.go Adds bootstrap.additionalRequiredServices and validates unit-name format.
pkg/config/config_test.go Adds coverage for config load + validation of required services.
docs/usages/configuration.md Documents the new configuration field and its purpose.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/daemon/assets/aks-flex-node-agent.service Outdated
Comment thread pkg/daemon/systemd_dependencies.go
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 19, 2026 16:48
Pull systemd-udev-settle into the transaction for both the Flex agent and nspawn unit so their After ordering is effective.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@bcho
hbc (bcho) merged commit 8cc0561 into main Aug 19, 2026
12 of 13 checks passed
@bcho
hbc (bcho) deleted the phealy/systemd branch August 19, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants