Skip to content

Commit a12d2b5

Browse files
committed
Do not panic when a default snapshotclass does not exist
1 parent 07425bd commit a12d2b5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pkg/sidecar-controller/snapshot_controller.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ func (ctrl *csiSnapshotSideCarController) checkandUpdateContentStatusOperation(c
263263
var groupSnapshotID string
264264
var snapshotterListCredentials map[string]string
265265

266-
volumeGroupSnapshotMember := content.Status != nil && content.Status.VolumeGroupSnapshotHandle != nil
266+
volumeGroupSnapshotMemberWithGroupSnapshotHandle := content.Status != nil && content.Status.VolumeGroupSnapshotHandle != nil
267267

268-
if content.Spec.Source.SnapshotHandle != nil || (volumeGroupSnapshotMember && content.Status.SnapshotHandle != nil) {
268+
if content.Spec.Source.SnapshotHandle != nil || (volumeGroupSnapshotMemberWithGroupSnapshotHandle && content.Status.SnapshotHandle != nil) {
269269
klog.V(5).Infof("checkandUpdateContentStatusOperation: call GetSnapshotStatus for snapshot content [%s]", content.Name)
270270

271271
if content.Spec.VolumeSnapshotClassName != nil {
@@ -315,7 +315,13 @@ func (ctrl *csiSnapshotSideCarController) checkandUpdateContentStatusOperation(c
315315
}
316316
return updatedContent, nil
317317
}
318-
return ctrl.createSnapshotWrapper(content)
318+
319+
_, groupSnapshotMember := content.Labels[utils.VolumeGroupSnapshotHandleLabel]
320+
if !groupSnapshotMember {
321+
return ctrl.createSnapshotWrapper(content)
322+
}
323+
324+
return content, nil
319325
}
320326

321327
// This is a wrapper function for the snapshot creation process.

0 commit comments

Comments
 (0)