Skip to content

Commit 28c74e2

Browse files
committed
support blobfuse2
1 parent e49979f commit 28c74e2

34 files changed

+1299
-8
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ require (
3939
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault v1.0.0
4040
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.4.1
4141
github.com/satori/go.uuid v1.2.0
42+
github.com/zcalusic/sysinfo v0.9.5
4243
k8s.io/apiserver v0.25.2
4344
)
4445

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
649649
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
650650
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
651651
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
652+
github.com/zcalusic/sysinfo v0.9.5 h1:ivoHyj9aIAYkwzo1+8QgJ5s4oeE6Etx9FmZtqa4wJjQ=
653+
github.com/zcalusic/sysinfo v0.9.5/go.mod h1:Z/gPVufBrFc8X5sef3m6kkw3r3nlNFp+I6bvASfvBZQ=
652654
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
653655
go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4=
654656
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=

pkg/blob/nodeserver.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,14 @@ func (d *Driver) mountBlobfuseWithProxy(args string, authEnv []string) (string,
166166

167167
func (d *Driver) mountBlobfuseInsideDriver(args string, authEnv []string) (string, error) {
168168
klog.V(2).Infof("mounting blobfuse inside driver")
169-
cmd := exec.Command("blobfuse", strings.Split(args, " ")...)
169+
// TODO: revert to blobfuse
170+
args = "mount " + args
171+
cmd := exec.Command("blobfuse2", strings.Split(args, " ")...)
170172
cmd.Env = append(os.Environ(), authEnv...)
173+
klog.Infof("xxxxxxxxxxxxxxx args %v", args)
174+
klog.Infof("xxxxxxxxxxxxxxx authEnv %v", authEnv)
171175
output, err := cmd.CombinedOutput()
176+
klog.Infof("xxxxxxxxxxxxxxx output %v", string(output))
172177
return string(output), err
173178
}
174179

pkg/blobfuse-proxy/init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ then
3131
cp /blobfuse-proxy/packages-microsoft-prod.deb /host/etc/
3232
$HOST_CMD dpkg -i /etc/packages-microsoft-prod.deb && \
3333
$HOST_CMD apt update && \
34-
$HOST_CMD apt-get install -y fuse blobfuse="${BLOBFUSE_VERSION}" && \
34+
$HOST_CMD apt-get install -y fuse blobfuse2 blobfuse="${BLOBFUSE_VERSION}" && \
3535
$HOST_CMD rm -f /etc/packages-microsoft-prod.deb
3636
fi
3737

pkg/blobfuse-proxy/main.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"k8s.io/klog/v2"
2525

26+
"github.com/zcalusic/sysinfo"
2627
server "sigs.k8s.io/blob-csi-driver/pkg/blobfuse-proxy/server"
2728
csicommon "sigs.k8s.io/blob-csi-driver/pkg/csi-common"
2829
)
@@ -55,10 +56,20 @@ func main() {
5556
klog.Fatal("cannot start server:", err)
5657
}
5758

58-
mountServer := server.NewMountServiceServer()
59+
mountServer := server.NewMountServiceServer(getBlobfuseVersion())
5960

6061
klog.V(2).Info("Listening for connections on address: %v\n", listener.Addr())
6162
if err = server.RunGRPCServer(mountServer, false, listener); err != nil {
6263
klog.Fatalf("Error running grpc server. Error: %v", listener.Addr(), err)
6364
}
6465
}
66+
67+
func getBlobfuseVersion() server.BlobfuseVersion {
68+
var si sysinfo.SysInfo
69+
si.GetSysInfo()
70+
klog.V(2).Infof("OS info: %+v", si.OS)
71+
if si.OS.Vendor == "ubuntu" && si.OS.Release >= "22.04" {
72+
return server.BlobfuseV2
73+
}
74+
return server.BlobfuseV1
75+
}

pkg/blobfuse-proxy/server/server.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,23 @@ var (
3333
mutex sync.Mutex
3434
)
3535

36+
type BlobfuseVersion int
37+
38+
const (
39+
BlobfuseV1 BlobfuseVersion = iota
40+
BlobfuseV2
41+
)
42+
3643
type MountServer struct {
44+
blobfuseVersion BlobfuseVersion
3745
mount_azure_blob.UnimplementedMountServiceServer
3846
}
3947

4048
// NewMountServer returns a new Mountserver
41-
func NewMountServiceServer() *MountServer {
42-
return &MountServer{}
49+
func NewMountServiceServer(ver BlobfuseVersion) *MountServer {
50+
return &MountServer{
51+
blobfuseVersion: ver,
52+
}
4353
}
4454

4555
// MountAzureBlob mounts an azure blob container to given location
@@ -53,11 +63,21 @@ func (server *MountServer) MountAzureBlob(ctx context.Context,
5363
authEnv := req.GetAuthEnv()
5464
klog.V(2).Infof("received mount request: Mounting with args %v \n", args)
5565

66+
var cmd *exec.Cmd
5667
var result mount_azure_blob.MountAzureBlobResponse
57-
cmd := exec.Command("blobfuse", strings.Split(args, " ")...)
68+
switch server.blobfuseVersion {
69+
case BlobfuseV1:
70+
cmd = exec.Command("blobfuse", strings.Split(args, " ")...)
71+
case BlobfuseV2:
72+
args = "mount " + args
73+
cmd = exec.Command("blobfuse2", strings.Split(args, " ")...)
74+
}
5875

5976
cmd.Env = append(cmd.Env, authEnv...)
77+
klog.Infof("zzzzzzzzzzzzzzz args %v", args)
78+
klog.Infof("zzzzzzzzzzzzzzz authEnv %v", authEnv)
6079
output, err := cmd.CombinedOutput()
80+
klog.Infof("zzzzzzzzzzzzzzz output %v", string(output))
6181
if err != nil {
6282
klog.Error("blobfuse mount failed: with error:", err.Error())
6383
} else {

pkg/blobfuse-proxy/server/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func TestServerMountAzureBlob(t *testing.T) {
4848
t.Run(tc.name, func(t *testing.T) {
4949
t.Parallel()
5050

51-
mountServer := NewMountServiceServer()
51+
mountServer := NewMountServiceServer(BlobfuseV1)
5252
req := mount_azure_blob.MountAzureBlobRequest{
5353
MountArgs: tc.args,
5454
AuthEnv: tc.authEnv,

pkg/blobplugin/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ARG ARCH=amd64
3434
RUN if [ "$ARCH" = "amd64" ] ; then \
3535
clean-install libcurl4-gnutls-dev && \
3636
wget -O /blobfuse-proxy/packages-microsoft-prod.deb https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb && \
37-
dpkg -i /blobfuse-proxy/packages-microsoft-prod.deb && apt update && apt install blobfuse fuse -y && apt remove wget -y; fi
37+
dpkg -i /blobfuse-proxy/packages-microsoft-prod.deb && apt update && apt install blobfuse blobfuse2 fuse -y && apt remove wget -y; fi
3838
LABEL maintainers="andyzhangx"
3939
LABEL description="Azure Blob Storage CSI driver"
4040

test/e2e/testsuites/pre_provisioned_provided_credentials_tester.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ func (t *PreProvisionedProvidedCredentiasTest) Run(client clientset.Interface, n
8080

8181
// test for storage account SAS token
8282
ginkgo.By("Run for storage account SAS token")
83+
pod.Volumes[n].Attrib = map[string]string{
84+
"azurestorageauthtype": "SAS",
85+
}
8386
sasToken := GenerateSASToken(accountName, accountKey)
8487
secretData = map[string]string{
8588
"azurestorageaccountname": accountName,

test/e2e/testsuites/pre_provisioned_sastoken_tester.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func (t *PreProvisionedSASTokenTest) Run(client clientset.Interface, namespace *
7171
pod.Volumes[n].Attrib["storageAccountName"] = accountName
7272
pod.Volumes[n].Attrib["keyVaultURL"] = *vault.Properties.VaultURI
7373
pod.Volumes[n].Attrib["keyVaultSecretName"] = *accountSASSecret.Name
74+
pod.Volumes[n].Attrib["azurestorageauthtype"] = "SAS"
7475

7576
tpod, cleanup := pod.SetupWithPreProvisionedVolumes(client, namespace, t.CSIDriver)
7677
// defer must be called here for resources not get removed before using them

0 commit comments

Comments
 (0)