Skip to content

Commit b906618

Browse files
authored
Merge pull request #1067 from leonardoce/dev/avoid-panic
Avoid panicking when snapshotting a non-CSI PV
2 parents c18ccb3 + 1192179 commit b906618

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/common-controller/groupsnapshot_controller_helper.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,19 @@ func (ctrl *csiSnapshotCommonController) createGroupSnapshotContent(groupSnapsho
754754
}
755755
var volumeHandles []string
756756
for _, pv := range volumes {
757+
if pv.Spec.CSI == nil {
758+
err := fmt.Errorf(
759+
"cannot snapshot a non-CSI volume for group snapshot %s: %s",
760+
utils.GroupSnapshotKey(groupSnapshot), pv.Name)
761+
klog.Error(err.Error())
762+
ctrl.eventRecorder.Event(
763+
groupSnapshot,
764+
v1.EventTypeWarning,
765+
"CreateGroupSnapshotContentFailed",
766+
fmt.Sprintf("Cannot snapshot a non-CSI volume: %s", pv.Name),
767+
)
768+
return nil, err
769+
}
757770
volumeHandles = append(volumeHandles, pv.Spec.CSI.VolumeHandle)
758771
}
759772

0 commit comments

Comments
 (0)