Documentation
¶
Overview ¶
Package daemon defines public library-facing types for composing host-local agent daemon controllers and operation runners.
Index ¶
- func FinishMachineOperation(ctx context.Context, c client.Client, op MachineOperation, ...) error
- func ReadBootID() (string, error)
- func RebootHost(ctx context.Context, log *slog.Logger) error
- func SetMachineOperationResult(op *machinav1alpha3.MachineOperation, result MachineOperationResult[int64], ...)
- func SetupController(name string, mgr ctrl.Manager, ...) error
- type HostRebooter
- type HostSoftRebootHandler
- type HostSoftRebootTarget
- type MachinaMachineOperationReconciler
- func NewMachinaMachineOperationReconciler(c client.Client, machineName string, nodeName string, ...) (*MachinaMachineOperationReconciler, error)
- func NewMachinaMachineOperationReconcilerWithReader(c client.Client, reader client.Reader, machineName string, nodeName string, ...) (*MachinaMachineOperationReconciler, error)
- func (r *MachinaMachineOperationReconciler) Finish(ctx context.Context, op MachineOperation, result MachineOperationResult[int64]) error
- func (r *MachinaMachineOperationReconciler) MarkInProgress(ctx context.Context, op MachineOperation, message string) error
- func (r *MachinaMachineOperationReconciler) ReconcileMachineOperation(ctx context.Context, name string) (ctrl.Result, error)
- func (r *MachinaMachineOperationReconciler) SetupController(b *builder.TypedBuilder[Request]) *builder.TypedBuilder[Request]
- type MachineOperation
- type MachineOperationHandler
- type MachineOperationHandlers
- type MachineOperationRequestReconciler
- type MachineOperationResult
- type MachineOperationStore
- type RepaveReconciler
- type Request
- type SystemHostRebooter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FinishMachineOperation ¶
func FinishMachineOperation(ctx context.Context, c client.Client, op MachineOperation, result MachineOperationResult[int64]) error
FinishMachineOperation records the final status for a MachineOperation.
func ReadBootID ¶ added in v0.27.0
ReadBootID reads the current host kernel boot ID.
func RebootHost ¶ added in v0.19.0
RebootHost asks systemd to reboot the host. It runs independently of ctx cancellation because systemd stops the caller as soon as the reboot starts. If systemctl reports an error while systemd is already stopping, the reboot is treated as under way.
func SetMachineOperationResult ¶ added in v0.19.0
func SetMachineOperationResult(op *machinav1alpha3.MachineOperation, result MachineOperationResult[int64], now metav1.Time)
SetMachineOperationResult applies result to the status of op, as FinishMachineOperation does, without writing it.
func SetupController ¶
func SetupController( name string, mgr ctrl.Manager, machineOperations MachineOperationRequestReconciler, repaves RepaveReconciler, ) error
SetupController registers a serialized controller with mgr. The reconciler owns request handling, including any goal resolution and host-local operation execution. All queued requests are serialized because host-local daemon operations mutate the same nspawn, systemd, filesystem, and daemon-binary state.
Types ¶
type HostRebooter ¶ added in v0.27.0
type HostRebooter interface {
BootID() (string, error)
RebootHost(context.Context, *slog.Logger) error
}
HostRebooter reads host boot evidence and requests a host reboot.
type HostSoftRebootHandler ¶ added in v0.27.0
type HostSoftRebootHandler struct {
// contains filtered or unexported fields
}
HostSoftRebootHandler implements the status and boot-evidence protocol. The caller serializes runtime work, holds its mutation lock during Reconcile, and uses requested to defer other work during an accepted reboot handoff.
func NewHostSoftRebootHandler ¶ added in v0.27.0
func NewHostSoftRebootHandler( c client.Client, reader client.Reader, log *slog.Logger, target HostSoftRebootTarget, host HostRebooter, requested *atomic.Bool, ) (*HostSoftRebootHandler, error)
NewHostSoftRebootHandler constructs a handler with a live API reader and an explicit host executor. No system reboot is used as a fallback.
func (*HostSoftRebootHandler) PublishStartup ¶ added in v0.27.0
func (h *HostSoftRebootHandler) PublishStartup(ctx context.Context) error
PublishStartup judges previous reboot handoffs before the caller admits work. It must only run during startup, not after this process issues a reboot. Errors are returned to the caller, which controls startup retry behavior.
func (*HostSoftRebootHandler) Reconcile ¶ added in v0.27.0
func (h *HostSoftRebootHandler) Reconcile(ctx context.Context, store MachineOperationStore[int64], op MachineOperation) (ctrl.Result, error)
Reconcile handles a HostSoftReboot routed to this target. The caller must hold its mutation lock. Status recording is required before the host command runs.
type HostSoftRebootTarget ¶ added in v0.27.0
type HostSoftRebootTarget interface {
Reference() string
ObservedGeneration(context.Context, client.Reader) (int64, error)
MatchSelector(context.Context, client.Reader, v1alpha3.OperationKind, labels.Selector) (bool, error)
}
HostSoftRebootTarget resolves the identity and selector labels of the local target. Reference is the machineRef used by operations, not necessarily a Machine CR. MatchSelector receives a compiled selector and the operation kind.
type MachinaMachineOperationReconciler ¶
type MachinaMachineOperationReconciler struct {
// contains filtered or unexported fields
}
MachinaMachineOperationReconciler fetches MachineOperation objects, skips terminal operations, and dispatches non-terminal operations to kind-specific targets.
func NewMachinaMachineOperationReconciler ¶
func NewMachinaMachineOperationReconciler( c client.Client, machineName string, nodeName string, handlers MachineOperationHandlers, ) (*MachinaMachineOperationReconciler, error)
NewMachinaMachineOperationReconciler returns a reusable MachineOperation request reconciler backed by client and kind-specific targets.
func NewMachinaMachineOperationReconcilerWithReader ¶ added in v0.2.4
func NewMachinaMachineOperationReconcilerWithReader( c client.Client, reader client.Reader, machineName string, nodeName string, handlers MachineOperationHandlers, ) (*MachinaMachineOperationReconciler, error)
NewMachinaMachineOperationReconcilerWithReader configures an uncached reader for terminal-state checks while retaining the client for status writes.
func (*MachinaMachineOperationReconciler) Finish ¶
func (r *MachinaMachineOperationReconciler) Finish(ctx context.Context, op MachineOperation, result MachineOperationResult[int64]) error
Finish records the final status for a MachineOperation.
func (*MachinaMachineOperationReconciler) MarkInProgress ¶
func (r *MachinaMachineOperationReconciler) MarkInProgress(ctx context.Context, op MachineOperation, message string) error
func (*MachinaMachineOperationReconciler) ReconcileMachineOperation ¶
func (r *MachinaMachineOperationReconciler) ReconcileMachineOperation( ctx context.Context, name string, ) (ctrl.Result, error)
ReconcileMachineOperation handles a queued MachineOperation request.
func (*MachinaMachineOperationReconciler) SetupController ¶
func (r *MachinaMachineOperationReconciler) SetupController(b *builder.TypedBuilder[Request]) *builder.TypedBuilder[Request]
SetupController registers the MachineOperation watch for this reconciler.
type MachineOperation ¶
type MachineOperation struct {
// Name is the operation name in its source system.
Name string
// Kind is the requested host-local operation kind.
Kind machinav1alpha3.OperationKind
// Parameters contains operation-specific inputs, such as an AgentUpgrade download URL.
Parameters map[string]string
}
MachineOperation is a typed host-local daemon operation request.
type MachineOperationHandler ¶
type MachineOperationHandler[TGeneration comparable] func(context.Context, MachineOperationStore[TGeneration], MachineOperation) (ctrl.Result, error)
MachineOperationHandler executes a host-local daemon operation.
type MachineOperationHandlers ¶
type MachineOperationHandlers map[machinav1alpha3.OperationKind]MachineOperationHandler[int64]
MachineOperationHandlers maps operation kinds to host-local MachineOperation handlers.
type MachineOperationRequestReconciler ¶
type MachineOperationRequestReconciler interface {
// SetupController registers MachineOperation watches on builder.
SetupController(*builder.TypedBuilder[Request]) *builder.TypedBuilder[Request]
// ReconcileMachineOperation handles req, which identifies a MachineOperation
// object queued by controller-runtime.
ReconcileMachineOperation(context.Context, string) (ctrl.Result, error)
}
MachineOperationRequestReconciler handles MachineOperation requests produced by the shared controller setup.
func NoopMachineOperationReconciler ¶
func NoopMachineOperationReconciler() MachineOperationRequestReconciler
NoopMachineOperationReconciler returns a MachineOperationRequestReconciler that does not register watches. Use it when a daemon controller only needs repave requests.
type MachineOperationResult ¶
type MachineOperationResult[TGeneration comparable] struct { // Phase is the resulting operation phase. Phase machinav1alpha3.OperationPhase // Reason is a stable, machine-readable reason for the result. Reason string // Message is a human-readable result description. Message string // ObservedMachineGeneration records the machine generation acted on by the operation. ObservedMachineGeneration TGeneration }
MachineOperationResult describes the outcome of a host-local daemon operation.
type MachineOperationStore ¶
type MachineOperationStore[TGeneration comparable] interface { // MarkInProgress records that op has started execution with message as the // human-readable in-progress status. MarkInProgress(context.Context, MachineOperation, string) error // Finish records the terminal or non-terminal result for op. The result // carries the desired phase, reason, message, observed generation, and any // controller-runtime requeue request. Finish(context.Context, MachineOperation, MachineOperationResult[TGeneration]) error }
MachineOperationStore records operation lifecycle state.
type RepaveReconciler ¶
type RepaveReconciler interface {
// SetupController registers repave watches on builder.
SetupController(*builder.TypedBuilder[Request]) *builder.TypedBuilder[Request]
// ReconcileRepave handles req, which identifies a local repave trigger queued
// by controller-runtime.
ReconcileRepave(context.Context, string) (ctrl.Result, error)
}
RepaveReconciler handles repave requests produced by the shared controller setup.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request is the controller-runtime queue item used by shared daemon controller setup. Use NewMachineOperationRequest or NewRepaveRequest to construct one.
func NewMachineOperationRequest ¶
NewMachineOperationRequest returns a controller queue request for a MachineOperation object.
func NewRepaveRequest ¶
NewRepaveRequest returns a controller queue request for a repave trigger.
type SystemHostRebooter ¶ added in v0.27.0
type SystemHostRebooter struct{}
SystemHostRebooter executes the host operating system reboot helpers.
func (SystemHostRebooter) BootID ¶ added in v0.27.0
func (SystemHostRebooter) BootID() (string, error)