From 30f9edd71f44854dbbba2927f8113bef14b42c7a Mon Sep 17 00:00:00 2001 From: Pallav Date: Fri, 5 Jul 2024 12:59:49 +0000 Subject: [PATCH] Fix Handling of Cloud Based CSI Backups - NFS Location --- pkg/executor/nfs/nfsrestoreresources.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/executor/nfs/nfsrestoreresources.go b/pkg/executor/nfs/nfsrestoreresources.go index c92143f7..de0efaa4 100644 --- a/pkg/executor/nfs/nfsrestoreresources.go +++ b/pkg/executor/nfs/nfsrestoreresources.go @@ -383,7 +383,7 @@ func getPVCToPVMapping(allObjects []runtime.Unstructured) (map[string]*v1.Persis return pvcNameToPV, nil } -func isGenericCSIPersistentVolume(pv *v1.PersistentVolume) (bool, error) { +func isGenericCSIPersistentVolume(pv *v1.PersistentVolume, volInfos []*storkapi.ApplicationRestoreVolumeInfo) (bool, error) { driverName, err := volume.GetPVDriverForRestore(pv) if err != nil { return false, err @@ -391,6 +391,12 @@ func isGenericCSIPersistentVolume(pv *v1.PersistentVolume) (bool, error) { if driverName == "csi" { return true, nil } + // in case of cloud disk such as GCE, AWS, Azure, we need to skip the volumes as its now moved to csi + for _, vInfo := range volInfos { + if vInfo.RestoreVolume == pv.Name && vInfo.DriverName == "csi" { + return true, nil + } + } return false, nil } func isGenericPersistentVolume(pv *v1.PersistentVolume, volInfos []*storkapi.ApplicationRestoreVolumeInfo) (bool, error) { @@ -436,7 +442,7 @@ func removeCSIVolumesBeforeApply( } // Check if this PV is a generic CSI one - isGenericCSIPVC, err := isGenericCSIPersistentVolume(&pv) + isGenericCSIPVC, err := isGenericCSIPersistentVolume(&pv, restore.Status.Volumes) if err != nil { return nil, fmt.Errorf("failed to check if PV was provisioned by a CSI driver: %v", err) } @@ -468,7 +474,7 @@ func removeCSIVolumesBeforeApply( // We have found a PV for this PVC. Check if it is a generic CSI PV // that we do not already have native volume driver support for. - isGenericCSIPVC, err := isGenericCSIPersistentVolume(pv) + isGenericCSIPVC, err := isGenericCSIPersistentVolume(pv, restore.Status.Volumes) if err != nil { return nil, err }