Skip to content

Commit 5d9078b

Browse files
committed
Squashed commit of the following:
commit 92aa40e Author: weizhichen <[email protected]> Date: Fri Mar 24 00:38:44 2023 +0000 fix ut commit f1238c6 Author: weizhichen <[email protected]> Date: Wed Mar 22 07:57:01 2023 +0000 fix ut commit 114cdaf Author: weizhichen <[email protected]> Date: Wed Mar 22 07:46:33 2023 +0000 fix ut commit 67440cd Author: weizhichen <[email protected]> Date: Wed Mar 22 07:14:27 2023 +0000 fix gomod commit a2144d9 Author: weizhichen <[email protected]> Date: Wed Mar 22 07:08:42 2023 +0000 fix ut commit 411a3d4 Author: weizhichen <[email protected]> Date: Wed Mar 22 06:46:53 2023 +0000 fix commit 7c9a5c9 Author: weizhichen <[email protected]> Date: Tue Mar 21 06:31:42 2023 +0000 update vendor commit fcc9364 Author: weizhichen <[email protected]> Date: Tue Mar 21 03:45:44 2023 +0000 fix ut commit 9dcc6fa Author: weizhichen <[email protected]> Date: Mon Mar 20 13:52:54 2023 +0000 fix commit 0900961 Author: weizhichen <[email protected]> Date: Mon Mar 20 11:18:01 2023 +0000 add ut commit cd9c5dd Author: weizhichen <[email protected]> Date: Mon Mar 20 06:08:45 2023 +0000 Revert "fix: add workaround for blobfuse2 mount issue" This reverts commit fa9f8a5. commit 10e8617 Author: weizhichen <[email protected]> Date: Mon Mar 20 06:08:28 2023 +0000 fix : wait for blobfuse2 mount
1 parent 7d925ae commit 5d9078b

File tree

10 files changed

+193
-79
lines changed

10 files changed

+193
-79
lines changed

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/Azure/azure-sdk-for-go v67.3.0+incompatible
77
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0
88
github.com/Azure/go-autorest/autorest v0.11.28
9-
github.com/Azure/go-autorest/autorest/adal v0.9.22
9+
github.com/Azure/go-autorest/autorest/adal v0.9.23
1010
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
1111
github.com/container-storage-interface/spec v1.7.0
1212
github.com/gofrs/uuid v4.2.0+incompatible // indirect
@@ -17,7 +17,7 @@ require (
1717
github.com/onsi/gomega v1.25.0
1818
github.com/pborman/uuid v1.2.0
1919
github.com/pelletier/go-toml v1.9.4
20-
github.com/stretchr/testify v1.8.1
20+
github.com/stretchr/testify v1.8.2
2121
golang.org/x/net v0.7.0
2222
google.golang.org/grpc v1.49.0
2323
google.golang.org/protobuf v1.28.1
@@ -71,7 +71,7 @@ require (
7171
github.com/go-openapi/jsonreference v0.20.0 // indirect
7272
github.com/go-openapi/swag v0.19.14 // indirect
7373
github.com/gogo/protobuf v1.3.2 // indirect
74-
github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
74+
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
7575
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
7676
github.com/google/gnostic v0.5.7-v3refs // indirect
7777
github.com/google/go-cmp v0.5.9 // indirect
@@ -109,7 +109,7 @@ require (
109109
go.opentelemetry.io/otel/sdk v1.10.0 // indirect
110110
go.opentelemetry.io/otel/trace v1.10.0 // indirect
111111
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
112-
golang.org/x/crypto v0.5.0 // indirect
112+
golang.org/x/crypto v0.6.0 // indirect
113113
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
114114
golang.org/x/sys v0.5.0 // indirect
115115
golang.org/x/term v0.5.0 // indirect

go.sum

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSW
5151
github.com/Azure/go-autorest/autorest v0.11.28 h1:ndAExarwr5Y+GaHE6VCaY1kyS/HwwGGyuimVhWsHOEM=
5252
github.com/Azure/go-autorest/autorest v0.11.28/go.mod h1:MrkzG3Y3AH668QyF9KRk5neJnGgmhQ6krbhR8Q5eMvA=
5353
github.com/Azure/go-autorest/autorest/adal v0.9.18/go.mod h1:XVVeme+LZwABT8K5Lc3hA4nAe8LDBVle26gTrguhhPQ=
54-
github.com/Azure/go-autorest/autorest/adal v0.9.22 h1:/GblQdIudfEM3AWWZ0mrYJQSd7JS4S/Mbzh6F0ov0Xc=
55-
github.com/Azure/go-autorest/autorest/adal v0.9.22/go.mod h1:XuAbAEUv2Tta//+voMI038TrJBqjKam0me7qR+L8Cmk=
54+
github.com/Azure/go-autorest/autorest/adal v0.9.23 h1:Yepx8CvFxwNKpH6ja7RZ+sKX+DWYNldbLiALMC3BTz8=
55+
github.com/Azure/go-autorest/autorest/adal v0.9.23/go.mod h1:5pcMqFkdPhviJdlEy3kC/v1ZLnQl0MH6XA5YCcMhy4c=
5656
github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw=
5757
github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74=
5858
github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k=
@@ -184,8 +184,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
184184
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
185185
github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
186186
github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
187-
github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU=
188-
github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
187+
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
188+
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
189189
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
190190
github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
191191
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
@@ -413,8 +413,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
413413
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
414414
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
415415
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
416-
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
417-
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
416+
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
417+
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
418418
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
419419
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
420420
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -464,8 +464,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
464464
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
465465
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
466466
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
467-
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
468-
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
467+
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
468+
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
469469
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
470470
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
471471
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -540,6 +540,7 @@ golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su
540540
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
541541
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
542542
golang.org/x/net v0.3.1-0.20221206200815-1e63c2f08a10/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
543+
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
543544
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
544545
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
545546
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=

pkg/blob/nodeserver.go

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ import (
4646
mount_azure_blob "sigs.k8s.io/blob-csi-driver/pkg/blobfuse-proxy/pb"
4747
)
4848

49+
const (
50+
waitForMountInterval = 20 * time.Millisecond
51+
waitForMountTimeout = 3 * time.Second
52+
)
53+
4954
type MountClient struct {
5055
service mount_azure_blob.MountServiceClient
5156
}
@@ -181,11 +186,7 @@ func (d *Driver) mountBlobfuseInsideDriver(args string, protocol string, authEnv
181186
cmd.Env = append(os.Environ(), authEnv...)
182187
output, err := cmd.CombinedOutput()
183188
klog.V(2).Infof("mount output: %s\n", string(output))
184-
if err == nil && protocol == Fuse2 {
185-
// todo: remove this when https://github.com/Azure/azure-storage-fuse/issues/1079 is fixed
186-
klog.V(2).Infof("sleep 2s, waiting for blobfuse2 mount complete")
187-
time.Sleep(2 * time.Second)
188-
}
189+
189190
return string(output), err
190191
}
191192

@@ -406,6 +407,12 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
406407
return nil, err
407408
}
408409

410+
// wait a few seconds to make sure blobfuse mount is successful
411+
// please refer to https://github.com/Azure/azure-storage-fuse/pull/1088 for more details
412+
if err := waitForMount(targetPath, waitForMountInterval, waitForMountTimeout); err != nil {
413+
return nil, fmt.Errorf("failed to wait for mount: %w", err)
414+
}
415+
409416
klog.V(2).Infof("volume(%s) mount on %q succeeded", volumeID, targetPath)
410417
return &csi.NodeStageVolumeResponse{}, nil
411418
}
@@ -575,3 +582,24 @@ func (d *Driver) ensureMountPoint(target string, perm os.FileMode) (bool, error)
575582
}
576583
return !notMnt, nil
577584
}
585+
586+
func waitForMount(path string, intervel, timeout time.Duration) error {
587+
timeAfter := time.After(timeout)
588+
timeTick := time.Tick(intervel)
589+
590+
for {
591+
select {
592+
case <-timeTick:
593+
notMount, err := mount.New("").IsLikelyNotMountPoint(path)
594+
if err != nil {
595+
return err
596+
}
597+
if !notMount {
598+
klog.V(2).Infof("blobfuse mount at %s success", path)
599+
return nil
600+
}
601+
case <-timeAfter:
602+
return fmt.Errorf("timeout waiting for mount %s", path)
603+
}
604+
}
605+
}

pkg/blob/nodeserver_test.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ import (
2424
"path/filepath"
2525
"reflect"
2626
"runtime"
27+
"strings"
2728
"syscall"
2829
"testing"
30+
"time"
2931

3032
"google.golang.org/grpc"
3133
"google.golang.org/grpc/codes"
@@ -754,3 +756,59 @@ func TestMountBlobfuseInsideDriver(t *testing.T) {
754756
// the error should be of type exec.ExitError
755757
assert.NotNil(t, err)
756758
}
759+
760+
func Test_waitForMount(t *testing.T) {
761+
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
762+
t.Skip("Skipping test on ", runtime.GOOS)
763+
}
764+
765+
tmpDir, err := os.MkdirTemp("", "")
766+
assert.NoError(t, err)
767+
defer os.RemoveAll(tmpDir)
768+
769+
type args struct {
770+
path string
771+
intervel time.Duration
772+
timeout time.Duration
773+
}
774+
775+
tests := []struct {
776+
name string
777+
args args
778+
wantErr bool
779+
subErrMsg string
780+
}{
781+
{
782+
name: "test error timeout",
783+
args: args{
784+
path: tmpDir,
785+
intervel: 1 * time.Millisecond,
786+
timeout: 10 * time.Millisecond,
787+
},
788+
wantErr: true,
789+
subErrMsg: "timeout",
790+
},
791+
{
792+
name: "test error no such file or directory",
793+
args: args{
794+
path: "/no/such/file/or/directory",
795+
intervel: 1 * time.Millisecond,
796+
timeout: 10 * time.Millisecond,
797+
},
798+
wantErr: true,
799+
subErrMsg: "no such file or directory",
800+
},
801+
}
802+
803+
for _, tt := range tests {
804+
t.Run(tt.name, func(t *testing.T) {
805+
err := waitForMount(tt.args.path, tt.args.intervel, tt.args.timeout)
806+
if (err != nil) != tt.wantErr {
807+
t.Errorf("waitForMount() error = %v, wantErr %v", err, tt.wantErr)
808+
}
809+
if err != nil && !strings.Contains(err.Error(), tt.subErrMsg) {
810+
t.Errorf("waitForMount() error = %v, wantErr %v", err, tt.subErrMsg)
811+
}
812+
})
813+
}
814+
}

pkg/blobfuse-proxy/server/server.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"os/exec"
2424
"strings"
2525
"sync"
26-
"time"
2726

2827
"google.golang.org/grpc"
2928
"k8s.io/klog/v2"
@@ -96,11 +95,6 @@ func (server *MountServer) MountAzureBlob(ctx context.Context,
9695
if err != nil {
9796
return &result, fmt.Errorf("%w %s", err, result.Output)
9897
}
99-
if protocol == blob.Fuse2 || server.blobfuseVersion == BlobfuseV2 {
100-
// todo: remove this when https://github.com/Azure/azure-storage-fuse/issues/1079 is fixed
101-
klog.V(2).Infof("sleep 2s, waiting for blobfuse2 mount complete\n")
102-
time.Sleep(2 * time.Second)
103-
}
10498
return &result, nil
10599
}
106100

vendor/github.com/Azure/go-autorest/autorest/adal/token.go

Lines changed: 38 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/golang-jwt/jwt/v4/token.go

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)