backuprestore

package
v0.0.0-...-5a6eb71 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OadpPath        = "/opt/OADP"
	OadpRestorePath = OadpPath + "/veleroRestore"
	OadpDpaPath     = OadpPath + "/dpa"
	OadpSecretPath  = OadpPath + "/secret"

	// OadpNs is the namespace used for everything related OADP e.g configsMaps, DataProtectionApplicationm, Restore, etc
	OadpNs = "openshift-adp"
)

Variables

View Source
var (
	DpaGvk     = schema.GroupVersionKind{Group: "oadp.openshift.io", Kind: "DataProtectionApplication", Version: "v1alpha1"}
	DpaGvkList = schema.GroupVersionKind{Group: "oadp.openshift.io", Kind: "DataProtectionApplicationList", Version: "v1alpha1"}
)

Functions

func CreateOrUpdateDataProtectionAppliation

func CreateOrUpdateDataProtectionAppliation(ctx context.Context, dpa *unstructured.Unstructured, c client.Client) error

func CreateOrUpdateSecret

func CreateOrUpdateSecret(ctx context.Context, secret *corev1.Secret, c client.Client) error

func IsBRFailedError

func IsBRFailedError(err error) bool

func IsBRFailedValidationError

func IsBRFailedValidationError(err error) bool

func IsBRStorageBackendUnavailableError

func IsBRStorageBackendUnavailableError(err error) bool

func IsDPAReconciled

func IsDPAReconciled(dpa *unstructured.Unstructured) bool

func ReadOadpDataProtectionApplication

func ReadOadpDataProtectionApplication(dpaYamlDir string) (*unstructured.Unstructured, error)

Types

type BRHandler

type BRHandler struct {
	client.Client
	DynamicClient dynamic.Interface
	Log           logr.Logger
}

BRHandler handles the backup and restore

func (*BRHandler) CheckOadpOperatorAvailability

func (h *BRHandler) CheckOadpOperatorAvailability(ctx context.Context) error

func (*BRHandler) CleanupBackups

func (h *BRHandler) CleanupBackups(ctx context.Context) error

CleanupBackups deletes all backups for this cluster from object storage

func (*BRHandler) CleanupDeleteBackupRequests

func (h *BRHandler) CleanupDeleteBackupRequests(ctx context.Context) error

CleanupDeleteBackupRequests deletes all DeleteBackupRequest for this cluster from object storage

func (*BRHandler) CleanupStaleBackups

func (h *BRHandler) CleanupStaleBackups(ctx context.Context, backups []*velerov1.Backup) error

CleanupStaleBackups checks and deletes if there are any stale Backups (with the same name) that may be available in the object storage but do not belong to this cluster. returns: true if all stale backups have been deleted, error

func (*BRHandler) EnsureOadpConfiguration

func (h *BRHandler) EnsureOadpConfiguration(ctx context.Context) error

EnsureOadpConfiguration ensures the expected OADP configuration is present

func (*BRHandler) ExportOadpConfigurationToDir

func (h *BRHandler) ExportOadpConfigurationToDir(ctx context.Context, toDir, oadpNamespace string) error

ExportOadpConfigurationToDir exports the OADP DataProtectionApplication CR and required storage creds to a given location

func (*BRHandler) ExportRestoresToDir

func (h *BRHandler) ExportRestoresToDir(ctx context.Context, configMaps []lcav1alpha1.ConfigMapRef, toDir string) error

ExportRestoresToDir extracts all restore CRs from oadp configmaps and write them to a given location returns: error

func (*BRHandler) GetSortedBackupsFromConfigmap

func (h *BRHandler) GetSortedBackupsFromConfigmap(ctx context.Context, content []lcav1alpha1.ConfigMapRef) ([][]*velerov1.Backup, error)

GetSortedBackupsFromConfigmap returns a list of sorted backup CRs extracted from configmap

func (*BRHandler) LoadRestoresFromOadpRestorePath

func (h *BRHandler) LoadRestoresFromOadpRestorePath() ([][]*velerov1.Restore, error)

func (*BRHandler) PatchPVsReclaimPolicy

func (h *BRHandler) PatchPVsReclaimPolicy(ctx context.Context) error

PatchPVsReclaimPolicy - when LVMS is configured, we need to patch PVs with Retain as the persistentVolumeReclaimPolicy due to https://github.com/vmware-tanzu/velero/issues/2739.

func (*BRHandler) RestorePVsReclaimPolicy

func (h *BRHandler) RestorePVsReclaimPolicy(ctx context.Context) error

RestorePVsReclaimPolicy restores the persistentVolumeReclaimPolicy field back to its original value, in PVs created by LVMS (this field was updated during pre-pivot by LCA).

func (*BRHandler) StartOrTrackBackup

func (h *BRHandler) StartOrTrackBackup(ctx context.Context, backups []*velerov1.Backup) (*BackupTracker, error)

StartOrTrackBackup start backup or track backup status

func (*BRHandler) StartOrTrackRestore

func (h *BRHandler) StartOrTrackRestore(ctx context.Context, restores []*velerov1.Restore,
) (
	*RestoreTracker, error,
)

StartOrTrackRestore start restore or track restore status

func (*BRHandler) ValidateOadpConfigmaps

func (h *BRHandler) ValidateOadpConfigmaps(ctx context.Context, content []lcav1alpha1.ConfigMapRef) error

type BRStatusError

type BRStatusError struct {
	Type       string
	Reason     string
	ErrMessage string
}

BRStatusError type

func NewBRFailedError

func NewBRFailedError(brType, msg string) *BRStatusError

func NewBRFailedValidationError

func NewBRFailedValidationError(brType, msg string) *BRStatusError

func NewBRStorageBackendUnavailableError

func NewBRStorageBackendUnavailableError(msg string) *BRStatusError

func (*BRStatusError) Error

func (e *BRStatusError) Error() string

type BackupTracker

type BackupTracker struct {
	PendingBackups          []string
	ProgressingBackups      []string
	SucceededBackups        []string
	FailedBackups           []string
	FailedValidationBackups []string
}

type BackuperRestorer

type BackuperRestorer interface {
	CleanupBackups(ctx context.Context) error
	CleanupStaleBackups(ctx context.Context, backups []*velerov1.Backup) error
	CleanupDeleteBackupRequests(ctx context.Context) error
	CheckOadpOperatorAvailability(ctx context.Context) error
	PatchPVsReclaimPolicy(ctx context.Context) error
	RestorePVsReclaimPolicy(ctx context.Context) error
	EnsureOadpConfiguration(ctx context.Context) error
	ExportOadpConfigurationToDir(ctx context.Context, toDir, oadpNamespace string) error
	ExportRestoresToDir(ctx context.Context, configMaps []lcav1alpha1.ConfigMapRef, toDir string) error
	GetSortedBackupsFromConfigmap(ctx context.Context, content []lcav1alpha1.ConfigMapRef) ([][]*velerov1.Backup, error)
	LoadRestoresFromOadpRestorePath() ([][]*velerov1.Restore, error)
	StartOrTrackBackup(ctx context.Context, backups []*velerov1.Backup) (*BackupTracker, error)
	StartOrTrackRestore(ctx context.Context, restores []*velerov1.Restore) (*RestoreTracker, error)
	ValidateOadpConfigmaps(ctx context.Context, content []lcav1alpha1.ConfigMapRef) error
}

BackuperRestorer interface also used for mocks

type ObjMetadata

type ObjMetadata struct {
	Group     string
	Version   string
	Resource  string
	Namespace string
	Name      string
}

type RestoreTracker

type RestoreTracker struct {
	MissingBackups      []string
	PendingRestores     []string
	ProgressingRestores []string
	SucceededRestores   []string
	FailedRestores      []string
}

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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