Skip to content

Commit bf7e4b2

Browse files
authored
fix(vd): correct restoring if original vd was deleted (#2431)
Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>
1 parent 3444525 commit bf7e4b2

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

images/virtualization-artifact/pkg/controller/vd/internal/source/step/create_pvc_from_vdsnapshot_step.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ func (s CreatePVCFromVDSnapshotStep) validateStorageClassCompatibility(ctx conte
281281
var originalPVC corev1.PersistentVolumeClaim
282282
err = s.client.Get(ctx, types.NamespacedName{Name: pvcName, Namespace: vdSnapshot.Namespace}, &originalPVC)
283283
if err != nil {
284+
if k8serrors.IsNotFound(err) {
285+
log.With("pvc.name", pvcName).Debug("Original PVC does not exist, skipping storage class compatibility validation")
286+
return nil
287+
}
284288
return fmt.Errorf("cannot fetch original PVC %q: %w", pvcName, err)
285289
}
286290

images/virtualization-artifact/pkg/controller/vi/internal/source/step/create_pvc_step.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ func (s CreatePersistentVolumeClaimStep) validateStorageClassCompatibility(ctx c
230230
var originalPVC corev1.PersistentVolumeClaim
231231
err = s.client.Get(ctx, types.NamespacedName{Name: pvcName, Namespace: vdSnapshot.Namespace}, &originalPVC)
232232
if err != nil {
233+
if k8serrors.IsNotFound(err) {
234+
log.With("pvc.name", pvcName).Debug("Original PVC does not exist, skipping storage class compatibility validation")
235+
return nil
236+
}
233237
return fmt.Errorf("cannot fetch original PVC %q: %w", pvcName, err)
234238
}
235239

0 commit comments

Comments
 (0)