From ed28fb3a49ab563826673d4e0f46fc915455398b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wenkai=20Yin=28=E5=B0=B9=E6=96=87=E5=BC=80=29?= Date: Thu, 17 Sep 2026 17:28:15 +0800 Subject: [PATCH] Move falling back full restore logic from PVC CSI RIA to data mover (#10541) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move falling back full restore logic from PVC CSI RIA to data mover Signed-off-by: Wenkai Yin (尹文开) --- config/crd/v2alpha1/bases/velero.io_datadownloads.yaml | 9 +++++++-- pkg/apis/velero/v2alpha1/data_download_types.go | 3 ++- pkg/restore/actions/csi/pvc_action.go | 6 ++---- pkg/restore/actions/csi/pvc_action_test.go | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/config/crd/v2alpha1/bases/velero.io_datadownloads.yaml b/config/crd/v2alpha1/bases/velero.io_datadownloads.yaml index f32bb9563..969815511 100644 --- a/config/crd/v2alpha1/bases/velero.io_datadownloads.yaml +++ b/config/crd/v2alpha1/bases/velero.io_datadownloads.yaml @@ -21,11 +21,16 @@ spec: jsonPath: .status.phase name: Status type: string - - description: Restore type such as Full/Incremental + - description: Requested restore type such as Full/Incremental jsonPath: .spec.restoreType - name: Restore Type + name: Requested Restore Type priority: 10 type: string + - description: Whether the incremental restore has fallen back to full restore + jsonPath: .status.fallbackFull + name: Fallback Full + priority: 10 + type: boolean - description: Time duration since this DataDownload was started jsonPath: .status.startTimestamp name: Started diff --git a/pkg/apis/velero/v2alpha1/data_download_types.go b/pkg/apis/velero/v2alpha1/data_download_types.go index f2be18c57..3b7bcbe38 100644 --- a/pkg/apis/velero/v2alpha1/data_download_types.go +++ b/pkg/apis/velero/v2alpha1/data_download_types.go @@ -162,7 +162,8 @@ type DataDownloadStatus struct { // +kubebuilder:storageversion // +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase",description="DataDownload status such as New/InProgress" // The "Restore Type" column is hidden by default to align with DataUpload. -// +kubebuilder:printcolumn:name="Restore Type",type="string",JSONPath=".spec.restoreType",description="Restore type such as Full/Incremental",priority=10 +// +kubebuilder:printcolumn:name="Requested Restore Type",type="string",JSONPath=".spec.restoreType",description="Requested restore type such as Full/Incremental",priority=10 +// +kubebuilder:printcolumn:name="Fallback Full",type="boolean",JSONPath=".status.fallbackFull",description="Whether the incremental restore has fallen back to full restore",priority=10 // +kubebuilder:printcolumn:name="Started",type="date",JSONPath=".status.startTimestamp",description="Time duration since this DataDownload was started" // +kubebuilder:printcolumn:name="Bytes Done",type="integer",format="int64",JSONPath=".status.progress.bytesDone",description="Completed bytes" // +kubebuilder:printcolumn:name="Total Bytes",type="integer",format="int64",JSONPath=".status.progress.totalBytes",description="Total bytes" diff --git a/pkg/restore/actions/csi/pvc_action.go b/pkg/restore/actions/csi/pvc_action.go index 2546c37a0..7066db062 100644 --- a/pkg/restore/actions/csi/pvc_action.go +++ b/pkg/restore/actions/csi/pvc_action.go @@ -244,7 +244,6 @@ func (p *pvcRestoreItemAction) executeWithDataMove(logger *logrus.Entry, input * var volumeSnapshot *snapshotv1api.VolumeSnapshot cleanUpVolumeSnapshot := false - restoreType := input.Restore.Spec.ExistingVolumeDataPolicy if pvcExists { // Pre-flight checks must pass before any side effect on the existing PVC/PV. if err := inplace.CheckPVCBoundToBackedUpVolume(ctx, p.crClient, existingPVC, pvcFromBackup.Spec.VolumeName, pvc.Annotations[velerov1api.InplaceRestoreVolumeHandleAnnotation], pvcFromBackup.Namespace); err != nil { @@ -264,8 +263,7 @@ func (p *pvcRestoreItemAction) executeWithDataMove(logger *logrus.Entry, input * logger.Info("requesting an in-place incremental restore with block data mover, taking a CSI snapshot of the existing PVC as the baseline of CBT...") volumeSnapshot, err = p.createVolumeSnapshot(ctx, logger, input.Restore, *existingPVC, dataUploadResult.SnapshotClass, input.Restore.Spec.CSISnapshotTimeout.Duration) if err != nil { - logger.Warnf("fail to create VolumeSnapshot for existing PVC %s/%s: %s, fallback to in-place full restore", existingPVC.Namespace, existingPVC.Name, err.Error()) - restoreType = velerov1api.VolumeDataPolicyTypeFull + logger.Warnf("Fail to create VolumeSnapshot for existing PVC %s/%s: %s, incremental restore will be suppressed", existingPVC.Namespace, existingPVC.Name, err.Error()) } else { cleanUpVolumeSnapshot = true defer func() { @@ -304,7 +302,7 @@ func (p *pvcRestoreItemAction) executeWithDataMove(logger *logrus.Entry, input * var dataDownload *velerov2alpha1.DataDownload dataDownload, err = restoreFromDataUploadResult( ctx, dataUploadResult, input.Restore, backup, pvc, existingPV, newNamespace, - operationID, string(restoreType), volumeSnapshot, cleanUpVolumeSnapshot, p.crClient) + operationID, string(input.Restore.Spec.ExistingVolumeDataPolicy), volumeSnapshot, cleanUpVolumeSnapshot, p.crClient) if err != nil { logger.Errorf("Failed to restore from DataUploadResult: %s", err.Error()) return nil, errors.WithStack(err) diff --git a/pkg/restore/actions/csi/pvc_action_test.go b/pkg/restore/actions/csi/pvc_action_test.go index 873f8f30b..cead11b8f 100644 --- a/pkg/restore/actions/csi/pvc_action_test.go +++ b/pkg/restore/actions/csi/pvc_action_test.go @@ -532,7 +532,7 @@ func TestExecute(t *testing.T) { ObjectMeta(builder.WithOwnerReference([]metav1.OwnerReference{{APIVersion: velerov1api.SchemeGroupVersion.String(), Kind: "Restore", Name: "testRestore", UID: "uid", Controller: boolptr.True()}}), builder.WithLabelsMap(map[string]string{velerov1api.AsyncOperationIDLabel: "dd-uid.", velerov1api.RestoreNameLabel: "testRestore", velerov1api.RestoreUIDLabel: "uid"}), builder.WithGenerateName("testRestore-")).Result() - d.Spec.RestoreType = "full" + d.Spec.RestoreType = "incremental" d.Spec.DataMover = "velero-block" return d }(),