diff --git a/pkg/controller/util.go b/pkg/controller/util.go index b53fea50b..7666f6019 100644 --- a/pkg/controller/util.go +++ b/pkg/controller/util.go @@ -20,6 +20,7 @@ import ( "encoding/json" "fmt" "regexp" + "strings" "github.com/container-storage-interface/spec/lib/go/csi" "k8s.io/api/core/v1" @@ -190,6 +191,9 @@ func GetVolumeHandle(csiSource *v1.CSIPersistentVolumeSource) (string, bool, err if csiSource == nil { return "", false, fmt.Errorf("csi source was nil") } + if len(strings.TrimSpace(csiSource.VolumeHandle)) == 0 { + return "", false, fmt.Errorf("volume handle was not set") + } return csiSource.VolumeHandle, csiSource.ReadOnly, nil }