Documentation
¶
Overview ¶
Package daemon implements nspawn machine updates for the unbounded-agent. When a desired AgentConfig differs from the currently applied config, this package orchestrates:
- Provisioning a new nspawn machine (the alternate of the current one)
- Stopping the old machine
- Starting the new machine and verifying kubelet is running
- Removing the old machine
- Persisting the new applied config
Index ¶
- func EnableDaemon(log *slog.Logger) phases.Task
- func PersistAppliedConfig(log *slog.Logger, machineName string, cfg *config.AgentConfig) phases.Task
- func RemoveAgentArtifacts(log *slog.Logger) phases.Task
- func RemoveAppliedConfig(log *slog.Logger, machineName string) phases.Task
- func Run(ctx context.Context, log *slog.Logger) error
- func StopDaemon(log *slog.Logger) phases.Task
- func UpdateNode(ctx context.Context, log *slog.Logger, active *ActiveMachine, ...) error
- type ActiveMachine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnableDaemon ¶ added in v0.1.1
EnableDaemon returns a task that installs, enables, and starts the unbounded-agent-daemon systemd unit on the host. The unit runs "unbounded-agent daemon" which watches the Machine CR for this node and reconciles the local state to match.
func PersistAppliedConfig ¶ added in v0.1.1
func PersistAppliedConfig(log *slog.Logger, machineName string, cfg *config.AgentConfig) phases.Task
PersistAppliedConfig returns a task that writes the agent config to the applied config file for the nspawn machine. The daemon reads this file on startup to detect configuration drift.
func RemoveAgentArtifacts ¶ added in v0.1.1
RemoveAgentArtifacts returns a task that removes the agent binary, install script, legacy uninstall script, config directory, and temp files.
func RemoveAppliedConfig ¶ added in v0.1.1
RemoveAppliedConfig returns a task that removes the applied agent config file and its checksum sidecar for the named machine. Errors are logged but do not fail the task.
func Run ¶
Run is the main daemon entry point. It discovers the active nspawn machine, builds a Kubernetes client, registers the Machine CR if needed, and blocks until the context is cancelled.
TODO: Add a trigger mechanism (e.g. file watch, signal, API) to invoke updateNode when the desired config changes.
func StopDaemon ¶ added in v0.1.1
StopDaemon returns a task that stops, disables, and removes the unbounded-agent-daemon systemd unit. Errors from stop and disable are logged but do not fail the task since the unit may not be present.
func UpdateNode ¶
func UpdateNode(ctx context.Context, log *slog.Logger, active *ActiveMachine, newCfg *provision.UnboundedAgentConfig) error
UpdateNode performs the nspawn machine update:
- Provision a new rootfs on the alternate machine
- Stop the old machine (graceful service shutdown + nspawn teardown)
- Start the new machine (configure, boot nspawn, start services, persist config)
- Verify kubelet health
- Remove the old machine and its applied config
Types ¶
type ActiveMachine ¶
type ActiveMachine struct {
Name string
Config *provision.AgentConfig
}
ActiveMachine holds the currently active nspawn machine name and its applied agent configuration.