Skip to content

Commit

Permalink
Handle potential nil pointer in handleSnapshot
Browse files Browse the repository at this point in the history
If the dataimportcron status has an empty
currentImports, the returned PVC will be nil and
handleSnapshot will be called. handleSnapshot
should check for nil PVC before proceeding.

Signed-off-by: Alexander Wels <awels@redhat.com>
  • Loading branch information
awels authored and kubevirt-bot committed Nov 6, 2024
1 parent 84d1298 commit 17aceaa
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/controller/dataimportcron-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,9 @@ func (r *DataImportCronReconciler) handleCronFormat(ctx context.Context, dataImp
}

func (r *DataImportCronReconciler) handleSnapshot(ctx context.Context, dataImportCron *cdiv1.DataImportCron, pvc *corev1.PersistentVolumeClaim, desiredStorageClass *storagev1.StorageClass) error {
if pvc == nil {
return nil
}
if sc := pvc.Spec.StorageClassName; sc != nil && *sc != desiredStorageClass.Name {
r.log.Info("Attempt to change storage class, will not try making a snapshot of the old PVC")
return nil
Expand Down

0 comments on commit 17aceaa

Please sign in to comment.