From 6a5a13ebcce6c90aedd4f73ee66f2d05b9c760d1 Mon Sep 17 00:00:00 2001 From: Xun Jiang Date: Wed, 19 Jul 2023 21:26:43 +0800 Subject: [PATCH] Resolve conflict with PR #180 plugin workflow determines whether to restore depends on PVC has the VolumeSnapshot annotation, so change to check the annotation from the pvcFromBackup, not the modified pvc. Signed-off-by: Xun Jiang --- .gitignore | 3 ++- internal/restore/pvc_action.go | 2 +- internal/restore/pvc_action_test.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 8d452293..2aef49d5 100644 --- a/.gitignore +++ b/.gitignore @@ -48,4 +48,5 @@ site/vendor .vs -_tiltbuild \ No newline at end of file +_tiltbuild +coverage.out \ No newline at end of file diff --git a/internal/restore/pvc_action.go b/internal/restore/pvc_action.go index a8f1665e..986278da 100644 --- a/internal/restore/pvc_action.go +++ b/internal/restore/pvc_action.go @@ -170,7 +170,7 @@ func (p *PVCRestoreItemAction) Execute(input *velero.RestoreItemActionExecuteInp } logger.Infof("DataDownload %s/%s is created successfully.", dataDownload.Namespace, dataDownload.Name) } else { - volumeSnapshotName, ok := pvc.Annotations[util.VolumeSnapshotLabel] + volumeSnapshotName, ok := pvcFromBackup.Annotations[util.VolumeSnapshotLabel] if !ok { logger.Info("Skipping PVCRestoreItemAction for PVC , PVC does not have a CSI volumesnapshot.") // Make no change in the input PVC. diff --git a/internal/restore/pvc_action_test.go b/internal/restore/pvc_action_test.go index 4c89551c..afc37724 100644 --- a/internal/restore/pvc_action_test.go +++ b/internal/restore/pvc_action_test.go @@ -564,7 +564,7 @@ func TestExecute(t *testing.T) { DataSourceRef(&corev1api.TypedLocalObjectReference{APIGroup: &snapshotv1api.SchemeGroupVersion.Group, Kind: util.VolumeSnapshotKindName, Name: "testVS"}). Result(), vs: builder.ForVolumeSnapshot("velero", "testVS").ObjectMeta(builder.WithAnnotations(util.VolumeSnapshotRestoreSize, "10Gi")).Result(), - expectedPVC: builder.ForPersistentVolumeClaim("velero", "testPVC").ObjectMeta(builder.WithAnnotations("velero.io/volume-snapshot-name", "testVS")).Result(), + expectedPVC: builder.ForPersistentVolumeClaim("velero", "testPVC").Result(), }, { name: "Restore from VolumeSnapshot without volume-snapshot-name annotation",