Skip to content

Commit 74ad3c2

Browse files
authored
Merge pull request #1103 from andyzhangx/aznfs-fix
fix: make aznfs protocol consistent with nfs
2 parents 819ecfe + ba55788 commit 74ad3c2

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
@@ -728,6 +728,12 @@ func isSupportedContainerNamePrefix(prefix string) bool {
728728
return true
729729
}
730730

731+
// isNFSProtocol checks if the protocol is NFS or AZNFS
732+
func isNFSProtocol(protocol string) bool {
733+
protocol = strings.ToLower(protocol)
734+
return protocol == NFS || protocol == AZNFS
735+
}
736+
731737
// get storage account from secrets map
732738
func getStorageAccount(secrets map[string]string) (string, string, error) {
733739
if secrets == nil {

pkg/blob/blob_test.go

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

pkg/blob/controllerserver.go

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

209209
if pointer.BoolDeref(enableBlobVersioning, false) {
210-
if protocol == NFS || pointer.BoolDeref(isHnsEnabled, false) {
210+
if isNFSProtocol(protocol) || pointer.BoolDeref(isHnsEnabled, false) {
211211
return nil, status.Errorf(codes.InvalidArgument, "enableBlobVersioning is not supported for NFS protocol or HNS enabled account")
212212
}
213213
}
@@ -217,7 +217,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
217217
}
218218

219219
if subsID != "" && subsID != d.cloud.SubscriptionID {
220-
if protocol == NFS {
220+
if isNFSProtocol(protocol) {
221221
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("NFS protocol is not supported in cross subscription(%s)", subsID))
222222
}
223223
if !storeAccountKey {
@@ -259,7 +259,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
259259
createPrivateEndpoint = pointer.BoolPtr(true)
260260
}
261261
accountKind := string(storage.KindStorageV2)
262-
if protocol == NFS {
262+
if isNFSProtocol(protocol) {
263263
isHnsEnabled = pointer.Bool(true)
264264
enableNfsV3 = pointer.Bool(true)
265265
// NFS protocol does not need account key
@@ -378,7 +378,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
378378
}
379379
}
380380

381-
if pointer.BoolDeref(createPrivateEndpoint, false) && protocol == NFS {
381+
if pointer.BoolDeref(createPrivateEndpoint, false) && isNFSProtocol(protocol) {
382382
// As for blobfuse/blobfuse2, serverName, i.e.,AZURE_STORAGE_BLOB_ENDPOINT env variable can't include
383383
// "privatelink", issue: https://github.com/Azure/azure-storage-fuse/issues/1014
384384
//

pkg/blob/nodeserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
318318
serverAddress = fmt.Sprintf("%s.blob.%s", accountName, storageEndpointSuffix)
319319
}
320320

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

0 commit comments

Comments
 (0)