Documentation
¶
Index ¶
- Constants
- Variables
- func AbandonReprovision(ctx context.Context, log *slog.Logger, dir string) error
- func AllocationUID(cfg *provision.AgentConfig) (uid string, backed bool)
- func AttestRecordPath() string
- func EnableDaemon(log *slog.Logger) phases.Task
- func InstallBootstrapBinary() error
- func IsFinalAllocationLaunchRefusal(err error) bool
- func LoadAllocationLaunchConfig() (*provision.AgentConfig, bool, error)
- func MigrateHostRoot(log *slog.Logger) error
- func PersistAllocationLaunchConfig(cfg *provision.AgentConfig) error
- func PersistAppliedConfig(log *slog.Logger, machineName string, cfg *config.AgentConfig) phases.Task
- func PersistAppliedConfigFor(log *slog.Logger, mode isolation.Mode, slot string, cfg *config.AgentConfig) phases.Task
- func PersistAttestConfig(log *slog.Logger, attest *provision.AgentAttestConfig) 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 RemoveFirstBootBootstrapUnit(log *slog.Logger) phases.Task
- func RemoveReprovisionHandoff(log *slog.Logger) phases.Task
- func RepairDaemon(ctx context.Context, log *slog.Logger, backends ModeBackends) error
- func ReportReprovisionGaveUp(ctx context.Context, cfg *provision.AgentConfig, j migrate.Journal) error
- func ReprovisionGaveUpStatus(j migrate.Journal) *v1alpha3.IsolationChangeStatus
- func ResetAgent(log *slog.Logger) phases.Task
- func ResetAgentForReprovision(log *slog.Logger) phases.Task
- func Run(ctx context.Context, log *slog.Logger, modes ModeOperators, ...) error
- func StopDaemon(log *slog.Logger) phases.Task
- func VerifyAllocationLaunch(ctx context.Context, log *slog.Logger, cfg *provision.AgentConfig) error
- func VerifyDaemonInstalled(ctx context.Context, log *slog.Logger) error
- type ActiveMachine
- type BackendFactory
- type BootstrapStatusReporter
- type ContainerNode
- type ContainerOperator
- func (op ContainerOperator) EnsureLifecycleMigration(ctx context.Context, log *slog.Logger, active *ActiveMachine) error
- func (op ContainerOperator) RepaveNode(ctx context.Context, log *slog.Logger, active *ActiveMachine, ...) error
- func (op ContainerOperator) RestartNode(ctx context.Context, log *slog.Logger, active *ActiveMachine) error
- 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
- type ModeBackends
- type ModeOperator
- type ModeOperators
- type NSpawnOperator
- func (NSpawnOperator) EnsureLifecycleMigration(ctx context.Context, log *slog.Logger, active *ActiveMachine) error
- func (NSpawnOperator) RepaveNode(ctx context.Context, log *slog.Logger, active *ActiveMachine, ...) error
- func (op NSpawnOperator) RestartNode(ctx context.Context, log *slog.Logger, active *ActiveMachine) error
- type NoneNode
- type NoneOperator
- func (op NoneOperator) EnsureLifecycleMigration(ctx context.Context, log *slog.Logger, active *ActiveMachine) error
- func (op NoneOperator) RepaveNode(ctx context.Context, log *slog.Logger, active *ActiveMachine, ...) error
- func (op NoneOperator) RestartNode(ctx context.Context, log *slog.Logger, active *ActiveMachine) error
Constants ¶
const ( // ReprovisionDir holds what a reprovision needs to survive its own reset: // the journal, a copy of the agent binary and the target configuration. The // reset does not remove it; the daemon that reports the outcome does. ReprovisionDir = "/var/lib/unbounded-agent-reprovision" // ReprovisionJournalName, ReprovisionConfigName and ReprovisionBinaryName // are the files in ReprovisionDir. ReprovisionJournalName = "journal.json" ReprovisionConfigName = "config.json" ReprovisionBinaryName = "unbounded-agent" // ReprovisionUnit is the systemd unit that runs the handoff command. ReprovisionUnit = "unbounded-agent-reprovision.service" // ReprovisionGiveUpAfter is how long after the handoff started its runs // keep being retried. It is below machina's ChangeStale threshold (two // hours), so a handoff that gives up reports Failed before machina would // call the change stale; ChangeStale then means the agent could not report // at all. ReprovisionGiveUpAfter = 90 * time.Minute // ReprovisionRestartDelay is the unit's RestartSec, the shortest pause // between two runs. The command adds a growing delay of its own on top. ReprovisionRestartDelay = 30 * time.Second // ReprovisionMaxBackoff caps the delay between two runs. ReprovisionMaxBackoff = 10 * time.Minute )
const ( // AllocationLaunchRefusedReason is the condition and MachineOperation // reason reported when the guard refuses to start an allocation host's // node. AllocationLaunchRefusedReason = "AllocationLaunchRefused" )
const DefaultMigrationReadyTimeout = 5 * time.Minute
DefaultMigrationReadyTimeout bounds the wait for the target node stack to come up on the host.
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 )
const InPlaceJournalName = "isolation-migration.json"
InPlaceJournalName is the file name of the in-place migration journal, which lives next to the applied configs. While a migration has two applied configs recorded, it says which one the node runs on.
const SupportsIsolationCommand = "supports-isolation"
SupportsIsolationCommand is the agent subcommand that exits zero when the binary can operate the isolation mode it is given.
Variables ¶
var ErrAllocationLaunchRefused = errors.New("allocation launch refused")
ErrAllocationLaunchRefused reports that an allocation-backed host must not start its node: its allocation is fenced, or that could not be ruled out.
var ErrBootstrapTokenRejected = errors.New("the bootstrap token recorded for this node is no longer accepted by the API server")
ErrBootstrapTokenRejected is returned, before anything is reset, when the API server answers that it no longer accepts the bootstrap token recorded for the node.
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.
var ErrMigrationHandedOff = errors.New("isolation migration handed off to the reprovision unit")
ErrMigrationHandedOff is returned by a mode change that continues without this daemon: a reprovision resets the host, which removes the daemon, and a handoff command finishes the bootstrap. The change stays InProgress in the Machine status and the daemon that starts afterward reports it.
var ErrRestartRequested = errors.New("daemon stopping to be restarted")
ErrRestartRequested reports that the daemon stopped so it can be started again: it staged an AgentUpgrade, or moved its files to the host root, and the unit now runs a different binary or a different path. The command layer re-executes the binary the unit runs in the same process. If it cannot, it exits 0, and the unit's Restart=always starts the daemon again after RestartSec.
The daemon does not ask systemd to restart it. A systemctl it runs is in the daemon's cgroup, and stopping the daemon kills everything in that cgroup. When the kill lands before systemctl exits, the daemon sees a failed command for a restart already under way. Re-executing or exiting leaves nothing to kill.
Functions ¶
func AbandonReprovision ¶ added in v0.24.0
AbandonReprovision ends a handoff that gave up: it disables and removes the unit and removes the staged binary and configuration, which holds the bootstrap token. The journal stays in dir, so the next daemon to start on the host reports the failure in the Machine status and then removes it.
func AllocationUID ¶ added in v0.24.0
func AllocationUID(cfg *provision.AgentConfig) (uid string, backed bool)
AllocationUID reports whether cfg belongs to a host launched for a MachineAllocation, and that allocation's UID; see provision.AllocationUID.
func AttestRecordPath ¶ added in v0.24.0
func AttestRecordPath() string
AttestRecordPath is where the attestation settings are recorded on the host.
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.
The binary path comes from the resolved upgrade paths, so an environment override lands the binary where VerifyDaemonInstalled will look for it.
func IsFinalAllocationLaunchRefusal ¶ added in v0.24.0
IsFinalAllocationLaunchRefusal reports whether err is a refusal that reading again cannot change: the cluster answered no, or the host cannot ask. It is false for a refusal because no read answered within the budget or the context ended, and for any error that is not a refusal.
func LoadAllocationLaunchConfig ¶ added in v0.24.0
func LoadAllocationLaunchConfig() (*provision.AgentConfig, bool, error)
LoadAllocationLaunchConfig reads the allocation launch record. found is false when the host has none.
func MigrateHostRoot ¶ added in v0.13.0
MigrateHostRoot links the host root to the legacy root on a host installed by an agent released before the host root. Commands that change the host call it before resolving any path; see hostroot.Migrate.
func PersistAllocationLaunchConfig ¶ added in v0.24.0
func PersistAllocationLaunchConfig(cfg *provision.AgentConfig) error
PersistAllocationLaunchConfig writes the allocation launch record for an allocation-backed config. It does nothing for any other config.
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 PersistAppliedConfigFor ¶ added in v0.24.0
func PersistAppliedConfigFor(log *slog.Logger, mode isolation.Mode, slot string, cfg *config.AgentConfig) phases.Task
PersistAppliedConfigFor is PersistAppliedConfig for the node of slot in mode. nspawn keeps the file names older agents read; every other mode stores its config where they do not look (see goalstates.AppliedConfigName).
func PersistAttestConfig ¶ added in v0.24.0
PersistAttestConfig returns a task that records the attestation settings the host was bootstrapped with at AttestRecordPath. It does nothing when attest is nil or has no URL.
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, and then the host root itself once it is empty, or the link to the legacy root on a migrated host.
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 RemoveFirstBootBootstrapUnit ¶ added in v0.13.0
RemoveFirstBootBootstrapUnit returns a task that stops, disables and removes the unit an Ignition config installs to bootstrap the agent.
The unit runs on every boot and relies on the ownership record, which reset removes, to decide there is nothing to do. Left behind, it would bootstrap the reset host again on the next boot.
func RemoveReprovisionHandoff ¶ added in v0.24.0
RemoveReprovisionHandoff is the part of an agent reset that removes what a reprovision left behind: the unit, the staged binary and configuration, and the journal. Without it, a reset after a handoff that gave up would leave a unit and a copy of the bootstrap token on the host. The handoff's own reset does not include it, because it runs from that directory.
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. backends is the backend of every isolation mode this agent can operate, from the agent's mode composition table: with two applied configs, the daemon asks them which node stack runs, and so does the repair.
func ReportReprovisionGaveUp ¶ added in v0.24.0
func ReportReprovisionGaveUp(ctx context.Context, cfg *provision.AgentConfig, j migrate.Journal) error
ReportReprovisionGaveUp reports a handoff that gave up in the Machine status, with the bootstrap token of the staged configuration cfg. The host is reset and has no daemon to report it, and the staged configuration, which holds the token, is about to be removed. A configuration without a token (an attested host) cannot report: the change is then reported by the first daemon that starts on the host, or shows as stale in machina.
func ReprovisionGaveUpStatus ¶ added in v0.24.0
func ReprovisionGaveUpStatus(j migrate.Journal) *v1alpha3.IsolationChangeStatus
ReprovisionGaveUpStatus is what a handoff that gave up reports in the Machine status.
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 ResetAgentForReprovision ¶ added in v0.24.0
ResetAgentForReprovision is ResetAgent for the reprovision handoff: it leaves the handoff's unit, binary, configuration and journal in place, since the handoff runs from them.
func Run ¶
func Run(ctx context.Context, log *slog.Logger, modes ModeOperators, backends ModeBackends) error
Run is the main daemon entry point. It discovers the active node, builds a Kubernetes client, registers the Machine CR if needed, and blocks until the context is canceled. modes is the operator, and backends the backend, of every isolation mode this agent can operate, from the agent's mode composition table.
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 VerifyAllocationLaunch ¶ added in v0.24.0
func VerifyAllocationLaunch(ctx context.Context, log *slog.Logger, cfg *provision.AgentConfig) error
VerifyAllocationLaunch decides whether an allocation-backed host may start its node. It returns nil at once for any other host.
Every read selects its credential again. With a stored, unexpired daemon-controller certificate the read gets the Machine live and allows only a Machine that binds this allocation UID, is not fenced and is not being deleted. Otherwise it asks the API server to review the bootstrap token, which is revoked when the allocation is fenced. A read never falls back from the certificate to the token; a certificate that expires during a call only moves the next read to the token.
It fails closed: every refusal wraps ErrAllocationLaunchRefused, and reads that keep failing transiently refuse once the retry budget is spent.
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
// Mode is the isolation mode the machine was applied with. The empty mode
// is the default mode.
Mode isolation.Mode
}
ActiveMachine holds the currently active node slot, its applied agent configuration and the isolation mode it runs in.
func FindActiveMachine ¶ added in v0.24.0
func FindActiveMachine(log *slog.Logger) (*ActiveMachine, error)
FindActiveMachine returns the running node, from its applied config, for tools outside the daemon (exec, logs) that operate it the way the daemon does. It never asks a backend whether a node runs, so a host with two applied configs and no journal is an error.
type BackendFactory ¶ added in v0.23.0
BackendFactory builds a mode's isolation backend bound to one 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 ContainerNode ¶ added in v0.24.0
type ContainerNode interface {
Restart(ctx context.Context) error
RewriteUnit(ctx context.Context) error
Upgrade(ctx context.Context, old ContainerNode) error
Destroy(ctx context.Context) error
}
ContainerNode is the part of a containerops.Node the container operator drives. Upgrade takes the node it replaces.
type ContainerOperator ¶ added in v0.24.0
type ContainerOperator struct {
// NewNode builds the node of a slot. Nil uses containerops.New.
NewNode func(containerops.Params) ContainerNode
// ResolveDownloads resolves the artifact download overrides and the
// offline container image archives of a configuration. Nil uses
// provision.ResolveDownloadOverridesWithOfflineArtifacts.
ResolveDownloads func(ctx context.Context, cfg *provision.UnboundedAgentConfig) (*goalstates.DownloadOverrides, *goalstates.ContainerImageArchiveStaging, error)
// StageArchives stages the offline container image archives. Nil downloads
// them for real.
StageArchives func(ctx context.Context, log *slog.Logger, staging *goalstates.ContainerImageArchiveStaging) error
// Persist records cfg as the applied config of slot. Nil writes it where
// goalstates.AppliedConfigName puts a container node's config.
Persist func(ctx context.Context, log *slog.Logger, slot string, cfg *provision.AgentConfig) error
// Remove removes the applied config record of slot. Nil removes the file.
Remove func(ctx context.Context, log *slog.Logger, slot string) error
}
ContainerOperator performs the node operations of a node that runs in an OCI container. The host-level operations (discovery, reset, daemon stop, agent upgrade) are the host operator's, as for every mode.
A container node is blue/green like nspawn: it runs in slot kube1 or kube2 and records its applied config where goalstates.AppliedConfigName puts it for the container mode, which agents that predate the mode never read.
Its fields are the host-touching steps; the zero value of each is the real host, and tests replace them.
PROVISIONAL: the container mode is experimental; see the containerops package comment for what is unverified.
func (ContainerOperator) EnsureLifecycleMigration ¶ added in v0.24.0
func (op ContainerOperator) EnsureLifecycleMigration(ctx context.Context, log *slog.Logger, active *ActiveMachine) error
EnsureLifecycleMigration re-renders the supervising unit so its hooks name the current lifecycle helper path (the host root may have moved it), and reloads systemd without restarting the container. The nspawn lifecycle files do not exist for a container.
func (ContainerOperator) RepaveNode ¶ added in v0.24.0
func (op ContainerOperator) RepaveNode(ctx context.Context, log *slog.Logger, active *ActiveMachine, newCfg *provision.UnboundedAgentConfig) error
RepaveNode moves a container node to the alternate slot, as for nspawn. The caller has cordoned, drained and deleted the Node. The new slot is built beside the running one, then the old container is stopped and disabled, host networking cleaned as repave does, and the new container started and waited on. If the new slot does not come up it is removed and, once it is confirmed gone, the old container is started again, and the error says so. The applied config is persisted only after the new slot is healthy, then the old slot's record and files are removed.
The node keeps its mode: a declared mode change is handled by the repave reconciler before it gets here, so the record is written as container whatever the desired config says.
func (ContainerOperator) RestartNode ¶ added in v0.24.0
func (op ContainerOperator) RestartNode(ctx context.Context, log *slog.Logger, active *ActiveMachine) error
RestartNode restarts the container unit (the soft reboot), which re-runs the lifecycle hooks, and waits for systemd, LocalDNS and kubelet. It never restarts the host.
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.
type ModeBackends ¶ added in v0.24.0
type ModeBackends map[isolation.Mode]BackendFactory
ModeBackends holds the backend factory of every isolation mode this agent can operate. The agent's mode composition table builds it.
type ModeOperator ¶ added in v0.23.0
type ModeOperator interface {
// EnsureLifecycleMigration installs lifecycle hooks for the active node
// without restarting its currently running services.
EnsureLifecycleMigration(context.Context, *slog.Logger, *ActiveMachine) error
// RestartNode restarts the active node stack in place. It never restarts
// the host.
RestartNode(context.Context, *slog.Logger, *ActiveMachine) error
// RepaveNode replaces the active node with one built from the desired
// configuration. The caller triggers it only after the Kubernetes Node has
// been cordoned, drained and deleted; it does not perform Kubernetes
// eviction or CNI-specific dataplane cleanup itself.
RepaveNode(context.Context, *slog.Logger, *ActiveMachine, *provision.UnboundedAgentConfig) error
}
ModeOperator is the node operations one isolation mode implements. Every mode implements all of them itself: a mode's operator never embeds another mode's, so a method added here is a compile error in every mode that does not implement it rather than a silent fallback to another mode's behavior.
type ModeOperators ¶ added in v0.23.0
type ModeOperators map[isolation.Mode]ModeOperator
ModeOperators holds the operator of every isolation mode this agent can operate. The agent's mode composition table builds it.
type NSpawnOperator ¶ added in v0.23.0
type NSpawnOperator struct {
// NewBackend builds the nspawn backend for a configuration. It is the
// backend of the mode composition table's nspawn entry.
NewBackend BackendFactory
}
NSpawnOperator is the ModeOperator of the nspawn mode.
func NewNSpawnOperator ¶ added in v0.23.0
func NewNSpawnOperator(newBackend BackendFactory) NSpawnOperator
NewNSpawnOperator returns the nspawn ModeOperator, whose node restarts run through the backend newBackend builds.
func (NSpawnOperator) EnsureLifecycleMigration ¶ added in v0.23.0
func (NSpawnOperator) EnsureLifecycleMigration(ctx context.Context, log *slog.Logger, active *ActiveMachine) error
func (NSpawnOperator) RepaveNode ¶ added in v0.23.0
func (NSpawnOperator) RepaveNode( ctx context.Context, log *slog.Logger, active *ActiveMachine, newCfg *provision.UnboundedAgentConfig, ) error
RepaveNode 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
func (NSpawnOperator) RestartNode ¶ added in v0.23.0
func (op NSpawnOperator) RestartNode(ctx context.Context, log *slog.Logger, active *ActiveMachine) error
type NoneNode ¶ added in v0.24.0
type NoneNode interface {
RecoverUpgrade(ctx context.Context) error
Restart(ctx context.Context) error
Upgrade(ctx context.Context) error
Commit() error
PruneVersions() error
}
NoneNode is the part of noneops.Node the none operator drives.
type NoneOperator ¶ added in v0.24.0
type NoneOperator struct {
// NewNode builds the node for a configuration. Nil uses noneops.New.
NewNode func(noneops.Params) NoneNode
// ResolveDownloads resolves the artifact download overrides and the offline
// container image archives of a configuration. Nil uses
// provision.ResolveDownloadOverridesWithOfflineArtifacts.
ResolveDownloads func(ctx context.Context, cfg *provision.UnboundedAgentConfig) (*goalstates.DownloadOverrides, *goalstates.ContainerImageArchiveStaging, error)
// StageArchives stages the offline container image archives. Nil downloads
// them for real.
StageArchives func(ctx context.Context, log *slog.Logger, staging *goalstates.ContainerImageArchiveStaging) error
// Persist records cfg as the applied config of the none node. Nil writes it
// where goalstates.AppliedConfigName puts a none node's config.
Persist func(ctx context.Context, log *slog.Logger, cfg *provision.AgentConfig) error
}
NoneOperator performs the node operations of a host-native (none) node. The host-level operations (discovery, reset, daemon stop, agent upgrade) are the host operator's, as for every mode.
Its fields are the host-touching steps; the zero value of each is the real host, and tests replace them.
func (NoneOperator) EnsureLifecycleMigration ¶ added in v0.24.0
func (op NoneOperator) EnsureLifecycleMigration(ctx context.Context, log *slog.Logger, active *ActiveMachine) error
EnsureLifecycleMigration runs at every daemon start. A host-native node has no nspawn lifecycle hooks to reconcile; what it may have is an upgrade the agent did not finish, which is finished here, before the daemon operates the node: rolled back, or committed when it had already succeeded.
A recovery that fails is logged and does not stop the daemon. Refusing to start would leave the node with no in-band way out: no repave, which retries the recovery (see RepaveNode), and no reset.
func (NoneOperator) RepaveNode ¶ added in v0.24.0
func (op NoneOperator) RepaveNode(ctx context.Context, log *slog.Logger, active *ActiveMachine, newCfg *provision.UnboundedAgentConfig) error
RepaveNode upgrades a host-native node in place. The caller has cordoned, drained and deleted the Node, as for nspawn. The new version is installed beside the running one, then the stack is stopped, its pods ended, host networking cleaned as repave does, the current link flipped, the stack started and kubelet waited on. If the new version does not come up the previous one is started again with the configuration it ran, and the error says so. The applied config is persisted only after the new version is healthy; the upgrade is committed after that, and the superseded version directories are removed last.
The node keeps its mode: a declared mode change is refused by the repave reconciler before it gets here.
func (NoneOperator) RestartNode ¶ added in v0.24.0
func (op NoneOperator) RestartNode(ctx context.Context, log *slog.Logger, active *ActiveMachine) error
RestartNode restarts LocalDNS, containerd and kubelet in order (the soft reboot) and waits for LocalDNS and kubelet. It never restarts the host, and the pods keep running.
Source Files
¶
- agentupgrade.go
- allocation_fence.go
- attest_record.go
- bootstrap_status.go
- controller.go
- controller_machineoperation.go
- controller_node.go
- daemon.go
- hostosreboot.go
- hostroot.go
- hostupgrade.go
- isolation_change.go
- isolation_status.go
- lifecycle.go
- migration.go
- migration_container.go
- migration_env.go
- migration_inplace.go
- migration_recover.go
- migration_reprovision.go
- nodeoperator.go
- nodeoperator_container.go
- nodeoperator_dispatch.go
- nodeoperator_host.go
- nodeoperator_none.go
- nodeoperator_nspawn.go
- persist_config.go
- reset.go
- scheme.go
- sysutil.go