Skip to content

Commit 266f849

Browse files
authored
Merge pull request #1110 from andyzhangx/aznfs-fix-1.22
[release-1.22] fix: make aznfs protocol consistent with nfs
2 parents 10a6587 + 0ef4124 commit 266f849

File tree

4 files changed

+54
-5
lines changed

4 files changed

+54
-5
lines changed

pkg/blob/blob.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,12 @@ func isSupportedContainerNamePrefix(prefix string) bool {
720720
return true
721721
}
722722

723+
// isNFSProtocol checks if the protocol is NFS or AZNFS
724+
func isNFSProtocol(protocol string) bool {
725+
protocol = strings.ToLower(protocol)
726+
return protocol == NFS || protocol == AZNFS
727+
}
728+
723729
// get storage account from secrets map
724730
func getStorageAccount(secrets map[string]string) (string, string, error) {
725731
if secrets == nil {

pkg/blob/blob_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,3 +1659,46 @@ func TestIsSupportedAccessTier(t *testing.T) {
16591659
}
16601660
}
16611661
}
1662+
1663+
func TestIsNFSProtocol(t *testing.T) {
1664+
tests := []struct {
1665+
protocol string
1666+
expectedResult bool
1667+
}{
1668+
{
1669+
protocol: "",
1670+
expectedResult: false,
1671+
},
1672+
{
1673+
protocol: "NFS",
1674+
expectedResult: true,
1675+
},
1676+
{
1677+
protocol: "nfs",
1678+
expectedResult: true,
1679+
},
1680+
{
1681+
protocol: "Nfs",
1682+
expectedResult: true,
1683+
},
1684+
{
1685+
protocol: "NFSv3",
1686+
expectedResult: false,
1687+
},
1688+
{
1689+
protocol: "aznfs",
1690+
expectedResult: true,
1691+
},
1692+
{
1693+
protocol: "azNfs",
1694+
expectedResult: true,
1695+
},
1696+
}
1697+
1698+
for _, test := range tests {
1699+
result := isNFSProtocol(test.protocol)
1700+
if result != test.expectedResult {
1701+
t.Errorf("isNFSVolume(%s) returned with %v, not equal to %v", test.protocol, result, test.expectedResult)
1702+
}
1703+
}
1704+
}

pkg/blob/controllerserver.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
192192
}
193193

194194
if pointer.BoolDeref(enableBlobVersioning, false) {
195-
if protocol == NFS || pointer.BoolDeref(isHnsEnabled, false) {
195+
if isNFSProtocol(protocol) || pointer.BoolDeref(isHnsEnabled, false) {
196196
return nil, status.Errorf(codes.InvalidArgument, "enableBlobVersioning is not supported for NFS protocol or HNS enabled account")
197197
}
198198
}
@@ -202,7 +202,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
202202
}
203203

204204
if subsID != "" && subsID != d.cloud.SubscriptionID {
205-
if protocol == NFS {
205+
if isNFSProtocol(protocol) {
206206
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("NFS protocol is not supported in cross subscription(%s)", subsID))
207207
}
208208
if !storeAccountKey {
@@ -249,7 +249,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
249249
vnetResourceIDs []string
250250
enableNfsV3 *bool
251251
)
252-
if protocol == NFS {
252+
if isNFSProtocol(protocol) {
253253
isHnsEnabled = pointer.Bool(true)
254254
enableNfsV3 = pointer.Bool(true)
255255
// NFS protocol does not need account key
@@ -359,7 +359,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
359359
}
360360
}
361361

362-
if createPrivateEndpoint && protocol == NFS {
362+
if createPrivateEndpoint && isNFSProtocol(protocol) {
363363
// As for blobfuse/blobfuse2, serverName, i.e.,AZURE_STORAGE_BLOB_ENDPOINT env variable can't include
364364
// "privatelink", issue: https://github.com/Azure/azure-storage-fuse/issues/1014
365365
//

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
serverAddress = fmt.Sprintf("%s.blob.%s", accountName, storageEndpointSuffix)
312312
}
313313

314-
if protocol == NFS {
314+
if isNFSProtocol(protocol) {
315315
klog.V(2).Infof("target %v\nprotocol %v\n\nvolumeId %v\ncontext %v\nmountflags %v\nserverAddress %v",
316316
targetPath, protocol, volumeID, attrib, mountFlags, serverAddress)
317317

0 commit comments

Comments
 (0)