Skip to content

Commit

Permalink
Merge pull request #1276 from andyzhangx/enforce-nfs-mount
Browse files Browse the repository at this point in the history
feat: provide nfsv3 protocol to enforce nfs mount
  • Loading branch information
k8s-ci-robot authored Mar 14, 2024
2 parents a33e816 + 58c76c8 commit ac7bf03
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
7 changes: 4 additions & 3 deletions 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 @@ -155,7 +156,7 @@ const (
)

var (
supportedProtocolList = []string{Fuse, Fuse2, NFS}
supportedProtocolList = []string{Fuse, Fuse2, NFS, AZNFS}
retriableErrors = []string{accountNotProvisioned, tooManyRequests, statusCodeNotFound, containerBeingDeletedDataplaneAPIError, containerBeingDeletedManagementAPIError, clientThrottled}
supportedFSGroupChangePolicyList = []string{FSGroupChangeNone, string(v1.FSGroupChangeAlways), string(v1.FSGroupChangeOnRootMismatch)}
)
Expand Down Expand Up @@ -762,7 +763,7 @@ func isSupportedProtocol(protocol string) bool {
return true
}
for _, v := range supportedProtocolList {
if protocol == v {
if protocol == v || protocol == NFSv3 {
return true
}
}
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/controllerserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,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)
}
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 ac7bf03

Please sign in to comment.