Skip to content

Commit

Permalink
feat: provide nfsv3 protocol to enforce nfs mount
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhangx committed Mar 13, 2024
1 parent a33e816 commit b9ae1e9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkg/blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const (
Fuse2 = "fuse2"
NFS = "nfs"
AZNFS = "aznfs"
NFSv3 = "nfsv3"
vnetResourceGroupField = "vnetresourcegroup"
vnetNameField = "vnetname"
subnetNameField = "subnetname"
Expand Down Expand Up @@ -804,7 +805,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
Expand Down
4 changes: 2 additions & 2 deletions pkg/blob/blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1745,8 +1745,8 @@ func TestIsNFSProtocol(t *testing.T) {
expectedResult: true,
},
{
protocol: "NFSv3",
expectedResult: false,
protocol: "nfsv3",
expectedResult: true,
},
{
protocol: "aznfs",
Expand Down
2 changes: 1 addition & 1 deletion pkg/blob/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,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
}

Expand Down
31 changes: 31 additions & 0 deletions test/e2e/dynamic_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,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")
Expand Down

0 comments on commit b9ae1e9

Please sign in to comment.