From c155adea270d5a7183051f0217b7e101c510183d Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Thu, 14 Mar 2024 12:03:45 +0000 Subject: [PATCH] feat: provide nfsv3 protocol to enforce nfs mount --- pkg/blob/blob.go | 7 +++--- pkg/blob/blob_test.go | 4 ++-- pkg/blob/controllerserver_test.go | 2 +- pkg/blob/nodeserver.go | 2 +- test/e2e/dynamic_provisioning_test.go | 31 +++++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/pkg/blob/blob.go b/pkg/blob/blob.go index b94a1a8b9..15271d7b9 100644 --- a/pkg/blob/blob.go +++ b/pkg/blob/blob.go @@ -111,6 +111,7 @@ const ( Fuse2 = "fuse2" NFS = "nfs" AZNFS = "aznfs" + NFSv3 = "nfsv3" vnetResourceGroupField = "vnetresourcegroup" vnetNameField = "vnetname" subnetNameField = "subnetname" @@ -151,7 +152,7 @@ const ( ) var ( - supportedProtocolList = []string{Fuse, Fuse2, NFS} + supportedProtocolList = []string{Fuse, Fuse2, NFS, AZNFS} retriableErrors = []string{accountNotProvisioned, tooManyRequests, statusCodeNotFound, containerBeingDeletedDataplaneAPIError, containerBeingDeletedManagementAPIError, clientThrottled} ) @@ -740,7 +741,7 @@ func isSupportedProtocol(protocol string) bool { return true } for _, v := range supportedProtocolList { - if protocol == v { + if protocol == v || protocol == NFSv3 { return true } } @@ -782,7 +783,7 @@ func isSupportedContainerNamePrefix(prefix string) bool { // isNFSProtocol checks if the protocol is NFS or AZNFS func isNFSProtocol(protocol string) bool { protocol = strings.ToLower(protocol) - return protocol == NFS || protocol == AZNFS + return protocol == NFS || protocol == AZNFS || protocol == NFSv3 } // get storage account from secrets map diff --git a/pkg/blob/blob_test.go b/pkg/blob/blob_test.go index 615903e43..e2219aa9f 100644 --- a/pkg/blob/blob_test.go +++ b/pkg/blob/blob_test.go @@ -1747,8 +1747,8 @@ func TestIsNFSProtocol(t *testing.T) { expectedResult: true, }, { - protocol: "NFSv3", - expectedResult: false, + protocol: "nfsv3", + expectedResult: true, }, { protocol: "aznfs", diff --git a/pkg/blob/controllerserver_test.go b/pkg/blob/controllerserver_test.go index e81b4528a..131531888 100644 --- a/pkg/blob/controllerserver_test.go +++ b/pkg/blob/controllerserver_test.go @@ -232,7 +232,7 @@ func TestCreateVolume(t *testing.T) { controllerServiceCapability, } _, err := d.CreateVolume(context.Background(), req) - expectedErr := status.Errorf(codes.InvalidArgument, "protocol(unit-test) is not supported, supported protocol list: [fuse fuse2 nfs]") + expectedErr := status.Errorf(codes.InvalidArgument, "protocol(unit-test) is not supported, supported protocol list: [fuse fuse2 nfs aznfs]") if !reflect.DeepEqual(err, expectedErr) { t.Errorf("actualErr: (%v), expectedErr: (%v)", err, expectedErr) } diff --git a/pkg/blob/nodeserver.go b/pkg/blob/nodeserver.go index 25729e94c..2e1a54529 100644 --- a/pkg/blob/nodeserver.go +++ b/pkg/blob/nodeserver.go @@ -330,7 +330,7 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe targetPath, protocol, volumeID, attrib, mountFlags, serverAddress) mountType := AZNFS - if !d.enableAznfsMount { + if !d.enableAznfsMount || protocol == NFSv3 { mountType = NFS } diff --git a/test/e2e/dynamic_provisioning_test.go b/test/e2e/dynamic_provisioning_test.go index 0f2ee5697..c1cf1da26 100644 --- a/test/e2e/dynamic_provisioning_test.go +++ b/test/e2e/dynamic_provisioning_test.go @@ -524,6 +524,37 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Dynamic Provisioning", func() { test.Run(ctx, cs, ns) }) + ginkgo.It("enforce with nfs mount [nfs]", func(ctx ginkgo.SpecContext) { + if isAzureStackCloud { + ginkgo.Skip("test case is not available for Azure Stack") + } + pods := []testsuites.PodDetails{ + { + Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data", + Volumes: []testsuites.VolumeDetails{ + { + ClaimSize: "10Gi", + MountOptions: []string{ + "nconnect=8", + }, + VolumeMount: testsuites.VolumeMountDetails{ + NameGenerate: "test-volume-", + MountPathGenerate: "/mnt/test-", + }, + }, + }, + }, + } + test := testsuites.DynamicallyProvisionedCmdVolumeTest{ + CSIDriver: testDriver, + Pods: pods, + StorageClassParameters: map[string]string{ + "protocol": "nfsv3", + }, + } + test.Run(ctx, cs, ns) + }) + ginkgo.It("should create a NFSv3 volume on demand with zero mountPermissions [nfs]", func(ctx ginkgo.SpecContext) { if isAzureStackCloud { ginkgo.Skip("test case is not available for Azure Stack")