Skip to content

agent: implement initial preflight check command - #335

Merged
hbc (bcho) merged 19 commits into
mainfrom
agent-preflight-implementation
Jun 25, 2026
Merged

agent: implement initial preflight check command#335
hbc (bcho) merged 19 commits into
mainfrom
agent-preflight-implementation

Conversation

@bcho

@bcho hbc (bcho) commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

  • Add reusable agent preflight report/runner framework.
  • Add unbounded-agent preflight with text/JSON output, ignore handling, and fail-on-warnings support.
  • Run preflight during agent Kind e2e bootstrap and collect text/JSON reports as artifacts.

Implemented checkers

  • is-privileged-user
  • agent-config
  • cluster-credentials
  • host-packages
  • host-os-configuration
  • nspawn-runtime
  • docker-active
  • swap-active
  • disk-space
  • cgroups
  • api-server-reachable
  • goal-state
  • nspawn-machine-provisioning

Follow-up checkers

Download, registry, GPU, and offline policy checks are intentionally left for follow-up PRs:

  • real oci-image-reachable manifest resolution without pulling layers
  • kubernetes-artifacts
  • cri-artifacts
  • cni-artifacts
  • gpu-config
  • nvidia-devices
  • nvidia-driver-libraries
  • nvidia-runtime
  • offline-no-upstream-urls
  • allowed-hosts
  • mirror-reachability

References

Verification

  • python3 -m py_compile hack/agent/e2e-kind/e2e.py
  • nix-shell -p golangci-lint openssl pkg-config --run 'make test'
  • Agent e2e and agent config e2e pass in CI with preflight enabled

@bcho

This comment was marked as outdated.

@bcho

This comment was marked as outdated.

@bcho hbc (bcho) changed the title agent: implement preflight check command agent: implement initial preflight check command Jun 24, 2026
Base automatically changed from agent-preflight-check-design to main June 25, 2026 19:21
@bcho
hbc (bcho) marked this pull request as ready for review June 25, 2026 21:48
@bcho
hbc (bcho) requested a review from a team June 25, 2026 21:48
@bcho

Copy link
Copy Markdown
Member Author

Latest preflight output from unbounded agent e2e run 28202024509 on head 531ffb9:
https://github.com/Azure/unbounded/actions/runs/28202024509

ubuntu2404 -> ubuntu2404 initial join

[preflight] Running unbounded-agent pre-flight checks
[OK is-privileged-user]: preflight is running as root (target: host user)
[WARNING host-packages]: required host packages are missing and may be installed by bootstrap: systemd-container, debootstrap, nftables (target: host packages)
[OK host-os-configuration]: host OS configuration can be applied (target: host OS configuration)
[WARNING nspawn-runtime]: nspawn runtime tool is missing and may be installed by bootstrap: machinectl (target: nspawn runtime)
[WARNING nspawn-runtime]: nspawn runtime tool is missing and may be installed by bootstrap: systemd-nspawn (target: nspawn runtime)
[OK docker-active]: Docker is not active (target: docker service)
[OK swap-active]: swap is not active (target: host swap)
[OK disk-space]: sufficient disk space is available (target: host disk)
[OK cgroups]: cgroup filesystem is available (target: host cgroups)
[OK api-server-reachable]: API server is reachable (target: cluster API server)
[OK goal-state]: goal state resolved (target: goal state)
[OK nspawn-machine-provisioning]: nspawn machine provisioning paths are ready (target: nspawn machine provisioning)

ubuntu2404 -> ubuntu2404 rejoin

[preflight] Running unbounded-agent pre-flight checks
[OK is-privileged-user]: preflight is running as root (target: host user)
[OK host-packages]: required host packages are installed (target: host packages)
[OK host-os-configuration]: host OS configuration can be applied (target: host OS configuration)
[OK nspawn-runtime]: nspawn runtime is available (target: nspawn runtime)
[OK docker-active]: Docker is not active (target: docker service)
[OK swap-active]: swap is not active (target: host swap)
[OK disk-space]: sufficient disk space is available (target: host disk)
[OK cgroups]: cgroup filesystem is available (target: host cgroups)
[OK api-server-reachable]: API server is reachable (target: cluster API server)
[OK goal-state]: goal state resolved (target: goal state)
[OK nspawn-machine-provisioning]: nspawn machine provisioning paths are ready (target: nspawn machine provisioning)

fedora -> azlinux3 initial join

[preflight] Running unbounded-agent pre-flight checks
[OK is-privileged-user]: preflight is running as root (target: host user)
[WARNING host-packages]: required host packages are missing and may be installed by bootstrap: systemd-container (target: host packages)
[OK host-os-configuration]: host OS configuration can be applied (target: host OS configuration)
[WARNING nspawn-runtime]: nspawn runtime tool is missing and may be installed by bootstrap: machinectl (target: nspawn runtime)
[WARNING nspawn-runtime]: nspawn runtime tool is missing and may be installed by bootstrap: systemd-nspawn (target: nspawn runtime)
[OK docker-active]: Docker is not active (target: docker service)
[WARNING swap-active]: swap is enabled and bootstrap will disable it (target: host swap)
[OK disk-space]: sufficient disk space is available (target: host disk)
[OK cgroups]: cgroup filesystem is available (target: host cgroups)
[OK api-server-reachable]: API server is reachable (target: cluster API server)
[OK goal-state]: goal state resolved (target: goal state)
[OK nspawn-machine-provisioning]: nspawn machine provisioning paths are ready (target: nspawn machine provisioning)

fedora -> azlinux3 rejoin

[preflight] Running unbounded-agent pre-flight checks
[OK is-privileged-user]: preflight is running as root (target: host user)
[OK host-packages]: required host packages are installed (target: host packages)
[OK host-os-configuration]: host OS configuration can be applied (target: host OS configuration)
[OK nspawn-runtime]: nspawn runtime is available (target: nspawn runtime)
[OK docker-active]: Docker is not active (target: docker service)
[OK swap-active]: swap is not active (target: host swap)
[OK disk-space]: sufficient disk space is available (target: host disk)
[OK cgroups]: cgroup filesystem is available (target: host cgroups)
[OK api-server-reachable]: API server is reachable (target: cluster API server)
[OK goal-state]: goal state resolved (target: goal state)
[OK nspawn-machine-provisioning]: nspawn machine provisioning paths are ready (target: nspawn machine provisioning)

ubuntu2604 -> ubuntu2604 initial join

[preflight] Running unbounded-agent pre-flight checks
[OK is-privileged-user]: preflight is running as root (target: host user)
[WARNING host-packages]: required host packages are missing and may be installed by bootstrap: systemd-container, debootstrap, nftables (target: host packages)
[OK host-os-configuration]: host OS configuration can be applied (target: host OS configuration)
[WARNING nspawn-runtime]: nspawn runtime tool is missing and may be installed by bootstrap: machinectl (target: nspawn runtime)
[WARNING nspawn-runtime]: nspawn runtime tool is missing and may be installed by bootstrap: systemd-nspawn (target: nspawn runtime)
[OK docker-active]: Docker is not active (target: docker service)
[OK swap-active]: swap is not active (target: host swap)
[OK disk-space]: sufficient disk space is available (target: host disk)
[OK cgroups]: cgroup filesystem is available (target: host cgroups)
[OK api-server-reachable]: API server is reachable (target: cluster API server)
[OK goal-state]: goal state resolved (target: goal state)
[OK nspawn-machine-provisioning]: nspawn machine provisioning paths are ready (target: nspawn machine provisioning)

ubuntu2604 -> ubuntu2604 rejoin

[preflight] Running unbounded-agent pre-flight checks
[OK is-privileged-user]: preflight is running as root (target: host user)
[OK host-packages]: required host packages are installed (target: host packages)
[OK host-os-configuration]: host OS configuration can be applied (target: host OS configuration)
[OK nspawn-runtime]: nspawn runtime is available (target: nspawn runtime)
[OK docker-active]: Docker is not active (target: docker service)
[OK swap-active]: swap is not active (target: host swap)
[OK disk-space]: sufficient disk space is available (target: host disk)
[OK cgroups]: cgroup filesystem is available (target: host cgroups)
[OK api-server-reachable]: API server is reachable (target: cluster API server)
[OK goal-state]: goal state resolved (target: goal state)
[OK nspawn-machine-provisioning]: nspawn machine provisioning paths are ready (target: nspawn machine provisioning)

@bcho
hbc (bcho) enabled auto-merge (squash) June 25, 2026 21:51
@bcho
hbc (bcho) merged commit e5a4454 into main Jun 25, 2026
26 checks passed
@bcho
hbc (bcho) deleted the agent-preflight-implementation branch June 25, 2026 22:11

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 introduces an initial “preflight” capability to the agent, providing a reusable framework for running non-mutating host/config checks and exposing them via unbounded-agent preflight, with e2e-kind collecting the resulting reports as artifacts.

Changes:

  • Add pkg/agent/preflight runner/reporting framework (severity, ignore handling, fail-on-warnings).
  • Add phase-owned preflight checkers (host, nodestart, rootfs) plus an unbounded-agent preflight command with text/JSON output.
  • Update agent Kind e2e bootstrap to run preflight and collect text/JSON reports from the VM.
Show a summary per file
File Description
pkg/agent/preflight/preflight.go Core preflight runner/report model and helper constructors.
pkg/agent/preflight/preflight_test.go Unit tests for report aggregation, ignore handling, formatting, and concurrency/order.
pkg/agent/phases/rootfs/preflight_local.go Rootfs-local checker for nspawn provisioning paths and machine dir sanity.
pkg/agent/phases/rootfs/preflight_local_test.go Tests for nspawn provisioning path validation behavior.
pkg/agent/phases/rootfs/preflight_goal_state.go Rootfs goal-state validation checker(s) used by preflight.
pkg/agent/phases/rootfs/preflight_goal_state_test.go Tests for rootfs goal-state validation behavior.
pkg/agent/phases/nodestart/preflight_api_server.go Checker validating API server endpoint/credentials and reachability (with redaction).
pkg/agent/phases/nodestart/preflight_api_server_test.go Tests for API server reachability checker behaviors and redaction.
pkg/agent/phases/host/preflight_host.go Host environment check suite (packages, OS config, nspawn runtime, swap, disk, cgroups, etc.).
pkg/agent/phases/host/preflight_host_test.go Tests for host preflight check behaviors via dependency injection.
pkg/agent/internal/utilio/fs.go Add ProbeWritableDir helper used by several checkers.
pkg/agent/internal/utilio/fs_test.go Test ensuring ProbeWritableDir leaves no durable state behind.
pkg/agent/config/config.go Add AgentConfig.Validate() for basic required-field and API server URL validation.
pkg/agent/config/config_test.go Tests for AgentConfig.Validate() expectations.
hack/agent/e2e-kind/e2e.py Run unbounded-agent preflight during bootstrap and collect reports as artifacts.
cmd/agent/internal/cmd/preflight.go Implement unbounded-agent preflight command (text/JSON output, ignore, fail-on-warnings).
cmd/agent/internal/cmd/preflight_test.go Command-level tests for JSON and text output behaviors (including redaction).
cmd/agent/internal/cmd/cmd.go Wire the new preflight subcommand into the agent CLI.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 18/18 changed files
  • Comments generated: 2

Comment on lines +86 to +92
var wg sync.WaitGroup

for i, check := range checks {
wg.Go(func() {
checkResults[i] = check.Check(ctx)
})
}
Comment on lines +15 to +18
const (
checkGoalStateName = "goal-state"
checkOCIImageReachableName = "oci-image-reachable"
)
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