Skip to content

Move agent bootstrap lifecycle into binary#157

Merged
bcho merged 10 commits into
mainfrom
hbc/daemon
Apr 30, 2026
Merged

Move agent bootstrap lifecycle into binary#157
bcho merged 10 commits into
mainfrom
hbc/daemon

Conversation

@bcho
Copy link
Copy Markdown
Member

@bcho bcho commented Apr 29, 2026

Summary

  • Add a bootstrap command that installs the embedded systemd unit, bootstraps the nspawn node, then enables and starts the agent service.
  • Change agent to only run the long-lived daemon loop used by systemd, and move unit install/uninstall behavior into Go.
  • Update install/uninstall scripts and docs for the new bootstrap/daemon split.

Validation

  • go test ./...
  • make lint

Comment thread pkg/daemon/lifecycle.go Fixed
Comment thread pkg/utils/utilexec/exec.go Fixed
Comment thread pkg/utils/utilexec/exec.go Fixed
@bcho bcho marked this pull request as ready for review April 29, 2026 21:52
Copilot AI review requested due to automatic review settings April 29, 2026 21:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 moves the host bootstrap/unbootstrap lifecycle (systemd unit install/removal + Azure CLI auth staging) into the aks-flex-node binary via a new bootstrap command, leaving agent as the long-lived systemd-launched daemon. It also updates install/uninstall scripts, e2e harnesses, and docs to follow the new bootstrap/daemon split.

Changes:

  • Add bootstrap command and pkg/daemon lifecycle helpers to install/start/uninstall the embedded systemd unit and stage Azure CLI auth into a root-owned directory.
  • Refactor command execution utilities (removing pkg/utils/utils.go, adding/expanding pkg/utils/utilexec and utilio.FileExists) and update Arc/drift call sites.
  • Update install/uninstall scripts, e2e join/unjoin flows, and docs to use bootstrap for initial setup and systemd-managed operation.

Reviewed changes

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

Show a summary per file
File Description
scripts/uninstall.sh Adjust uninstall flow to rely on unbootstrap for systemd removal; add SKIP_AZCLI support.
scripts/install.sh Add local binary/version overrides and SKIP_AZCLI; remove systemd/unit installation from the script.
pkg/utils/utils.go Remove legacy utility helpers (systemd + exec wrappers, FileExists, cleanup helpers).
pkg/utils/utilio/fs.go Add utilio.FileExists helper used by drift codepaths.
pkg/utils/utilexec/exec.go Expand exec helpers with slog streaming, systemctl helpers, and safe remove helpers.
pkg/drift/node_maintenance.go Switch kubeconfig existence check to utilio.FileExists.
pkg/daemon/lifecycle.go New: install/start/uninstall embedded systemd unit and copy Azure CLI auth files.
pkg/daemon/assets/aks-flex-node-agent.service New embedded unit file used by bootstrap.
pkg/arc/helpers.go Migrate Arc service checks to utilexec + slog logging.
pkg/arc/arc_uninstaller.go Migrate cleanup execution/systemctl interactions to utilexec.
pkg/arc/arc_installer.go Migrate dpkg/bash/curl/wget/azcmagent execution to utilexec.
main.go Add bootstrap command registration; suppress exit on context.Canceled.
hack/qemu/README.md Update VM instructions to run bootstrap instead of agent.
hack/e2e/lib/node-join.sh Update E2E join to install via script and bootstrap via transient unit; add service validation.
hack/e2e/lib/node-join-token.sh Update E2E unjoin to run uninstall script and validate removal.
hack/e2e/lib/node-join-msi.sh Update E2E unjoin to run uninstall script and validate removal.
hack/e2e/lib/node-join-kubeadm.sh Update E2E unjoin to run uninstall script and validate removal.
hack/e2e/README.md Update join-method documentation to reference bootstrap.
docs/usage.md Update usage guide to reflect bootstrap (systemd-managed) vs agent (daemon).
commands.go Add bootstrap cobra command; make agent daemon-only; uninstall systemd unit during unbootstrap.
README.md Update quickstart to use bootstrap.

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

Comment thread scripts/uninstall.sh Outdated
Comment thread pkg/utils/utilexec/exec.go
Copilot AI review requested due to automatic review settings April 29, 2026 23:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 20 out of 21 changed files in this pull request and generated 2 comments.


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

Comment thread commands.go
Comment thread pkg/arc/arc_uninstaller.go
@bcho bcho merged commit d6ee127 into main Apr 30, 2026
13 checks passed
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.

4 participants