mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-10 00:10:20 +00:00
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>
This commit is contained in:
parent
f193ebfbb1
commit
671d6a7767
@ -993,6 +993,13 @@ func genVolFromVolumeOptions(ctx context.Context, volOptions, credentials map[st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rv *rbdVolume) validateImageFeatures(imageFeatures string) error {
|
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, ",")
|
arr := strings.Split(imageFeatures, ",")
|
||||||
featureSet := sets.NewString(arr...)
|
featureSet := sets.NewString(arr...)
|
||||||
for _, f := range arr {
|
for _, f := range arr {
|
||||||
|
Loading…
Reference in New Issue
Block a user