Documentation ¶
Index ¶
- Constants
- func DequeueOpsRequestInClusterAnnotation(ctx context.Context, cli client.Client, opsRes *OpsResource) error
- func GetOpsRecorderFromSlice(opsRequestSlice []opsv1alpha1.OpsRecorder, opsRequestName string) (int, opsv1alpha1.OpsRecorder)
- func PatchClusterNotFound(ctx context.Context, cli client.Client, opsRes *OpsResource) error
- func PatchOpsHandlerNotSupported(ctx context.Context, cli client.Client, opsRes *OpsResource) error
- func PatchOpsStatus(ctx context.Context, cli client.Client, opsRes *OpsResource, ...) error
- func PatchOpsStatusWithOpsDeepCopy(ctx context.Context, cli client.Client, opsRes *OpsResource, ...) error
- type BackupOpsHandler
- func (b BackupOpsHandler) Action(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
- func (b BackupOpsHandler) ActionStartedCondition(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (*metav1.Condition, error)
- func (b BackupOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (opsv1alpha1.OpsPhase, time.Duration, error)
- func (b BackupOpsHandler) SaveLastConfiguration(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
- type ComponentOpsInterface
- type CustomOpsHandler
- func (c CustomOpsHandler) Action(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
- func (c CustomOpsHandler) ActionStartedCondition(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (*metav1.Condition, error)
- func (c CustomOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (opsv1alpha1.OpsPhase, time.Duration, error)
- func (c CustomOpsHandler) SaveLastConfiguration(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
- type ExposeOpsHandler
- func (e ExposeOpsHandler) Action(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
- func (e ExposeOpsHandler) ActionStartedCondition(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (*metav1.Condition, error)
- func (e ExposeOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsResource *OpsResource) (opsv1alpha1.OpsPhase, time.Duration, error)
- func (e ExposeOpsHandler) SaveLastConfiguration(reqCtx intctrlutil.RequestCtx, cli client.Client, opsResource *OpsResource) error
- type OpsBehaviour
- type OpsHandler
- type OpsManager
- func (opsMgr *OpsManager) Do(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (*ctrl.Result, error)
- func (opsMgr *OpsManager) Reconcile(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (time.Duration, error)
- func (opsMgr *OpsManager) RegisterOps(opsType opsv1alpha1.OpsType, opsBehaviour OpsBehaviour)
- type OpsResource
- type RestoreOpsHandler
- func (r RestoreOpsHandler) Action(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
- func (r RestoreOpsHandler) ActionStartedCondition(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (*metav1.Condition, error)
- func (r RestoreOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (opsv1alpha1.OpsPhase, time.Duration, error)
- func (r RestoreOpsHandler) SaveLastConfiguration(reqCtx intctrlutil.RequestCtx, cli client.Client, opsResource *OpsResource) error
- type StartOpsHandler
- func (start StartOpsHandler) Action(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
- func (start StartOpsHandler) ActionStartedCondition(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (*metav1.Condition, error)
- func (start StartOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (opsv1alpha1.OpsPhase, time.Duration, error)
- func (start StartOpsHandler) SaveLastConfiguration(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
- type StopOpsHandler
- func (stop StopOpsHandler) Action(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
- func (stop StopOpsHandler) ActionStartedCondition(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (*metav1.Condition, error)
- func (stop StopOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (opsv1alpha1.OpsPhase, time.Duration, error)
- func (stop StopOpsHandler) SaveLastConfiguration(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
- type SwitchoverMessage
- type WaitForClusterPhaseErr
- type WorkflowContext
- type WorkflowStatus
Constants ¶
const ( OpsReasonForSkipSwitchover = "SkipSwitchover" KBSwitchoverCandidateInstanceForAnyPod = "*" KBSwitchoverDoNCheckRoleChangeKey = "DoSwitchoverAndCheckRoleChange" )
switchover constants
const ( // VolumeExpansionTimeOut volume expansion timeout. VolumeExpansionTimeOut = 30 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func DequeueOpsRequestInClusterAnnotation ¶
func DequeueOpsRequestInClusterAnnotation(ctx context.Context, cli client.Client, opsRes *OpsResource) error
DequeueOpsRequestInClusterAnnotation when OpsRequest.status.phase is Succeeded or Failed we should remove the OpsRequest Annotation of cluster, then unlock cluster
func GetOpsRecorderFromSlice ¶
func GetOpsRecorderFromSlice(opsRequestSlice []opsv1alpha1.OpsRecorder, opsRequestName string) (int, opsv1alpha1.OpsRecorder)
GetOpsRecorderFromSlice gets OpsRequest recorder from slice by target cluster phase
func PatchClusterNotFound ¶
PatchClusterNotFound patches ClusterNotFound condition to the OpsRequest.status.conditions.
func PatchOpsHandlerNotSupported ¶
PatchOpsHandlerNotSupported patches OpsNotSupported condition to the OpsRequest.status.conditions.
func PatchOpsStatus ¶
func PatchOpsStatus(ctx context.Context, cli client.Client, opsRes *OpsResource, phase opsv1alpha1.OpsPhase, condition ...*metav1.Condition) error
PatchOpsStatus patches OpsRequest.status
func PatchOpsStatusWithOpsDeepCopy ¶
func PatchOpsStatusWithOpsDeepCopy(ctx context.Context, cli client.Client, opsRes *OpsResource, opsRequestDeepCopy *opsv1alpha1.OpsRequest, phase opsv1alpha1.OpsPhase, condition ...*metav1.Condition) error
PatchOpsStatusWithOpsDeepCopy patches OpsRequest.status with the deepCopy opsRequest.
Types ¶
type BackupOpsHandler ¶
type BackupOpsHandler struct{}
func (BackupOpsHandler) Action ¶
func (b BackupOpsHandler) Action(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
Action implements the backup action. It will create a backup resource for cluster.
func (BackupOpsHandler) ActionStartedCondition ¶
func (b BackupOpsHandler) ActionStartedCondition(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (*metav1.Condition, error)
ActionStartedCondition the started condition when handling the backup request.
func (BackupOpsHandler) ReconcileAction ¶
func (b BackupOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (opsv1alpha1.OpsPhase, time.Duration, error)
ReconcileAction implements the backup reconcile action. It will check the backup status and update the OpsRequest status. If the backup is completed, it will return OpsSuccess If the backup is failed, it will return OpsFailed
func (BackupOpsHandler) SaveLastConfiguration ¶
func (b BackupOpsHandler) SaveLastConfiguration(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
SaveLastConfiguration records last configuration to the OpsRequest.status.lastConfiguration
type ComponentOpsInterface ¶
type ComponentOpsInterface interface {
GetComponentName() string
}
type CustomOpsHandler ¶
type CustomOpsHandler struct{}
func (CustomOpsHandler) Action ¶
func (c CustomOpsHandler) Action(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
func (CustomOpsHandler) ActionStartedCondition ¶
func (c CustomOpsHandler) ActionStartedCondition(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (*metav1.Condition, error)
ActionStartedCondition the started condition when handling the stop request.
func (CustomOpsHandler) ReconcileAction ¶
func (c CustomOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (opsv1alpha1.OpsPhase, time.Duration, error)
ReconcileAction will be performed when action is done and loops till OpsRequest.status.phase is Succeed/Failed. the Reconcile function for stop opsRequest.
func (CustomOpsHandler) SaveLastConfiguration ¶
func (c CustomOpsHandler) SaveLastConfiguration(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
SaveLastConfiguration records last configuration to the OpsRequest.status.lastConfiguration
type ExposeOpsHandler ¶
type ExposeOpsHandler struct { }
func (ExposeOpsHandler) Action ¶
func (e ExposeOpsHandler) Action(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
func (ExposeOpsHandler) ActionStartedCondition ¶
func (e ExposeOpsHandler) ActionStartedCondition(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (*metav1.Condition, error)
func (ExposeOpsHandler) ReconcileAction ¶
func (e ExposeOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsResource *OpsResource) (opsv1alpha1.OpsPhase, time.Duration, error)
func (ExposeOpsHandler) SaveLastConfiguration ¶
func (e ExposeOpsHandler) SaveLastConfiguration(reqCtx intctrlutil.RequestCtx, cli client.Client, opsResource *OpsResource) error
type OpsBehaviour ¶
type OpsBehaviour struct { FromClusterPhases []appsv1.ClusterPhase // ToClusterPhase indicates that the cluster will enter this phase during the operation. // All opsRequest with ToClusterPhase are mutually exclusive. ToClusterPhase appsv1.ClusterPhase // CancelFunc this function defines the cancel action and does not patch/update the opsRequest by client-go in here. // only update the opsRequest object, then opsRequest controller will update uniformly. CancelFunc func(reqCtx intctrlutil.RequestCtx, cli client.Client, opsResource *OpsResource) error // IsClusterCreation indicates whether the opsRequest will create a new cluster. IsClusterCreation bool // QueueByCluster indicates that the operation is queued for execution within the cluster-wide scope. QueueByCluster bool // QueueWithSelf indicates that the operation is queued for execution within opsType scope. QueueBySelf bool OpsHandler OpsHandler }
type OpsHandler ¶
type OpsHandler interface { // Action The action duration should be short. if it fails, it will be reconciled by the OpsRequest controller. // Do not patch OpsRequest status in this function with k8s client, just modify the status of ops. // The opsRequest controller will patch it to the k8s apiServer. Action(reqCtx intctrlutil.RequestCtx, cli client.Client, opsResource *OpsResource) error // ReconcileAction loops till the operation is completed. // return OpsRequest.status.phase and requeueAfter time. ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsResource *OpsResource) (opsv1alpha1.OpsPhase, time.Duration, error) // ActionStartedCondition appends to OpsRequest.status.conditions when start performing Action function ActionStartedCondition(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (*metav1.Condition, error) // SaveLastConfiguration saves last configuration to the OpsRequest.status.lastConfiguration, // and this method will be executed together when opsRequest in running. SaveLastConfiguration(reqCtx intctrlutil.RequestCtx, cli client.Client, opsResource *OpsResource) error }
type OpsManager ¶
type OpsManager struct {
OpsMap map[opsv1alpha1.OpsType]OpsBehaviour
}
func GetOpsManager ¶
func GetOpsManager() *OpsManager
func (*OpsManager) Do ¶
func (opsMgr *OpsManager) Do(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (*ctrl.Result, error)
Do the entry function for handling OpsRequest
func (*OpsManager) Reconcile ¶
func (opsMgr *OpsManager) Reconcile(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (time.Duration, error)
Reconcile entry function when OpsRequest.status.phase is Running. loops till the operation is completed.
func (*OpsManager) RegisterOps ¶
func (opsMgr *OpsManager) RegisterOps(opsType opsv1alpha1.OpsType, opsBehaviour OpsBehaviour)
RegisterOps registers operation with OpsType and OpsBehaviour
type OpsResource ¶
type OpsResource struct { OpsDef *opsv1alpha1.OpsDefinition OpsRequest *opsv1alpha1.OpsRequest Cluster *appsv1.Cluster Recorder record.EventRecorder ToClusterPhase appsv1.ClusterPhase }
type RestoreOpsHandler ¶
type RestoreOpsHandler struct{}
func (RestoreOpsHandler) Action ¶
func (r RestoreOpsHandler) Action(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
Action implements the restore action.
func (RestoreOpsHandler) ActionStartedCondition ¶
func (r RestoreOpsHandler) ActionStartedCondition(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (*metav1.Condition, error)
ActionStartedCondition the started condition when handling the restore request.
func (RestoreOpsHandler) ReconcileAction ¶
func (r RestoreOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (opsv1alpha1.OpsPhase, time.Duration, error)
ReconcileAction implements the restore action. It will check the cluster status and update the OpsRequest status. If the cluster is running, it will update the OpsRequest status to Complete. If the cluster is failed, it will update the OpsRequest status to Failed. If the cluster is not running, it will update the OpsRequest status to Running.
func (RestoreOpsHandler) SaveLastConfiguration ¶
func (r RestoreOpsHandler) SaveLastConfiguration(reqCtx intctrlutil.RequestCtx, cli client.Client, opsResource *OpsResource) error
SaveLastConfiguration saves last configuration to the OpsRequest.status.lastConfiguration
type StartOpsHandler ¶
type StartOpsHandler struct{}
func (StartOpsHandler) Action ¶
func (start StartOpsHandler) Action(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
Action modifies Cluster.spec.components[*].replicas from the opsRequest
func (StartOpsHandler) ActionStartedCondition ¶
func (start StartOpsHandler) ActionStartedCondition(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (*metav1.Condition, error)
ActionStartedCondition the started condition when handling the start request.
func (StartOpsHandler) ReconcileAction ¶
func (start StartOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (opsv1alpha1.OpsPhase, time.Duration, error)
ReconcileAction will be performed when action is done and loops till OpsRequest.status.phase is Succeed/Failed. the Reconcile function for start opsRequest.
func (StartOpsHandler) SaveLastConfiguration ¶
func (start StartOpsHandler) SaveLastConfiguration(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
SaveLastConfiguration records last configuration to the OpsRequest.status.lastConfiguration
type StopOpsHandler ¶
type StopOpsHandler struct{}
func (StopOpsHandler) Action ¶
func (stop StopOpsHandler) Action(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
Action modifies Cluster.spec.components[*].replicas from the opsRequest
func (StopOpsHandler) ActionStartedCondition ¶
func (stop StopOpsHandler) ActionStartedCondition(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (*metav1.Condition, error)
ActionStartedCondition the started condition when handling the stop request.
func (StopOpsHandler) ReconcileAction ¶
func (stop StopOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (opsv1alpha1.OpsPhase, time.Duration, error)
ReconcileAction will be performed when action is done and loops till OpsRequest.status.phase is Succeed/Failed. the Reconcile function for stop opsRequest.
func (StopOpsHandler) SaveLastConfiguration ¶
func (stop StopOpsHandler) SaveLastConfiguration(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error
SaveLastConfiguration records last configuration to the OpsRequest.status.lastConfiguration
type SwitchoverMessage ¶
type SwitchoverMessage struct { opsv1alpha1.Switchover OldPrimary string Cluster string }
SwitchoverMessage is the OpsRequest.Status.Condition.Message for switchover.
type WaitForClusterPhaseErr ¶
type WaitForClusterPhaseErr struct {
// contains filtered or unexported fields
}
func (*WaitForClusterPhaseErr) Error ¶
func (e *WaitForClusterPhaseErr) Error() string
type WorkflowContext ¶
type WorkflowContext struct { Cli client.Client OpsRes *OpsResource // contains filtered or unexported fields }
func NewWorkflowContext ¶
func NewWorkflowContext( ctx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) *WorkflowContext
func (*WorkflowContext) Run ¶
func (w *WorkflowContext) Run(compCustomSpec *opsv1alpha1.CustomOpsComponent) (*WorkflowStatus, error)
Run actions execution layer.
type WorkflowStatus ¶
Source Files ¶
- backup.go
- custom.go
- custom_workflow.go
- expose.go
- horizontal_scaling.go
- ops_comp_helper.go
- ops_manager.go
- ops_progress_util.go
- ops_util.go
- queue_util.go
- rebuild_instance.go
- rebuild_instance_inplace.go
- reconfigure.go
- reconfigure_pipeline.go
- reconfigure_util.go
- restart.go
- restore.go
- start.go
- stop.go
- switchover.go
- switchover_util.go
- type.go
- upgrade.go
- vertical_scaling.go
- volume_expansion.go