Documentation
¶
Overview ¶
Package agentruntime executes worker operations without owning daemon state.
Index ¶
- func CheckMachinesTarget(log *slog.Logger, failForMissing bool) preflight.Checker
- func PreflightGoalState(log *slog.Logger, mode isolation.Mode, cfg *agentconfig.AgentConfig, ...) (*goalstates.MachineGoalState, error)
- func RewriteContainerHostRoot(ctx context.Context, log *slog.Logger, input Node) error
- func RewriteHostRoot(ctx context.Context, log *slog.Logger, cfg *agentconfig.AgentConfig, ...) (*goalstates.RootFS, error)
- func RunContainerLifecycle(ctx context.Context, log *slog.Logger, phase, slot string) error
- type Inputs
- type NSpawn
- func (NSpawn) PlanReset(log *slog.Logger) ResetPlan
- func (NSpawn) PrepareUpgrade(log *slog.Logger, input Inputs) phases.Task
- func (NSpawn) Recover(log *slog.Logger, _ Inputs) phases.Task
- func (NSpawn) Restart(log *slog.Logger, input Inputs) phases.Task
- func (NSpawn) Retire(log *slog.Logger, input Inputs) phases.Task
- func (NSpawn) Start(log *slog.Logger, input Inputs) phases.Task
- func (NSpawn) Worker(log *slog.Logger, node Node) (WorkerContext, error)
- type Node
- type ResetPlan
- type Runtime
- type WorkerContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckMachinesTarget ¶
CheckMachinesTarget checks that systemd can start nspawn workers at boot. TODO: Move this check to Unbounded's host preflight checks.
func PreflightGoalState ¶
func PreflightGoalState(log *slog.Logger, mode isolation.Mode, cfg *agentconfig.AgentConfig, gs *goalstates.MachineGoalState) (*goalstates.MachineGoalState, error)
PreflightGoalState supplies the SDK root and executor used by the selected worker.
func RewriteContainerHostRoot ¶
RewriteContainerHostRoot updates the network helper and supervisor after a host-root move.
func RewriteHostRoot ¶
func RewriteHostRoot(ctx context.Context, log *slog.Logger, cfg *agentconfig.AgentConfig, machine string) (*goalstates.RootFS, error)
RewriteHostRoot updates worker assets after a host-root move without starting the network unit.
Types ¶
type Inputs ¶
type Inputs struct {
Config *config.Config
Node Node
Previous *Node
Archives *goalstates.ContainerImageArchiveStaging
}
Inputs carry execution inputs resolved by the daemon. Previous is set for a repave.
type NSpawn ¶
type NSpawn struct{}
NSpawn executes worker actions using resolved machine configuration.
func (NSpawn) PlanReset ¶
PlanReset discovers all installed runtimes independently of applied state.
func (NSpawn) PrepareUpgrade ¶
type Node ¶
type Node struct {
Slot string
Config *agentconfig.AgentConfig
GoalState *goalstates.MachineGoalState
}
Node contains a resolved worker configuration and placement.
type ResetPlan ¶
type ResetPlan interface {
// HasHostNativeState reports whether SDK discovery selected native teardown.
HasHostNativeState() bool
// Stop stops every discovered worker before any teardown runs.
Stop() phases.Task
// Finish destroys the discovered workers, then cleans shared host resources.
Finish() phases.Task
}
ResetPlan captures runtime ownership before cleanup removes its evidence. The daemon runs Stop, cleans host components, then runs Finish.
type Runtime ¶
type Runtime interface {
// Worker resolves the selected worker's filesystem, executor, and service
// context for components without loading or updating daemon State.
Worker(*slog.Logger, Node) (WorkerContext, error)
// Start provisions the first worker or applies a replacement when Previous
// is supplied, then starts the worker and converges its NPD service.
Start(*slog.Logger, Inputs) phases.Task
// Restart restarts the installed worker in place without provisioning a
// replacement, replacing kubelet identity, or advancing applied State.
Restart(*slog.Logger, Inputs) phases.Task
// PrepareUpgrade stops/cleans nspawn or recovers none SDK state before
// replacement. OCI preparation is handled inside the SDK upgrade itself.
PrepareUpgrade(*slog.Logger, Inputs) phases.Task
// Recover reconciles the applied worker before startup or reapply using the
// SDK's recovery support. OCI only rewrites its unit; it does not provide
// durable recovery for interrupted upgrades.
Recover(*slog.Logger, Inputs) phases.Task
// Retire removes the superseded slot or commits/prunes a none SDK upgrade.
// The daemon must successfully save the target as applied before invoking it.
Retire(*slog.Logger, Inputs) phases.Task
// PlanReset discovers owned worker runtimes at execution time, independently
// of applied State. Callers stop workers before component cleanup and Finish;
// State deletion, status publication and uninstall stay outside the plan.
PlanReset(*slog.Logger) ResetPlan
}
Runtime constructs worker execution tasks. The daemon owns lifecycle decisions, applied State, and remote status publication; the SDK owns runtime recovery.
The daemon drives these transitions:
Bootstrap: Start -> save applied State
Reapply: Recover(applied) -> Restart, without advancing applied State
Repave: PrepareUpgrade(previous) -> agent hooks or host Hub cleanup
-> Start(target) -> save applied State -> Retire(previous)
Reset: stop workers -> host Hub cleanup if needed -> teardown -> clear configuration/State
An error stops the sequence without implying that earlier actions rolled back. Start must succeed before persistence, and persistence must succeed before Retire. Recovery guarantees are backend-specific; this interface adds no journal.