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 <mnaser@vexxhost.com>
(cherry picked from commit 671d6a7767)
This commit is contained in:
Mohammed Naser 2021-06-05 10:59:50 -04:00 committed by mergify[bot]
parent f476a376f7
commit 6b86391bb2

View File

@ -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 {