mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-13 11:34:54 +00:00
Update CRDs and CLI to support in-place restore (#10038)
Update CRDs(Restore, DataDownload, PodVolumeRestore) and restore create CLI to support in-place restore Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>
This commit is contained in:
@@ -46,6 +46,9 @@ type PodVolumeRestoreSpec struct {
|
||||
// SnapshotID is the ID of the volume snapshot to be restored.
|
||||
SnapshotID string `json:"snapshotID"`
|
||||
|
||||
// RestoreType indicates the type of the restore.
|
||||
RestoreType string `json:"restoreType"`
|
||||
|
||||
// SourceNamespace is the original namespace for namaspace mapping.
|
||||
SourceNamespace string `json:"sourceNamespace"`
|
||||
|
||||
|
||||
@@ -113,7 +113,12 @@ type RestoreSpec struct {
|
||||
// ExistingResourcePolicy specifies the restore behavior for the Kubernetes resource to be restored
|
||||
// +optional
|
||||
// +nullable
|
||||
ExistingResourcePolicy PolicyType `json:"existingResourcePolicy,omitempty"`
|
||||
ExistingResourcePolicy ResourcePolicyType `json:"existingResourcePolicy,omitempty"`
|
||||
|
||||
// ExistingVolumeDataPolicy specifies the restore behavior for the volume data to be restored
|
||||
// +optional
|
||||
// +nullable
|
||||
ExistingVolumeDataPolicy VolumeDataPolicyType `json:"existingVolumeDataPolicy,omitempty"`
|
||||
|
||||
// ItemOperationTimeout specifies the time used to wait for RestoreItemAction operations
|
||||
// The default value is 4 hour.
|
||||
@@ -141,6 +146,10 @@ type RestoreSpec struct {
|
||||
UploaderConfig *UploaderConfigForRestore `json:"uploaderConfig,omitempty"`
|
||||
}
|
||||
|
||||
func (r *RestoreSpec) IsVolumeDataInplaceRestore() bool {
|
||||
return r.ExistingVolumeDataPolicy == VolumeDataPolicyTypeFull || r.ExistingVolumeDataPolicy == VolumeDataPolicyTypeIncremental
|
||||
}
|
||||
|
||||
// UploaderConfigForRestore defines the configuration for the restore.
|
||||
type UploaderConfigForRestore struct {
|
||||
// WriteSparseFiles is a flag to indicate whether write files sparsely or not.
|
||||
@@ -150,6 +159,11 @@ type UploaderConfigForRestore struct {
|
||||
// ParallelFilesDownload is the concurrency number setting for restore.
|
||||
// +optional
|
||||
ParallelFilesDownload int `json:"parallelFilesDownload,omitempty"`
|
||||
// DeleteExtraFiles specifies whether to delete the extra files in the target volume that do not exist in the backup.
|
||||
// This setting is only applicable to File System restores (PodVolumeBackup or CSI File System Data Move) and has no effect on Block Data Move restores.
|
||||
// +optional
|
||||
// +nullable
|
||||
DeleteExtraFiles *bool `json:"deleteExtraFiles,omitempty"`
|
||||
}
|
||||
|
||||
// RestoreHooks contains custom behaviors that should be executed during or post restore.
|
||||
@@ -316,13 +330,22 @@ const (
|
||||
// The failing error is recorded in status.FailureReason.
|
||||
RestorePhaseFailed RestorePhase = "Failed"
|
||||
|
||||
// PolicyTypeNone means velero will not overwrite the resource
|
||||
// ResourcePolicyTypeNone means velero will not overwrite the resource
|
||||
// in cluster with the one in backup whether changed/unchanged.
|
||||
PolicyTypeNone PolicyType = "none"
|
||||
ResourcePolicyTypeNone ResourcePolicyType = "none"
|
||||
|
||||
// PolicyTypeUpdate means velero will try to attempt a patch on
|
||||
// ResourcePolicyTypeUpdate means velero will try to attempt a patch on
|
||||
// the changed resources.
|
||||
PolicyTypeUpdate PolicyType = "update"
|
||||
ResourcePolicyTypeUpdate ResourcePolicyType = "update"
|
||||
|
||||
// VolumeDataPolicyTypeNone means velero will skip and not overwrite the volume data if the volume already exists
|
||||
VolumeDataPolicyTypeNone VolumeDataPolicyType = "none"
|
||||
|
||||
// VolumeDataPolicyTypeFull means velero will try to restore the volume data fully if the volume already exists.
|
||||
VolumeDataPolicyTypeFull VolumeDataPolicyType = "full"
|
||||
|
||||
// VolumeDataPolicyTypeIncremental means velero will try to restore the volume data incrementally if the volume already exists.
|
||||
VolumeDataPolicyTypeIncremental VolumeDataPolicyType = "incremental"
|
||||
)
|
||||
|
||||
// RestoreStatus captures the current status of a Velero restore
|
||||
@@ -440,5 +463,8 @@ type RestoreList struct {
|
||||
Items []Restore `json:"items"`
|
||||
}
|
||||
|
||||
// PolicyType helps specify the ExistingResourcePolicy
|
||||
type PolicyType string
|
||||
// ResourcePolicyType helps specify the ExistingResourcePolicy
|
||||
type ResourcePolicyType string
|
||||
|
||||
// VolumeDataPolicyType helps specify the ExistingVolumeDataPolicy
|
||||
type VolumeDataPolicyType string
|
||||
|
||||
@@ -1754,6 +1754,11 @@ func (in *UploaderConfigForRestore) DeepCopyInto(out *UploaderConfigForRestore)
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
if in.DeleteExtraFiles != nil {
|
||||
in, out := &in.DeleteExtraFiles, &out.DeleteExtraFiles
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UploaderConfigForRestore.
|
||||
|
||||
@@ -39,6 +39,14 @@ type DataDownloadSpec struct {
|
||||
// SnapshotID is the ID of the Velero backup snapshot to be restored from.
|
||||
SnapshotID string `json:"snapshotID"`
|
||||
|
||||
// RestoreType indicates the type of the restore.
|
||||
RestoreType string `json:"restoreType"`
|
||||
|
||||
// CSISnapshot provides the information of the CSI snapshot used to do the incremental restore.
|
||||
// +optional
|
||||
// +nullable
|
||||
CSISnapshot *CSISnapshotSpec `json:"csiSnapshot"`
|
||||
|
||||
// SourceNamespace is the original namespace where the volume is backed up from.
|
||||
// It may be different from SourcePVC's namespace if namespace is remapped during restore.
|
||||
SourceNamespace string `json:"sourceNamespace"`
|
||||
|
||||
@@ -86,6 +86,11 @@ func (in *DataDownloadList) DeepCopyObject() runtime.Object {
|
||||
func (in *DataDownloadSpec) DeepCopyInto(out *DataDownloadSpec) {
|
||||
*out = *in
|
||||
out.TargetVolume = in.TargetVolume
|
||||
if in.CSISnapshot != nil {
|
||||
in, out := &in.CSISnapshot, &out.CSISnapshot
|
||||
*out = new(CSISnapshotSpec)
|
||||
**out = **in
|
||||
}
|
||||
if in.DataMoverConfig != nil {
|
||||
in, out := &in.DataMoverConfig, &out.DataMoverConfig
|
||||
*out = make(map[string]string, len(*in))
|
||||
|
||||
Reference in New Issue
Block a user