restore

package
v0.8.3-beta.16 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: AGPL-3.0 Imports: 26 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 (
	DataProtectionRestoreLabelKey          = "dataprotection.kubeblocks.io/restore"
	DataProtectionRestoreNamespaceLabelKey = "dataprotection.kubeblocks.io/restore-namespace"
	DataProtectionPopulatePVCLabelKey      = "dataprotection.kubeblocks.io/populate-pvc"
)

labels key

View Source
const (
	DPRestoreTime              = "DP_RESTORE_TIME"
	DPRestoreTimestamp         = "DP_RESTORE_TIMESTAMP"
	DPBaseBackupStartTime      = "DP_BASE_BACKUP_START_TIME"
	DPBaseBackupStartTimestamp = "DP_BASE_BACKUP_START_TIMESTAMP"
	DPBaseBackupStopTime       = "DP_BASE_BACKUP_STOP_TIME"
	DPBaseBackupStopTimestamp  = "DP_BASE_BACKUP_STOP_TIMESTAMP"
)
View Source
const (
	DataProtectionBackupExtrasLabelKey = "dataprotection.kubeblocks.io/backup-extras"
)

Annotations key

View Source
const Restore = "restore"

Restore constant

Variables

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

Functions

func BuildJobKeyForActionStatus added in v0.8.2

func BuildJobKeyForActionStatus(jobName string) string

func BuildRestoreLabels

func BuildRestoreLabels(restoreName string) map[string]string

func CompareWithBackupStopTime added in v0.7.1

func CompareWithBackupStopTime(backupI, backupJ dpv1alpha1.Backup) bool

func FormatRestoreTimeAndValidate added in v0.8.0

func FormatRestoreTimeAndValidate(restoreTimeStr string, continuousBackup *dpv1alpha1.Backup) (string, error)

func GetRestoreActionsCountForPrepareData

func GetRestoreActionsCountForPrepareData(config *dpv1alpha1.PrepareDataConfig) int

func GetRestoreDuration

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

func GetRestoreFromBackupAnnotation added in v0.8.0

func GetRestoreFromBackupAnnotation(backup *dpv1alpha1.Backup,
	compSpecs []appsv1alpha1.ClusterComponentSpec, volumeRestorePolicy,
	restoreTime string,
	effectiveCommonComponentDef,
	doReadyRestoreAfterClusterRunning bool) (string, error)

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,
	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
	// set it when the backup relies on a base backup, such as Continuous backup
	BaseBackup        *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) BuildContinuousRestoreManager added in v0.8.2

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

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