From 5fa26d0233d53da2cc792bdf332e2e66181bf4d5 Mon Sep 17 00:00:00 2001 From: Leonardo Cecchi Date: Fri, 22 Nov 2024 19:09:48 +0000 Subject: [PATCH] Do not panic when a default snapshotclass does not exist --- pkg/sidecar-controller/snapshot_controller.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/sidecar-controller/snapshot_controller.go b/pkg/sidecar-controller/snapshot_controller.go index 5675a130b..c4059faaa 100644 --- a/pkg/sidecar-controller/snapshot_controller.go +++ b/pkg/sidecar-controller/snapshot_controller.go @@ -339,7 +339,12 @@ func (ctrl *csiSnapshotSideCarController) createSnapshotWrapper(content *crdv1.V return content, fmt.Errorf("failed to add VolumeSnapshotBeingCreated annotation on the content %s: %q", content.Name, err) } - parameters, err := utils.RemovePrefixedParameters(class.Parameters) + var parameters map[string]string + if class != nil { + parameters = class.Parameters + } + + parameters, err = utils.RemovePrefixedParameters(parameters) if err != nil { return content, fmt.Errorf("failed to remove CSI Parameters of prefixed keys: %v", err) }