Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,12 @@ func isSupportedContainerNamePrefix(prefix string) bool {
return true
}

// isNFSProtocol checks if the protocol is NFS or AZNFS
func isNFSProtocol(protocol string) bool {
protocol = strings.ToLower(protocol)
return protocol == NFS || protocol == AZNFS
}

// get storage account from secrets map
func getStorageAccount(secrets map[string]string) (string, string, error) {
if secrets == nil {
Expand Down
43 changes: 43 additions & 0 deletions pkg/blob/blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1659,3 +1659,46 @@ func TestIsSupportedAccessTier(t *testing.T) {
}
}
}

func TestIsNFSProtocol(t *testing.T) {
tests := []struct {
protocol string
expectedResult bool
}{
{
protocol: "",
expectedResult: false,
},
{
protocol: "NFS",
expectedResult: true,
},
{
protocol: "nfs",
expectedResult: true,
},
{
protocol: "Nfs",
expectedResult: true,
},
{
protocol: "NFSv3",
expectedResult: false,
},
{
protocol: "aznfs",
expectedResult: true,
},
{
protocol: "azNfs",
expectedResult: true,
},
}

for _, test := range tests {
result := isNFSProtocol(test.protocol)
if result != test.expectedResult {
t.Errorf("isNFSVolume(%s) returned with %v, not equal to %v", test.protocol, result, test.expectedResult)
}
}
}
8 changes: 4 additions & 4 deletions pkg/blob/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
}

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

if subsID != "" && subsID != d.cloud.SubscriptionID {
if protocol == NFS {
if isNFSProtocol(protocol) {
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("NFS protocol is not supported in cross subscription(%s)", subsID))
}
if !storeAccountKey {
Expand Down Expand Up @@ -249,7 +249,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
vnetResourceIDs []string
enableNfsV3 *bool
)
if protocol == NFS {
if isNFSProtocol(protocol) {
isHnsEnabled = pointer.Bool(true)
enableNfsV3 = pointer.Bool(true)
// NFS protocol does not need account key
Expand Down Expand Up @@ -359,7 +359,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
}
}

if createPrivateEndpoint && protocol == NFS {
if createPrivateEndpoint && isNFSProtocol(protocol) {
// As for blobfuse/blobfuse2, serverName, i.e.,AZURE_STORAGE_BLOB_ENDPOINT env variable can't include
// "privatelink", issue: https://github.com/Azure/azure-storage-fuse/issues/1014
//
Expand Down
2 changes: 1 addition & 1 deletion pkg/blob/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
serverAddress = fmt.Sprintf("%s.blob.%s", accountName, storageEndpointSuffix)
}

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

Expand Down