Documentation
¶
Index ¶
- Constants
- func ActivateHostAgent(ctx context.Context, log *slog.Logger, candidatePath string) (agentbinary.ActivationResult, error)
- func ConfigureNSpawnDependencies(log *slog.Logger, rootFS *goalstates.RootFS, requiredServices []string) phases.Task
- func EnsureNSpawnLifecycleUnits(log *slog.Logger) phases.Task
- func HostRootMarkers() []string
- func InstallBinary(machineDir string) phases.Task
- func InstallHostBinary(ctx context.Context, log *slog.Logger) error
- func InstallService(cfg *config.Config, log *slog.Logger) phases.Task
- func MigrateHostRoot(log *slog.Logger) error
- func NewFileStateStore() (stateStore, error)
- func PlannedHostRoot() string
- func PreflightHostAgentActivation(ctx context.Context, log *slog.Logger, candidatePath string) (agentbinary.ActivationPlan, error)
- func PrepareHostRoot(ctx context.Context, log *slog.Logger) error
- func RecoverAgentUpgrade(ctx context.Context, message string) error
- func RemoveLegacySeed(log *slog.Logger) error
- func ResetNode(log *slog.Logger) phases.Task
- func Run(ctx context.Context, cfg *config.Config, log *slog.Logger) error
- func SetupHost(cfg *config.Config, log *slog.Logger) phases.Task
- func StartNode(cfg *config.Config, log *slog.Logger, machineName string, ...) phases.Task
- func UninstallService(log *slog.Logger) phases.Task
- type State
Constants ¶
const ( ServiceUnitName = "aks-flex-node-agent.service" // ServiceUnitPath is where the agent unit is installed. The first-boot unit // only runs while it is absent. ServiceUnitPath = systemdSystemDir + "/" + ServiceUnitName // FirstBootUnitName is the oneshot unit that runs bootstrap.sh on first // boot on a host provisioned by Ignition, as scripts/aks-flex-node-bootstrap.bu // documents. Reset removes it; a host without it is left alone. FirstBootUnitName = "aks-flex-node-bootstrap.service" )
const ( DeletionTaintKey = "kubernetes.azure.com/flex-node-deleting" DeletionTaintValue = "true" DeletionTaintEffect = corev1.TaintEffectNoSchedule )
const DefaultMachineReconcileInterval = 10 * time.Minute
Variables ¶
This section is empty.
Functions ¶
func ActivateHostAgent ¶ added in v0.1.7
func ActivateHostAgent(ctx context.Context, log *slog.Logger, candidatePath string) (agentbinary.ActivationResult, error)
ActivateHostAgent activates a directly staged Flex agent binary. It uses the same lock and binary layout as MachineOperation upgrades.
func ConfigureNSpawnDependencies ¶ added in v0.1.9
func ConfigureNSpawnDependencies(log *slog.Logger, rootFS *goalstates.RootFS, requiredServices []string) phases.Task
ConfigureNSpawnDependencies orders the machine after host services that must finish changing host devices before nspawn starts.
func EnsureNSpawnLifecycleUnits ¶ added in v0.3.0
EnsureNSpawnLifecycleUnits returns a task that writes the nspawn lifecycle units the machines' hooks start, those that are missing, so that StartNode can start a machine: start installs the agent's other units only once the node runs. The daemon converges them with those units, while an AgentUpgrade isn't pending, so this leaves the existing ones as they are. It links the lifecycle helper too, for hooks an earlier release's pre-start writes, as after a reset that kept that release's binaries; see ensureNSpawnLifecycleHelperLink.
func HostRootMarkers ¶ added in v0.3.0
func HostRootMarkers() []string
HostRootMarkers returns the files, relative to the host root, whose presence under the legacy root identifies an installation by a release before the host root. They are the blue/green binary layout only. The plain binary is left out: install scripts put it in /usr/local/bin on fresh hosts too, so on its own it is not an installation. Neither are the files the agent library installs, such as the nspawn lifecycle helper, which an older reset can leave behind.
func InstallBinary ¶
InstallBinary returns a task that copies the current process binary into the nspawn rootfs at /usr/local/bin/aks-flex-node.
func InstallHostBinary ¶ added in v0.3.0
InstallHostBinary puts the binary under the host root, <host root>/bin/aks-flex-node, which the agent's blue/green layout is seeded from:
- While the agent's unit is installed, as for the daemon, the binary changes only through an activation, so it is copied only when no usable binary is there, as on a host an earlier release installed directly in /usr/local/bin.
- Otherwise, as for start before it installs the agent, it is the running binary. One there that isn't, such as the one a reset left, is replaced with a copy of it, and a layout that doesn't run it, such as one a reset by an earlier release kept, is removed, so the layout start seeds runs the binary doing the start.
It fails, and leaves no copy, when the copy cannot run.
func InstallService ¶
InstallService returns a task that installs, enables, and starts the systemd unit.
func MigrateHostRoot ¶ added in v0.3.0
MigrateHostRoot links the host root to the legacy root on a host installed by a release before the host root. Commands that change the host call it before they resolve any path.
func NewFileStateStore ¶
func NewFileStateStore() (stateStore, error)
func PlannedHostRoot ¶ added in v0.3.0
func PlannedHostRoot() string
PlannedHostRoot returns the host root this host will resolve once migrated, without migrating it. It is for code that must not change the host.
func PreflightHostAgentActivation ¶ added in v0.1.7
func PreflightHostAgentActivation(ctx context.Context, log *slog.Logger, candidatePath string) (agentbinary.ActivationPlan, error)
PreflightHostAgentActivation validates a directly staged Flex agent binary and returns the shared activation plan without changing host state.
It does not migrate the host root, so it plans against the root the host will resolve once migrated.
func PrepareHostRoot ¶ added in v0.3.0
PrepareHostRoot creates the directories under the host root that the node installs into.
func RecoverAgentUpgrade ¶ added in v0.1.7
RecoverAgentUpgrade records failure and restores both host and active nspawn binaries. It is invoked by the systemd recovery unit through last-good.
It recovers whatever the host root, since recovery is what brings a failed upgrade back. A host root that cannot be migrated is logged and left as it is, and the layout is the one this binary runs from: the recovery script runs the resolved last-good link, so that is the layout systemd uses.
func RemoveLegacySeed ¶ added in v0.3.0
RemoveLegacySeed removes the binary install scripts left in /usr/local/bin once nothing the agent runs is under /usr/local: the host is installed under a real host root, or one an operator linked somewhere else. Only a regular file is removed: a link there is an earlier release's compatibility link, or an operator's.
Not partway through a move from /usr/local: until the move has restarted the daemon from the host root, the daemon may still be running from the files under /usr/local, and the move removes none of them until then.
It is for start, which runs from that binary on a host whose /usr/local/bin is writable, and removes it as its last step, once it has copied itself everywhere it is needed and is about to exit. The daemon keeps it while it runs from it; see removeDaemonLegacySeed.
func ResetNode ¶
ResetNode returns the task that removes the node runtime from the host.
Helpers the agent library installs under the host root, the nspawn lifecycle helper and the LocalDNS network helper, are removed under the resolved host root and under the legacy root, so reset does not depend on the host root having been migrated. The managed agent binaries are intentionally kept.
func StartNode ¶
func StartNode( cfg *config.Config, log *slog.Logger, machineName string, gs *goalstates.MachineGoalState, containerImageArchives *goalstates.ContainerImageArchiveStaging, store stateStore, state *State, ) phases.Task
func UninstallService ¶
UninstallService returns a task that removes the first-boot unit, then disables, removes, and stops the agent's systemd unit, leaving the agent's binary under the host root as a regular file, without its blue/green layout.
The paths are resolved when the task is built. Nothing in reset changes the host root, and ResetNode resolves the helper paths it removes the same way.
Types ¶
type State ¶
type State struct {
AppliedSettingsVersion string `json:"appliedSettingsVersion,omitempty"`
AppliedKubernetesVersion string `json:"appliedKubernetesVersion,omitempty"`
PreviousSettingsVersion string `json:"previousSettingsVersion,omitempty"`
PreviousKubernetesVersion string `json:"previousKubernetesVersion,omitempty"`
ActiveMachine string `json:"activeMachine,omitempty"`
}
State records the last safely applied AKS machine goal and the previous known-good goal needed for rollback-oriented reconciliation.
func SeededState ¶
func SeededState(goal aksmachine.GoalState) *State