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 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 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
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 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 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.