You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The exported library mechanics can be reused, but the standalone daemon orchestration is under cmd/agent/internal and is not directly importable by AKS Flex Node.
Motivation
Today, selecting an agent version is supported during initial bootstrap.sh, but updating an existing node requires manual binary replacement or a broader node lifecycle operation. Manual replacement has no managed status, automatic rollback, or synchronization with the copy of aks-flex-node inside the active nspawn worker.
A first-class upgrade operation is needed to:
roll out agent fixes independently of Kubernetes repaves;
report operation progress and failure through MachineOperation;
roll back automatically if the new daemon does not start;
avoid leaving nodes with partially switched binaries;
define how the nspawn copy used for kubelet exec credentials is updated.
Proposed behavior
Handle OperationAgentUpgrade in the Flex daemon:
Validate operation parameters, including an exact HTTPS archive URL and expected SHA-256.
Download the architecture-specific AKS Flex Node archive without logging sensitive URL query strings.
Install the candidate into the inactive blue/green slot.
Verify the candidate with aks-flex-node version.
Atomically update last-good and current links.
Persist a pending upgrade signal.
Restart aks-flex-node-agent.service.
Have the new daemon mark the MachineOperation complete and clear the signal.
If the new daemon repeatedly fails, restore last-good, restart the service, and report the operation as failed.
The implementation should migrate existing direct-file installations at /usr/local/bin/aks-flex-node into the blue/green layout idempotently.
Upstream reuse/generalization
Consider contributing reusable APIs to Unbounded rather than copying its orchestration:
generalize InstallAndSwitchFromTarGz to accept the expected archive member name instead of hardcoding unbounded-agent;
export upgrade signal/recovery primitives that are independent of the standalone Unbounded daemon;
allow callers to provide binary paths and the systemd service name.
AKS Flex Node also copies its binary into the nspawn rootfs, where kubelet may invoke it for MSI/service-principal exec credentials. The design must explicitly choose and test one of:
atomically update the active nspawn copy as part of AgentUpgrade and roll it back with the host binary;
expose a read-only host-managed current binary through an nspawn bind mount;
document and enforce that the nspawn copy updates only on repave, including compatibility guarantees.
Upgrading only the outer daemon without defining this behavior can leave host and nspawn versions skewed.
Security requirements
HTTPS-only download URLs.
SHA-256 verification before switching.
URL redaction because URLs may contain SAS tokens.
Safe archive path and expected-member validation.
Bounded download/extraction size.
Root-owned executable installation with atomic file/link updates.
Preserve a verified last-good binary until a later upgrade succeeds.
Never return or log credentials/tokens.
Acceptance criteria
AgentUpgrade is no longer mapped to unsupportedOperation.
Existing installations migrate idempotently to blue/green binary slots.
A valid MachineOperation upgrades the running Flex daemon and reports success.
Invalid URL, digest, archive, architecture, and candidate binaries report failure without switching.
Failure of the new daemon automatically restores the last-good binary and reports failure.
Repeating or reconciling the same operation is safe.
Sensitive download URLs are redacted from logs and status.
The active nspawn binary synchronization policy is implemented and tested.
The Kubernetes Node remains Ready during a successful host-daemon-only upgrade, aside from any explicitly documented nspawn synchronization step.
Unit tests cover migration, blue/green switching, rollback, status transitions, and idempotency.
E2E covers successful upgrade, forced rollback, retry after rollback, kubelet exec authentication, and repave after upgrade.
Summary
Add managed, rollback-safe upgrades for the running
aks-flex-nodebinary through the MachinaAgentUpgradeMachineOperation.AKS Flex Node currently supports
NodeRebootandAgentReset, but explicitly rejectsAgentUpgrade:Unbounded already implements most of the required mechanics for its standalone agent:
currentandlast-goodsymlinks;versionverification;Relevant upstream packages and implementation:
github.com/Azure/unbounded/pkg/agent/agentbinarygithub.com/Azure/unbounded/pkg/agent/goalstates(AgentUpgradePaths)cmd/agent/internal/daemon/agentupgrade.gocmd/agent/internal/daemon/controller_machineoperation.goThe exported library mechanics can be reused, but the standalone daemon orchestration is under
cmd/agent/internaland is not directly importable by AKS Flex Node.Motivation
Today, selecting an agent version is supported during initial
bootstrap.sh, but updating an existing node requires manual binary replacement or a broader node lifecycle operation. Manual replacement has no managed status, automatic rollback, or synchronization with the copy ofaks-flex-nodeinside the active nspawn worker.A first-class upgrade operation is needed to:
MachineOperation;Proposed behavior
Handle
OperationAgentUpgradein the Flex daemon:aks-flex-node version.last-goodandcurrentlinks.aks-flex-node-agent.service.last-good, restart the service, and report the operation as failed.The implementation should migrate existing direct-file installations at
/usr/local/bin/aks-flex-nodeinto the blue/green layout idempotently.Upstream reuse/generalization
Consider contributing reusable APIs to Unbounded rather than copying its orchestration:
InstallAndSwitchFromTarGzto accept the expected archive member name instead of hardcodingunbounded-agent;AKS Flex Node release archives currently contain:
Nspawn binary synchronization
AKS Flex Node also copies its binary into the nspawn rootfs, where kubelet may invoke it for MSI/service-principal exec credentials. The design must explicitly choose and test one of:
Upgrading only the outer daemon without defining this behavior can leave host and nspawn versions skewed.
Security requirements
Acceptance criteria
AgentUpgradeis no longer mapped tounsupportedOperation.