Documentation
¶
Index ¶
- Constants
- Variables
- func EnableDaemon(log *slog.Logger) phases.Task
- func InstallBootstrapBinary() error
- func PersistAppliedConfig(log *slog.Logger, machineName string, cfg *config.AgentConfig) phases.Task
- func RecordAgentUpgradeFailureSignal(message string) error
- func RemoveAgentArtifacts(log *slog.Logger) phases.Task
- func RemoveAppliedConfig(log *slog.Logger, machineName string) phases.Task
- func RemoveDaemonUnit(log *slog.Logger) phases.Task
- func RepairDaemon(ctx context.Context, log *slog.Logger) error
- func ResetAgent(log *slog.Logger) phases.Task
- func Run(ctx context.Context, log *slog.Logger) error
- func StopDaemon(log *slog.Logger) phases.Task
- func VerifyDaemonInstalled(ctx context.Context, log *slog.Logger) error
- type ActiveMachine
- type BootstrapStatusReporter
- type HostDaemonActivationService
- func (s *HostDaemonActivationService) Preflight(_ context.Context, currentBinaryPath string) (agentbinary.ServicePlan, error)
- func (s *HostDaemonActivationService) Prepare(_ context.Context, currentBinaryPath string) error
- func (s *HostDaemonActivationService) Reload(ctx context.Context) error
- func (s *HostDaemonActivationService) Restart(ctx context.Context) error
- func (s *HostDaemonActivationService) WaitHealthy(ctx context.Context, expectedBinaryPath string) error
Constants ¶
const ( // DeferredExitCode is returned when the daemon has no work because an // installation owns the host. It is not a failure, and the daemon unit // names it in both SuccessExitStatus and RestartPreventExitStatus so // systemd leaves the unit inactive instead of restarting it, exhausting the // start limit, and running OnFailure recovery. Those two directives and this // constant have to agree; TestDaemonUnitDeclaresDeferredExitCode pins that. // // 69 is EX_UNAVAILABLE: the service is correct but cannot run yet. DeferredExitCode = 69 )
Variables ¶
var ErrDeferred = errors.New("daemon deferred until installation completes")
ErrDeferred reports that the daemon cannot run because an installation owns the host, and that this is expected rather than a fault. The command layer turns it into DeferredExitCode without printing an error.
Run wraps it with context, so callers must test with errors.Is.
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 InstallBootstrapBinary ¶ added in v0.9.0
func InstallBootstrapBinary() error
InstallBootstrapBinary installs the staged bootstrap executable unless the host already has a usable daemon binary. The caller holds installation ownership; existing binary layouts are retained and upgrades use their normal activation path.
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 RecordAgentUpgradeFailureSignal ¶ added in v0.1.4
RecordAgentUpgradeFailureSignal records that the daemon failed after an AgentUpgrade.
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 RemoveDaemonUnit ¶ added in v0.1.4
RemoveDaemonUnit returns a task that disables and removes the unbounded-agent-daemon systemd unit without stopping the running service.
func RepairDaemon ¶ added in v0.9.0
RepairDaemon requires the caller's installation lock. It uses current applied configuration, never the original bootstrap input that may name a retired slot.
func ResetAgent ¶ added in v0.9.0
ResetAgent removes the unbounded-agent and all associated resources, stopping the daemon first. The daemon's own operation path stops it last instead, so that ordering stays with the caller.
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 canceled.
func StopDaemon ¶ added in v0.1.1
StopDaemon returns a task that stops, disables, and removes the unbounded-agent-daemon systemd unit. Only an absent unit permits a failed stop; substantive service errors must retain reset ownership.
func VerifyDaemonInstalled ¶ added in v0.9.0
VerifyDaemonInstalled checks installed daemon assets and service state. An active daemon already proves it resolved an applied config at startup, so the applied-config check belongs to RepairDaemon rather than here.
Types ¶
type ActiveMachine ¶
type ActiveMachine struct {
Name string
Config *provision.AgentConfig
}
ActiveMachine holds the currently active nspawn machine name and its applied agent configuration.
type BootstrapStatusReporter ¶ added in v0.1.20
type BootstrapStatusReporter struct {
// contains filtered or unexported fields
}
BootstrapStatusReporter publishes the agent's initial bootstrap progress to the Machine status. It is best-effort so bootstrap can continue when the cluster is temporarily unavailable or RBAC has not been updated yet.
func NewBootstrapStatusReporter ¶ added in v0.1.20
func NewBootstrapStatusReporter(ctx context.Context, log *slog.Logger, cfg *provision.AgentConfig) *BootstrapStatusReporter
NewBootstrapStatusReporter builds a best-effort Machine status reporter from bootstrap credentials in cfg. When credentials are incomplete, the returned reporter logs and skips updates.
func (*BootstrapStatusReporter) Failed ¶ added in v0.1.20
func (r *BootstrapStatusReporter) Failed(ctx context.Context, reason string, err error)
Failed reports that initial bootstrap failed.
func (*BootstrapStatusReporter) Running ¶ added in v0.1.20
func (r *BootstrapStatusReporter) Running(ctx context.Context)
Running reports that initial bootstrap is in progress.
func (*BootstrapStatusReporter) Succeeded ¶ added in v0.1.20
func (r *BootstrapStatusReporter) Succeeded(ctx context.Context)
Succeeded reports that initial bootstrap completed successfully.
type HostDaemonActivationService ¶ added in v0.2.3
type HostDaemonActivationService struct {
// contains filtered or unexported fields
}
HostDaemonActivationService manages the Unbounded systemd units used by a host-driven agent binary activation.
func NewHostDaemonActivationService ¶ added in v0.2.3
func NewHostDaemonActivationService(log *slog.Logger, paths goalstates.AgentUpgradePaths) *HostDaemonActivationService
NewHostDaemonActivationService returns the Unbounded systemd adapter for host-driven agent activation.
func (*HostDaemonActivationService) Preflight ¶ added in v0.2.3
func (s *HostDaemonActivationService) Preflight(_ context.Context, currentBinaryPath string) (agentbinary.ServicePlan, error)
Preflight reports whether the installed daemon assets differ from the desired assets. It does not change the host.
func (*HostDaemonActivationService) Prepare ¶ added in v0.2.3
func (s *HostDaemonActivationService) Prepare(_ context.Context, currentBinaryPath string) error
Prepare installs the daemon service, recovery service, and recovery script. It does not reload systemd or restart the daemon.
func (*HostDaemonActivationService) Reload ¶ added in v0.2.3
func (s *HostDaemonActivationService) Reload(ctx context.Context) error
Reload reloads systemd configuration.
func (*HostDaemonActivationService) Restart ¶ added in v0.2.3
func (s *HostDaemonActivationService) Restart(ctx context.Context) error
Restart restarts the Unbounded daemon synchronously.
func (*HostDaemonActivationService) WaitHealthy ¶ added in v0.2.3
func (s *HostDaemonActivationService) WaitHealthy(ctx context.Context, expectedBinaryPath string) error
WaitHealthy waits until systemd reports a stable daemon process executing the expected binary target.