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 Oct 30, 2024
1 parent c0545b9 commit f1a51c0
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 @@ -686,6 +686,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 f1a51c0

Please sign in to comment.