From 671d6a77679771bca714c7a2efe2d6799acd7fb8 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Sat, 5 Jun 2021 10:59:50 -0400 Subject: [PATCH] rbd: Backout if image features is empty In golang world, if you split an empty string that does not contain the seperator, you get an array with one empty string. This results in volumes failing to mount with "invalid feature " (note extra space because it's trying to check if 'empty string' is a valid feature). This patch checks if the string is empty, and if so, it just decides to skip the entire validation and returning nothing. Signed-off-by: Mohammed Naser --- internal/rbd/rbd_util.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index c11c6468b..0053c76ed 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -993,6 +993,13 @@ func genVolFromVolumeOptions(ctx context.Context, volOptions, credentials map[st } func (rv *rbdVolume) validateImageFeatures(imageFeatures string) error { + // It is possible for image features to be an empty string which + // the Go split function would return a single item array with + // an empty string, causing a failure when trying to validate + // the features. + if strings.TrimSpace(imageFeatures) == "" { + return nil + } arr := strings.Split(imageFeatures, ",") featureSet := sets.NewString(arr...) for _, f := range arr {