Skip to content

Commit ac5110c

Browse files
authored
Merge pull request #1283 from andyzhangx/enforce-nfs-mount-1.23
[release-1.23] feat: provide nfsv3 protocol to enforce nfs mount
2 parents fd6743e + c155ade commit ac5110c

File tree

5 files changed

+39
-7
lines changed

5 files changed

+39
-7
lines changed

pkg/blob/blob.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ const (
111111
Fuse2 = "fuse2"
112112
NFS = "nfs"
113113
AZNFS = "aznfs"
114+
NFSv3 = "nfsv3"
114115
vnetResourceGroupField = "vnetresourcegroup"
115116
vnetNameField = "vnetname"
116117
subnetNameField = "subnetname"
@@ -151,7 +152,7 @@ const (
151152
)
152153

153154
var (
154-
supportedProtocolList = []string{Fuse, Fuse2, NFS}
155+
supportedProtocolList = []string{Fuse, Fuse2, NFS, AZNFS}
155156
retriableErrors = []string{accountNotProvisioned, tooManyRequests, statusCodeNotFound, containerBeingDeletedDataplaneAPIError, containerBeingDeletedManagementAPIError, clientThrottled}
156157
)
157158

@@ -740,7 +741,7 @@ func isSupportedProtocol(protocol string) bool {
740741
return true
741742
}
742743
for _, v := range supportedProtocolList {
743-
if protocol == v {
744+
if protocol == v || protocol == NFSv3 {
744745
return true
745746
}
746747
}
@@ -782,7 +783,7 @@ func isSupportedContainerNamePrefix(prefix string) bool {
782783
// isNFSProtocol checks if the protocol is NFS or AZNFS
783784
func isNFSProtocol(protocol string) bool {
784785
protocol = strings.ToLower(protocol)
785-
return protocol == NFS || protocol == AZNFS
786+
return protocol == NFS || protocol == AZNFS || protocol == NFSv3
786787
}
787788

788789
// get storage account from secrets map

pkg/blob/blob_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,8 +1747,8 @@ func TestIsNFSProtocol(t *testing.T) {
17471747
expectedResult: true,
17481748
},
17491749
{
1750-
protocol: "NFSv3",
1751-
expectedResult: false,
1750+
protocol: "nfsv3",
1751+
expectedResult: true,
17521752
},
17531753
{
17541754
protocol: "aznfs",

pkg/blob/controllerserver_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func TestCreateVolume(t *testing.T) {
232232
controllerServiceCapability,
233233
}
234234
_, err := d.CreateVolume(context.Background(), req)
235-
expectedErr := status.Errorf(codes.InvalidArgument, "protocol(unit-test) is not supported, supported protocol list: [fuse fuse2 nfs]")
235+
expectedErr := status.Errorf(codes.InvalidArgument, "protocol(unit-test) is not supported, supported protocol list: [fuse fuse2 nfs aznfs]")
236236
if !reflect.DeepEqual(err, expectedErr) {
237237
t.Errorf("actualErr: (%v), expectedErr: (%v)", err, expectedErr)
238238
}

pkg/blob/nodeserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
330330
targetPath, protocol, volumeID, attrib, mountFlags, serverAddress)
331331

332332
mountType := AZNFS
333-
if !d.enableAznfsMount {
333+
if !d.enableAznfsMount || protocol == NFSv3 {
334334
mountType = NFS
335335
}
336336

test/e2e/dynamic_provisioning_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,37 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Dynamic Provisioning", func() {
524524
test.Run(ctx, cs, ns)
525525
})
526526

527+
ginkgo.It("enforce with nfs mount [nfs]", func(ctx ginkgo.SpecContext) {
528+
if isAzureStackCloud {
529+
ginkgo.Skip("test case is not available for Azure Stack")
530+
}
531+
pods := []testsuites.PodDetails{
532+
{
533+
Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data",
534+
Volumes: []testsuites.VolumeDetails{
535+
{
536+
ClaimSize: "10Gi",
537+
MountOptions: []string{
538+
"nconnect=8",
539+
},
540+
VolumeMount: testsuites.VolumeMountDetails{
541+
NameGenerate: "test-volume-",
542+
MountPathGenerate: "/mnt/test-",
543+
},
544+
},
545+
},
546+
},
547+
}
548+
test := testsuites.DynamicallyProvisionedCmdVolumeTest{
549+
CSIDriver: testDriver,
550+
Pods: pods,
551+
StorageClassParameters: map[string]string{
552+
"protocol": "nfsv3",
553+
},
554+
}
555+
test.Run(ctx, cs, ns)
556+
})
557+
527558
ginkgo.It("should create a NFSv3 volume on demand with zero mountPermissions [nfs]", func(ctx ginkgo.SpecContext) {
528559
if isAzureStackCloud {
529560
ginkgo.Skip("test case is not available for Azure Stack")

0 commit comments

Comments
 (0)