Skip to content

[release-1.19] fix: mount failure when mountOptions is empty #895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/blob/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ func (d *Driver) mountBlobfuseWithProxy(args string, protocol string, authEnv []
func (d *Driver) mountBlobfuseInsideDriver(args string, protocol string, authEnv []string) (string, error) {
var cmd *exec.Cmd

args = volumehelper.TrimDuplicatedSpace(args)

mountLog := "mount inside driver with"
if protocol == Fuse2 {
mountLog += " v2"
Expand Down
2 changes: 2 additions & 0 deletions pkg/blobfuse-proxy/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ func (server *MountServer) MountAzureBlob(ctx context.Context,
klog.V(2).Infof("append --ignore-open-flags=true to mount args")
args = args + " " + "--ignore-open-flags=true"
}
args = util.TrimDuplicatedSpace(args)
klog.V(2).Infof("mount with v2, protocol: %s, args: %s", protocol, args)
cmd = exec.Command("blobfuse2", strings.Split(args, " ")...)
} else {
args = util.TrimDuplicatedSpace(args)
klog.V(2).Infof("mount with v1, protocol: %s, args: %s", protocol, args)
cmd = exec.Command("blobfuse", strings.Split(args, " ")...)
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package util
import (
"fmt"
"os"
"regexp"
"strings"
"sync"

Expand Down Expand Up @@ -183,3 +184,9 @@ func GetOSInfo(f interface{}) (*OsInfo, error) {
klog.V(2).Infof("get OS info: %v", oi)
return oi, nil
}

func TrimDuplicatedSpace(s string) string {
reg := regexp.MustCompile(`\s+`)
s = reg.ReplaceAllString(s, " ")
return s
}
27 changes: 27 additions & 0 deletions pkg/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,30 @@ func TestGetOSInfo(t *testing.T) {
})
}
}

func TestTrimDuplicatedSpace(t *testing.T) {
type args struct {
s string
}
tests := []struct {
name string
args args
want string
}{
{
// ignore spell lint error
name: "trim duplicated space",
args: args{
s: " 12 3 456 ",
},
want: " 12 3 456 ",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := TrimDuplicatedSpace(tt.args.s); got != tt.want {
t.Errorf("TrimDuplicatedSpace() = %v, want %v", got, tt.want)
}
})
}
}