Avoid adding duplicate volume to restore status
@@ -279,16 +279,18 @@ func initRestoreVolumesInfo(snapshotList []*snap_v1.VolumeSnapshot, snapRestore
if err != nil {
return fmt.Errorf("failed to get pvc details for snapshot %v", err)
}
-
volInfo := &stork_api.RestoreVolumeInfo{}
// check whether we have volInfo already processed for given
// pvc. If so update existing vol info
+ isPresent := false
for _, vol := range snapRestore.Status.Volumes {
- if pvc.Spec.VolumeName == vol.PVC {
+ if pvc.Name == vol.PVC {
volInfo = vol
+ isPresent = true
break
}
}
+ if !isPresent {
volInfo.Volume = pvc.Spec.VolumeName
volInfo.PVC = pvc.Name
volInfo.Namespace = pvc.Namespace
@@ -296,7 +298,7 @@ func initRestoreVolumesInfo(snapshotList []*snap_v1.VolumeSnapshot, snapRestore
volInfo.RestoreStatus = stork_api.VolumeSnapshotRestoreStatusInitial
snapRestore.Status.Volumes = append(snapRestore.Status.Volumes, volInfo)
}
-
+ }
return nil
}
