Skip to content

Commit 4a596be

Browse files
authored
Merge pull request #1284 from andyzhangx/enforce-nfs-mount-1.22
[release-1.22] feat: provide nfsv3 protocol to enforce nfs mount
2 parents f907e9d + 0572d97 commit 4a596be

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
@@ -105,6 +105,7 @@ const (
105105
Fuse2 = "fuse2"
106106
NFS = "nfs"
107107
AZNFS = "aznfs"
108+
NFSv3 = "nfsv3"
108109
vnetResourceGroupField = "vnetresourcegroup"
109110
vnetNameField = "vnetname"
110111
subnetNameField = "subnetname"
@@ -145,7 +146,7 @@ const (
145146
)
146147

147148
var (
148-
supportedProtocolList = []string{Fuse, Fuse2, NFS}
149+
supportedProtocolList = []string{Fuse, Fuse2, NFS, AZNFS}
149150
retriableErrors = []string{accountNotProvisioned, tooManyRequests, statusCodeNotFound, containerBeingDeletedDataplaneAPIError, containerBeingDeletedManagementAPIError, clientThrottled}
150151
)
151152

@@ -681,7 +682,7 @@ func isSupportedProtocol(protocol string) bool {
681682
return true
682683
}
683684
for _, v := range supportedProtocolList {
684-
if protocol == v {
685+
if protocol == v || protocol == NFSv3 {
685686
return true
686687
}
687688
}
@@ -723,7 +724,7 @@ func isSupportedContainerNamePrefix(prefix string) bool {
723724
// isNFSProtocol checks if the protocol is NFS or AZNFS
724725
func isNFSProtocol(protocol string) bool {
725726
protocol = strings.ToLower(protocol)
726-
return protocol == NFS || protocol == AZNFS
727+
return protocol == NFS || protocol == AZNFS || protocol == NFSv3
727728
}
728729

729730
// 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
@@ -1728,8 +1728,8 @@ func TestIsNFSProtocol(t *testing.T) {
17281728
expectedResult: true,
17291729
},
17301730
{
1731-
protocol: "NFSv3",
1732-
expectedResult: false,
1731+
protocol: "nfsv3",
1732+
expectedResult: true,
17331733
},
17341734
{
17351735
protocol: "aznfs",

pkg/blob/controllerserver_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func TestCreateVolume(t *testing.T) {
241241
controllerServiceCapability,
242242
}
243243
_, err := d.CreateVolume(context.Background(), req)
244-
expectedErr := status.Errorf(codes.InvalidArgument, "protocol(unit-test) is not supported, supported protocol list: [fuse fuse2 nfs]")
244+
expectedErr := status.Errorf(codes.InvalidArgument, "protocol(unit-test) is not supported, supported protocol list: [fuse fuse2 nfs aznfs]")
245245
if !reflect.DeepEqual(err, expectedErr) {
246246
t.Errorf("actualErr: (%v), expectedErr: (%v)", err, expectedErr)
247247
}

pkg/blob/nodeserver.go

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

313313
mountType := AZNFS
314-
if !d.enableAznfsMount {
314+
if !d.enableAznfsMount || protocol == NFSv3 {
315315
mountType = NFS
316316
}
317317

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)