Documentation
¶
Overview ¶
Package workflow provides a multi-cycle saga abstraction on top of the multiphase reconciler pattern. A WorkflowStepReconcilerAction extends the standard step reconciler with a typed phase cursor persisted in a dedicated status sub-struct (not conditions) and a WaitForOwnedObjects primitive for convergence gating.
Index ¶
- Constants
- func WaitForOwnedObjects[T client.Object](ctx context.Context, c client.Client, owner client.Object, ...) (done bool, res reconcile.Result, err error)
- type DefaultWorkflowStepReconcilerAction
- func (m *DefaultWorkflowStepReconcilerAction) AdvancePhase(ctx context.Context, o k8sObject, to workflow.WorkflowPhase, ...) (res reconcile.Result, err error)
- func (m *DefaultWorkflowStepReconcilerAction) CurrentPhase(o k8sObject) workflow.WorkflowPhase
- func (m *DefaultWorkflowStepReconcilerAction) IsPhase(o k8sObject, phase workflow.WorkflowPhase) bool
- func (m *DefaultWorkflowStepReconcilerAction) IsPhaseEmpty(o k8sObject) bool
- type DefaultWorkflowStepReconcilerActionWithDiff
- func (m *DefaultWorkflowStepReconcilerActionWithDiff) AdvancePhase(ctx context.Context, o k8sObject, to workflow.WorkflowPhase, ...) (res reconcile.Result, err error)
- func (m *DefaultWorkflowStepReconcilerActionWithDiff) CurrentPhase(o k8sObject) workflow.WorkflowPhase
- func (m *DefaultWorkflowStepReconcilerActionWithDiff) IsPhase(o k8sObject, phase workflow.WorkflowPhase) bool
- func (m *DefaultWorkflowStepReconcilerActionWithDiff) IsPhaseEmpty(o k8sObject) bool
- type OwnedObjectPredicate
- type Phase
- type WorkflowStatusGetter
- type WorkflowStepReconcilerAction
- type WorkflowStepReconcilerActionWithDiff
Constants ¶
const DefaultRequeueAfter = 10 * time.Second
DefaultRequeueAfter is the default pause duration when owned objects have not yet converged.
Variables ¶
This section is empty.
Functions ¶
func WaitForOwnedObjects ¶
func WaitForOwnedObjects[T client.Object]( ctx context.Context, c client.Client, owner client.Object, list client.ObjectList, predicate OwnedObjectPredicate[T], listOpts ...client.ListOption, ) (done bool, res reconcile.Result, err error)
WaitForOwnedObjects lists owned objects matching the selector and checks whether all of them satisfy the predicate. If not all are converged, it returns a short-circuit reconcile.Result with RequeueAfter.
This generalises the hand-coded StatefulSet CurrentReplicas / sequence-number polling found in the elasticsearch-operator reference.
Types ¶
type DefaultWorkflowStepReconcilerAction ¶
type DefaultWorkflowStepReconcilerAction[k8sObject object.MultiPhaseObject, k8sStepObject client.Object] struct { *multiphase.DefaultMultiPhaseStepReconcilerAction[k8sObject, k8sStepObject] // contains filtered or unexported fields }
DefaultWorkflowStepReconcilerAction is the default implementation of WorkflowStepReconcilerAction. It embeds a standard multiphase step action and adds workflow phase management on top.
func (*DefaultWorkflowStepReconcilerAction) AdvancePhase ¶
func (*DefaultWorkflowStepReconcilerAction) CurrentPhase ¶
func (m *DefaultWorkflowStepReconcilerAction) CurrentPhase(o k8sObject) workflow.WorkflowPhase
func (*DefaultWorkflowStepReconcilerAction) IsPhase ¶
func (m *DefaultWorkflowStepReconcilerAction) IsPhase(o k8sObject, phase workflow.WorkflowPhase) bool
func (*DefaultWorkflowStepReconcilerAction) IsPhaseEmpty ¶
func (m *DefaultWorkflowStepReconcilerAction) IsPhaseEmpty(o k8sObject) bool
type DefaultWorkflowStepReconcilerActionWithDiff ¶ added in v3.0.2
type DefaultWorkflowStepReconcilerActionWithDiff[k8sObject object.MultiPhaseObject, k8sStepObject client.Object] struct { *multiphase.DefaultMultiPhaseStepReconcilerActionWithDiff[k8sObject, k8sStepObject] // contains filtered or unexported fields }
DefaultWorkflowStepReconcilerActionWithDiff is the default implementation of WorkflowStepReconcilerActionWithDiff. It embeds a multiphase diff step action and adds the same workflow phase management as the simple variant.
func (*DefaultWorkflowStepReconcilerActionWithDiff) AdvancePhase ¶ added in v3.0.2
func (*DefaultWorkflowStepReconcilerActionWithDiff) CurrentPhase ¶ added in v3.0.2
func (m *DefaultWorkflowStepReconcilerActionWithDiff) CurrentPhase(o k8sObject) workflow.WorkflowPhase
func (*DefaultWorkflowStepReconcilerActionWithDiff) IsPhase ¶ added in v3.0.2
func (m *DefaultWorkflowStepReconcilerActionWithDiff) IsPhase(o k8sObject, phase workflow.WorkflowPhase) bool
func (*DefaultWorkflowStepReconcilerActionWithDiff) IsPhaseEmpty ¶ added in v3.0.2
func (m *DefaultWorkflowStepReconcilerActionWithDiff) IsPhaseEmpty(o k8sObject) bool
type OwnedObjectPredicate ¶
OwnedObjectPredicate is a function that checks whether a given owned object has reached the desired state. Return true when the object is converged.
type Phase ¶
type Phase = workflow.WorkflowPhase
Phase is a convenience alias for workflow.WorkflowPhase.
type WorkflowStatusGetter ¶
type WorkflowStatusGetter interface {
GetWorkflowStatus() *workflow.WorkflowStatus
}
WorkflowStatusGetter is the interface that objects must implement to expose a WorkflowStatus sub-struct for saga phase tracking.
type WorkflowStepReconcilerAction ¶
type WorkflowStepReconcilerAction[k8sObject object.MultiPhaseObject, k8sStepObject client.Object] interface { multiphase.MultiPhaseStepReconcilerAction[k8sObject, k8sStepObject] // CurrentPhase returns the current saga phase. CurrentPhase(o k8sObject) workflow.WorkflowPhase // AdvancePhase transitions the saga to the next phase. AdvancePhase(ctx context.Context, o k8sObject, to workflow.WorkflowPhase, logger *logrus.Entry) (res reconcile.Result, err error) // IsPhase returns true when the saga is at the given phase. IsPhase(o k8sObject, phase workflow.WorkflowPhase) bool // IsPhaseEmpty returns true when no phase has been set yet. IsPhaseEmpty(o k8sObject) bool }
WorkflowStepReconcilerAction extends MultiPhaseStepReconcilerAction with multi-cycle saga support. It adds a typed phase cursor persisted in a WorkflowStatus sub-struct (not conditions) and exposes phase-management helpers for convergence-gated sagas.
The phase cursor follows this pattern:
- On each reconcile cycle, the step checks its current phase.
- It performs phase-appropriate work (computes desired objects in Read).
- When the phase requires convergence gating, it calls WaitForOwnedObjects and short-circuits.
- When the phase is complete, it advances to the next phase.
func NewWorkflowStepReconcilerAction ¶
func NewWorkflowStepReconcilerAction[k8sObject object.MultiPhaseObject, k8sStepObject client.Object]( c client.Client, phaseName shared.PhaseName, conditionName shared.ConditionName, recorder record.EventRecorder, fieldManager string, ) WorkflowStepReconcilerAction[k8sObject, k8sStepObject]
NewWorkflowStepReconcilerAction creates a new workflow step reconciler action.
type WorkflowStepReconcilerActionWithDiff ¶ added in v3.0.2
type WorkflowStepReconcilerActionWithDiff[k8sObject object.MultiPhaseObject, k8sStepObject client.Object] interface { multiphase.MultiPhaseStepReconcilerActionWithDiff[k8sObject, k8sStepObject] // CurrentPhase returns the current saga phase. CurrentPhase(o k8sObject) workflow.WorkflowPhase // AdvancePhase transitions the saga to the next phase. AdvancePhase(ctx context.Context, o k8sObject, to workflow.WorkflowPhase, logger *logrus.Entry) (res reconcile.Result, err error) // IsPhase returns true when the saga is at the given phase. IsPhase(o k8sObject, phase workflow.WorkflowPhase) bool // IsPhaseEmpty returns true when no phase has been set yet. IsPhaseEmpty(o k8sObject) bool }
WorkflowStepReconcilerActionWithDiff is the diff variant of WorkflowStepReconcilerAction. It embeds the multiphase diff variant (SSA dry-run classification + optional OnDiff) and adds the same saga phase-management helpers as the simple variant.
func NewWorkflowStepReconcilerActionWithDiff ¶ added in v3.0.2
func NewWorkflowStepReconcilerActionWithDiff[k8sObject object.MultiPhaseObject, k8sStepObject client.Object]( c client.Client, phaseName shared.PhaseName, conditionName shared.ConditionName, recorder record.EventRecorder, fieldManager string, ) WorkflowStepReconcilerActionWithDiff[k8sObject, k8sStepObject]
NewWorkflowStepReconcilerActionWithDiff creates a new workflow step reconciler action using SSA dry-run diff classification.