daemon

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 32 Imported by: 0

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:

  1. Provisioning a new nspawn machine (the alternate of the current one)
  2. Stopping the old machine
  3. Starting the new machine and verifying kubelet is running
  4. Removing the old machine
  5. Persisting the new applied config

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnableDaemon added in v0.1.1

func EnableDaemon(log *slog.Logger) phases.Task

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

func RemoveAgentArtifacts(log *slog.Logger) phases.Task

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

func RemoveAppliedConfig(log *slog.Logger, machineName string) phases.Task

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

func Run(ctx context.Context, log *slog.Logger) error

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

func StopDaemon(log *slog.Logger) phases.Task

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:

  1. Provision a new rootfs on the alternate machine
  2. Stop the old machine (graceful service shutdown + nspawn teardown)
  3. Start the new machine (configure, boot nspawn, start services, persist config)
  4. Verify kubelet health
  5. 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL