operations

package
v0.5.2-beta.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2023 License: AGPL-3.0 Imports: 30 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ProcessingReasonHorizontalScaling is the reason of the "OpsRequestProcessed" condition for the horizontal scaling opsRequest processing in cluster.
	ProcessingReasonHorizontalScaling = "HorizontalScaling"
	// ProcessingReasonVerticalScaling is the reason of the "OpsRequestProcessed" condition for the vertical scaling opsRequest processing in cluster.
	ProcessingReasonVerticalScaling = "VerticalScaling"
	// ProcessingReasonVolumeExpanding is the reason of the "OpsRequestProcessed" condition for the volume expansion opsRequest processing in cluster.
	ProcessingReasonVolumeExpanding = "VolumeExpanding"
	// ProcessingReasonStarting is the reason of the "OpsRequestProcessed" condition for the start opsRequest processing in cluster.
	ProcessingReasonStarting = "Starting"
	// ProcessingReasonStopping is the reason of the "OpsRequestProcessed" condition for the stop opsRequest processing in cluster.
	ProcessingReasonStopping = "Stopping"
	// ProcessingReasonRestarting is the reason of the "OpsRequestProcessed" condition for the restart opsRequest processing in cluster.
	ProcessingReasonRestarting = "Restarting"
	// ProcessingReasonReconfiguring is the reason of the "OpsRequestProcessed" condition for the reconfiguration opsRequest processing in cluster.
	ProcessingReasonReconfiguring = "Reconfiguring"
	// ProcessingReasonVersionUpgrading is the reason of the "OpsRequestProcessed" condition for the version upgrade opsRequest processing in cluster.
	ProcessingReasonVersionUpgrading = "VersionUpgrading"
)
View Source
const (
	// PVCEventTimeOut timeout of the pvc event
	PVCEventTimeOut = 30 * time.Second

	// VolumeResizeFailed the event reason of volume resize failed on external-resizer(the csi driver sidecar)
	VolumeResizeFailed = "VolumeResizeFailed"
	// FileSystemResizeFailed the event reason of fileSystem resize failed on kubelet volume manager
	FileSystemResizeFailed = "FileSystemResizeFailed"
)
View Source
const (
	// VolumeExpansionTimeOut volume expansion timeout.
	VolumeExpansionTimeOut = 30 * time.Minute
)

Variables

This section is empty.

Functions

func DeleteOpsRequestAnnotationInCluster

func DeleteOpsRequestAnnotationInCluster(ctx context.Context, cli client.Client, opsRes *OpsResource) error

DeleteOpsRequestAnnotationInCluster when OpsRequest.status.phase is Succeed or Failed we should delete the OpsRequest Annotation in cluster, unlock cluster

func GetOpsRecorderFromSlice

func GetOpsRecorderFromSlice(opsRequestSlice []appsv1alpha1.OpsRecorder,
	opsRequestName string) (int, appsv1alpha1.OpsRecorder)

GetOpsRecorderFromSlice gets OpsRequest recorder from slice by target cluster phase

func PatchClusterNotFound

func PatchClusterNotFound(ctx context.Context, cli client.Client, opsRes *OpsResource) error

PatchClusterNotFound patches ClusterNotFound condition to the OpsRequest.status.conditions.

func PatchOpsStatus

func PatchOpsStatus(ctx context.Context,
	cli client.Client,
	opsRes *OpsResource,
	phase appsv1alpha1.OpsPhase,
	condition ...*metav1.Condition) error

PatchOpsStatus patches OpsRequest.status

Types

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(opsRequest *appsv1alpha1.OpsRequest) *metav1.Condition

func (ExposeOpsHandler) GetRealAffectedComponentMap

func (e ExposeOpsHandler) GetRealAffectedComponentMap(opsRequest *appsv1alpha1.OpsRequest) realAffectedComponentMap

func (ExposeOpsHandler) ReconcileAction

func (e ExposeOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsResource *OpsResource) (appsv1alpha1.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 []appsv1alpha1.ClusterPhase

	// ToClusterPhase indicates that the cluster will enter this phase during the operation.
	ToClusterPhase appsv1alpha1.ClusterPhase

	// MaintainClusterPhaseBySelf indicates whether the operation will maintain cluster/component phase by itself.
	// Generally, the cluster/component phase will be maintained by cluster controller, but if your operation will not update
	// StatefulSet/Deployment by Cluster controller and make pod to rebuilt, you need to maintain the cluster/component phase yourself.
	MaintainClusterPhaseBySelf bool

	// ProcessingReasonInClusterCondition indicates the reason of the condition that type is "OpsRequestProcessed" in Cluster.Status.Conditions and
	// is only valid when ToClusterPhase is not empty. it will indicate what operation the cluster is doing and
	// will be displayed of "kblic cluster list".
	ProcessingReasonInClusterCondition string

	OpsHandler OpsHandler
}

type OpsHandler

type OpsHandler interface {
	// Action The action running time 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 variable of ops.
	// The opsRequest controller will unify the 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) (appsv1alpha1.OpsPhase, time.Duration, error)
	// ActionStartedCondition append to OpsRequest.status.conditions when start performing Action function
	ActionStartedCondition(opsRequest *appsv1alpha1.OpsRequest) *metav1.Condition

	// SaveLastConfiguration saves last configuration to the OpsRequest.status.lastConfiguration,
	// and this method will be executed together when opsRequest to running.
	SaveLastConfiguration(reqCtx intctrlutil.RequestCtx, cli client.Client, opsResource *OpsResource) error

	// GetRealAffectedComponentMap returns a changed configuration componentName map by
	// compared current configuration with the last configuration.
	// we only changed the component status of cluster.status to the ToClusterPhase
	// of OpsBehaviour, which component name is in the returned componentName map.
	// Note: if the operation will not modify the Spec struct of the component workload,
	// GetRealAffectedComponentMap function should return nil unless phase management of cluster and components
	// is implemented at ReconcileAction function.
	GetRealAffectedComponentMap(opsRequest *appsv1alpha1.OpsRequest) realAffectedComponentMap
}

type OpsManager

type OpsManager struct {
	OpsMap map[appsv1alpha1.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 common 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 appsv1alpha1.OpsType, opsBehaviour OpsBehaviour)

RegisterOps register operation with OpsType and OpsBehaviour

type OpsResource

type OpsResource struct {
	OpsRequest     *appsv1alpha1.OpsRequest
	Cluster        *appsv1alpha1.Cluster
	Recorder       record.EventRecorder
	ToClusterPhase appsv1alpha1.ClusterPhase
}

type PersistentVolumeClaimEventHandler

type PersistentVolumeClaimEventHandler struct {
}

func (PersistentVolumeClaimEventHandler) Handle

func (pvcEventHandler PersistentVolumeClaimEventHandler) Handle(cli client.Client,
	reqCtx intctrlutil.RequestCtx,
	recorder record.EventRecorder,
	event *corev1.Event) error

Handle the warning events on pvcs. if the events are resize failed events, update the OpsRequest.status.

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(opsRequest *appsv1alpha1.OpsRequest) *metav1.Condition

ActionStartedCondition the started condition when handling the start request.

func (StartOpsHandler) GetRealAffectedComponentMap

func (start StartOpsHandler) GetRealAffectedComponentMap(opsRequest *appsv1alpha1.OpsRequest) realAffectedComponentMap

GetRealAffectedComponentMap gets the real affected component map for the operation

func (StartOpsHandler) ReconcileAction

func (start StartOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (appsv1alpha1.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(opsRequest *appsv1alpha1.OpsRequest) *metav1.Condition

ActionStartedCondition the started condition when handling the stop request.

func (StopOpsHandler) GetRealAffectedComponentMap

func (stop StopOpsHandler) GetRealAffectedComponentMap(opsRequest *appsv1alpha1.OpsRequest) realAffectedComponentMap

GetRealAffectedComponentMap gets the real affected component map for the operation

func (StopOpsHandler) ReconcileAction

func (stop StopOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (appsv1alpha1.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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL