Skip to content

Commit 5bdf2d1

Browse files
authored
Merge pull request #895 from k8s-infra-cherrypick-robot/cherry-pick-893-to-release-1.19
[release-1.19] fix: mount failure when mountOptions is empty
2 parents 1b715ca + 6dee178 commit 5bdf2d1

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

pkg/blob/nodeserver.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ func (d *Driver) mountBlobfuseWithProxy(args string, protocol string, authEnv []
173173
func (d *Driver) mountBlobfuseInsideDriver(args string, protocol string, authEnv []string) (string, error) {
174174
var cmd *exec.Cmd
175175

176+
args = volumehelper.TrimDuplicatedSpace(args)
177+
176178
mountLog := "mount inside driver with"
177179
if protocol == Fuse2 {
178180
mountLog += " v2"

pkg/blobfuse-proxy/server/server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ func (server *MountServer) MountAzureBlob(ctx context.Context,
7676
klog.V(2).Infof("append --ignore-open-flags=true to mount args")
7777
args = args + " " + "--ignore-open-flags=true"
7878
}
79+
args = util.TrimDuplicatedSpace(args)
7980
klog.V(2).Infof("mount with v2, protocol: %s, args: %s", protocol, args)
8081
cmd = exec.Command("blobfuse2", strings.Split(args, " ")...)
8182
} else {
83+
args = util.TrimDuplicatedSpace(args)
8284
klog.V(2).Infof("mount with v1, protocol: %s, args: %s", protocol, args)
8385
cmd = exec.Command("blobfuse", strings.Split(args, " ")...)
8486
}

pkg/util/util.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package util
1919
import (
2020
"fmt"
2121
"os"
22+
"regexp"
2223
"strings"
2324
"sync"
2425

@@ -183,3 +184,9 @@ func GetOSInfo(f interface{}) (*OsInfo, error) {
183184
klog.V(2).Infof("get OS info: %v", oi)
184185
return oi, nil
185186
}
187+
188+
func TrimDuplicatedSpace(s string) string {
189+
reg := regexp.MustCompile(`\s+`)
190+
s = reg.ReplaceAllString(s, " ")
191+
return s
192+
}

pkg/util/util_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,30 @@ func TestGetOSInfo(t *testing.T) {
293293
})
294294
}
295295
}
296+
297+
func TestTrimDuplicatedSpace(t *testing.T) {
298+
type args struct {
299+
s string
300+
}
301+
tests := []struct {
302+
name string
303+
args args
304+
want string
305+
}{
306+
{
307+
// ignore spell lint error
308+
name: "trim duplicated space",
309+
args: args{
310+
s: " 12 3 456 ",
311+
},
312+
want: " 12 3 456 ",
313+
},
314+
}
315+
for _, tt := range tests {
316+
t.Run(tt.name, func(t *testing.T) {
317+
if got := TrimDuplicatedSpace(tt.args.s); got != tt.want {
318+
t.Errorf("TrimDuplicatedSpace() = %v, want %v", got, tt.want)
319+
}
320+
})
321+
}
322+
}

0 commit comments

Comments
 (0)