Skip to content

Commit

Permalink
Do not panic when a default snapshotclass does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardoce committed Nov 22, 2024
1 parent 07425bd commit a12d2b5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/sidecar-controller/snapshot_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ func (ctrl *csiSnapshotSideCarController) checkandUpdateContentStatusOperation(c
var groupSnapshotID string
var snapshotterListCredentials map[string]string

volumeGroupSnapshotMember := content.Status != nil && content.Status.VolumeGroupSnapshotHandle != nil
volumeGroupSnapshotMemberWithGroupSnapshotHandle := content.Status != nil && content.Status.VolumeGroupSnapshotHandle != nil

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

if content.Spec.VolumeSnapshotClassName != nil {
Expand Down Expand Up @@ -315,7 +315,13 @@ func (ctrl *csiSnapshotSideCarController) checkandUpdateContentStatusOperation(c
}
return updatedContent, nil
}
return ctrl.createSnapshotWrapper(content)

_, groupSnapshotMember := content.Labels[utils.VolumeGroupSnapshotHandleLabel]
if !groupSnapshotMember {
return ctrl.createSnapshotWrapper(content)
}

return content, nil
}

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

0 comments on commit a12d2b5

Please sign in to comment.