Skip to content

Commit bf65357

Browse files
authored
Merge pull request #278 from huffmanca/check_nil_content
Include a nil check for the snapshotContent
2 parents 2890f4a + 806ccc0 commit bf65357

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pkg/common-controller/snapshot_controller.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323

2424
crdv1 "github.com/kubernetes-csi/external-snapshotter/v2/pkg/apis/volumesnapshot/v1beta1"
2525
"github.com/kubernetes-csi/external-snapshotter/v2/pkg/utils"
26-
"k8s.io/api/core/v1"
26+
v1 "k8s.io/api/core/v1"
2727
storagev1 "k8s.io/api/storage/v1"
2828
apierrs "k8s.io/apimachinery/pkg/api/errors"
2929
"k8s.io/apimachinery/pkg/api/resource"
@@ -266,7 +266,7 @@ func (ctrl *csiSnapshotCommonController) checkandRemoveSnapshotFinalizersAndChec
266266
}
267267

268268
if !inUse {
269-
klog.V(5).Infof("checkandRemoveSnapshotFinalizersAndCheckandDeleteContent: Set VolumeSnapshotBeingDeleted annotation on the content [%s]", content.Name)
269+
klog.V(5).Infof("checkandRemoveSnapshotFinalizersAndCheckandDeleteContent: Set VolumeSnapshotBeingDeleted annotation on the content")
270270
ctrl.setAnnVolumeSnapshotBeingDeleted(content)
271271

272272
klog.V(5).Infof("checkandRemoveSnapshotFinalizersAndCheckandDeleteContent: Remove Finalizer for VolumeSnapshot[%s]", utils.SnapshotKey(snapshot))
@@ -1281,6 +1281,9 @@ func (ctrl *csiSnapshotCommonController) getSnapshotFromStore(snapshotName strin
12811281
func (ctrl *csiSnapshotCommonController) setAnnVolumeSnapshotBeingDeleted(content *crdv1.VolumeSnapshotContent) error {
12821282
// Set AnnVolumeSnapshotBeingDeleted if it is not set yet
12831283
if !metav1.HasAnnotation(content.ObjectMeta, utils.AnnVolumeSnapshotBeingDeleted) {
1284+
if content == nil {
1285+
return nil
1286+
}
12841287
klog.V(5).Infof("setAnnVolumeSnapshotBeingDeleted: set annotation [%s] on content [%s].", utils.AnnVolumeSnapshotBeingDeleted, content.Name)
12851288
metav1.SetMetaDataAnnotation(&content.ObjectMeta, utils.AnnVolumeSnapshotBeingDeleted, "yes")
12861289

0 commit comments

Comments
 (0)