restore

package
v0.7.0-beta.9 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: AGPL-3.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// condition types
	ConditionTypeRestoreValidationPassed = "ValidationPassed"
	ConditionTypeRestorePreparedData     = "PrepareData"
	ConditionTypeReadinessProbe          = "ReadinessProbe"
	ConditionTypeRestorePostReady        = "PostReady"

	// condition reasons
	ReasonRestoreStarting      = "RestoreStarting"
	ReasonRestoreCompleted     = "RestoreCompleted"
	ReasonRestoreFailed        = "RestoreFailed"
	ReasonValidateFailed       = "ValidateFailed"
	ReasonValidateSuccessfully = "ValidateSuccessfully"
	ReasonProcessing           = "Processing"
	ReasonFailed               = "Failed"
	ReasonSucceed              = "Succeed"
)

Restore condition constants

View Source
const (
	DataProtectionLabelRestoreKey     = "dataprotection.kubeblocks.io/restore"
	DataProtectionLabelPopulatePVCKey = "dataprotection.kubeblocks.io/populate-pvc"
)

labels key

View Source
const (
	DPRestoreTime      = "DP_RESTORE_TIME"
	DPRestoreTimestamp = "DP_RESTORE_TIMESTAMP"
)
View Source
const Restore = "restore"

Restore constant

Variables

View Source
var VolumeSnapshotGroup = "snapshot.storage.k8s.io"

Functions

func BuildRestoreLabels

func BuildRestoreLabels(restoreName string) map[string]string

func CheckJobDone

func CheckJobDone(job *batchv1.Job) (bool, error)

CheckJobDone if the job is completed or failed, return true. if the job is failed, return an error to describe the failed message.

func GetRestoreActionsCountForPrepareData

func GetRestoreActionsCountForPrepareData(config *dpv1alpha1.PrepareDataConfig) int

func GetRestoreDuration

func GetRestoreDuration(status dpv1alpha1.RestoreStatus) *metav1.Duration

func SetRestoreCondition

func SetRestoreCondition(restore *dpv1alpha1.Restore, status metav1.ConditionStatus, conditionType, reason, message string)

func SetRestoreStageCondition

func SetRestoreStageCondition(restore *dpv1alpha1.Restore, stage dpv1alpha1.RestoreStage, reason, message string)

SetRestoreStageCondition sets restore stage condition.

func SetRestoreStatusAction

func SetRestoreStatusAction(actions *[]dpv1alpha1.RestoreStatusAction,
	statusAction dpv1alpha1.RestoreStatusAction)

func SetRestoreValidationCondition

func SetRestoreValidationCondition(restore *dpv1alpha1.Restore, reason, message string)

SetRestoreValidationCondition sets restore condition which type is ConditionTypeRestoreValidationPassed.

func ValidateAndInitRestoreMGR

func ValidateAndInitRestoreMGR(reqCtx intctrlutil.RequestCtx,
	cli client.Client,
	recorder record.EventRecorder,
	restoreMgr *RestoreManager) error

ValidateAndInitRestoreMGR validate if the restore CR is valid and init the restore manager.

Types

type BackupActionSet

type BackupActionSet struct {
	Backup            *dpv1alpha1.Backup
	ActionSet         *dpv1alpha1.ActionSet
	UseVolumeSnapshot bool
}

type RestoreManager

type RestoreManager struct {
	OriginalRestore       *dpv1alpha1.Restore
	Restore               *dpv1alpha1.Restore
	PrepareDataBackupSets []BackupActionSet
	PostReadyBackupSets   []BackupActionSet
	Schema                *runtime.Scheme
	Recorder              record.EventRecorder
}

func NewRestoreManager

func NewRestoreManager(restore *dpv1alpha1.Restore, recorder record.EventRecorder, schema *runtime.Scheme) *RestoreManager

func (*RestoreManager) AnalysisRestoreActionsWithBackup

func (r *RestoreManager) AnalysisRestoreActionsWithBackup(stage dpv1alpha1.RestoreStage, backupName string, actionName string) (bool, bool)

AnalysisRestoreActionsWithBackup analysis the restore actions progress group by backup. check if the restore jobs are completed or failed or processing.

func (*RestoreManager) BuildDifferentialBackupActionSets

func (r *RestoreManager) BuildDifferentialBackupActionSets(reqCtx intctrlutil.RequestCtx, cli client.Client, sourceBackupSet BackupActionSet) error

BuildDifferentialBackupActionSets builds the backupActionSets for specified incremental backup.

func (*RestoreManager) BuildIncrementalBackupActionSets

func (r *RestoreManager) BuildIncrementalBackupActionSets(reqCtx intctrlutil.RequestCtx, cli client.Client, sourceBackupSet BackupActionSet) error

BuildIncrementalBackupActionSets builds the backupActionSets for specified incremental backup.

func (*RestoreManager) BuildPostReadyActionJobs

func (r *RestoreManager) BuildPostReadyActionJobs(reqCtx intctrlutil.RequestCtx, cli client.Client, backupSet BackupActionSet, step int) ([]*batchv1.Job, error)

BuildPostReadyActionJobs builds the post ready jobs.

func (*RestoreManager) BuildPrepareDataJobs

func (r *RestoreManager) BuildPrepareDataJobs(reqCtx intctrlutil.RequestCtx, cli client.Client, backupSet BackupActionSet, actionName string) ([]*batchv1.Job, error)

BuildPrepareDataJobs builds the restore jobs for prepare pvc's data, and will create the target pvcs if not exist.

func (*RestoreManager) BuildVolumePopulateJob

func (r *RestoreManager) BuildVolumePopulateJob(
	reqCtx intctrlutil.RequestCtx,
	cli client.Client,
	backupSet BackupActionSet,
	populatePVC *corev1.PersistentVolumeClaim,
	index int) (*batchv1.Job, error)

func (*RestoreManager) CheckJobsDone

func (r *RestoreManager) CheckJobsDone(
	stage dpv1alpha1.RestoreStage,
	actionName string,
	backupSet BackupActionSet,
	fetchedJobs []*batchv1.Job) (bool, bool)

CheckJobsDone checks if jobs are completed or failed.

func (*RestoreManager) CreateJobsIfNotExist

func (r *RestoreManager) CreateJobsIfNotExist(reqCtx intctrlutil.RequestCtx,
	cli client.Client,
	ownerObj client.Object,
	objs []*batchv1.Job) ([]*batchv1.Job, error)

CreateJobsIfNotExist creates the jobs if not exist.

func (*RestoreManager) GetBackupActionSetByNamespaced

func (r *RestoreManager) GetBackupActionSetByNamespaced(reqCtx intctrlutil.RequestCtx,
	cli client.Client,
	backupName,
	namespace string) (*BackupActionSet, error)

GetBackupActionSetByNamespaced gets the BackupActionSet by name and namespace of backup.

func (*RestoreManager) Recalculation

func (r *RestoreManager) Recalculation(backupName, actionName string, allActionsFinished, existFailedAction *bool)

Recalculation whether all actions have been completed.

func (*RestoreManager) RestorePVCFromSnapshot

func (r *RestoreManager) RestorePVCFromSnapshot(reqCtx intctrlutil.RequestCtx, cli client.Client, backupSet BackupActionSet) error

func (*RestoreManager) SetBackupSets

func (r *RestoreManager) SetBackupSets(backupSets ...BackupActionSet)

Jump to

Keyboard shortcuts

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