Skip to content

Commit

Permalink
Merge pull request #387 from portworx/PB-7158
Browse files Browse the repository at this point in the history
PB-7158, PB-7159: Fix Handling of Cloud Based CSI Backups - NFS Location
  • Loading branch information
siva-portworx authored Jul 11, 2024
2 parents 2bf14e1 + 30f9edd commit 63e0fa2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/executor/nfs/nfsrestoreresources.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,20 @@ 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
}
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) {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 63e0fa2

Please sign in to comment.