Skip to content

Commit

Permalink
fix: nfs protocol does not support standard account
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhangx committed Mar 8, 2024
1 parent 691feb9 commit 68b9551
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions pkg/azurefile/azurefile.go
Expand Up @@ -145,6 +145,7 @@ const (
shareNamePrefixField = "sharenameprefix"
requireInfraEncryptionField = "requireinfraencryption"
enableMultichannelField = "enablemultichannel"
standard = "standard"
premium = "premium"
selectRandomMatchingAccountField = "selectrandommatchingaccount"
accountQuotaField = "accountquota"
Expand Down
9 changes: 6 additions & 3 deletions pkg/azurefile/controllerserver.go
Expand Up @@ -338,12 +338,15 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
}
var vnetResourceIDs []string
if fsType == nfs || protocol == nfs {
protocol = nfs
enableHTTPSTrafficOnly = false
if !strings.HasPrefix(strings.ToLower(sku), premium) {
if sku == "" {
// NFS protocol only supports Premium storage
sku = string(storage.SkuNamePremiumLRS)
} else if strings.HasPrefix(strings.ToLower(sku), standard) {
return nil, status.Errorf(codes.InvalidArgument, "nfs protocol only supports premium storage, current account type: %s", sku)
}

protocol = nfs
enableHTTPSTrafficOnly = false
shareProtocol = storage.EnabledProtocolsNFS
// NFS protocol does not need account key
storeAccountKey = false
Expand Down
23 changes: 23 additions & 0 deletions pkg/azurefile/controllerserver_test.go
Expand Up @@ -265,6 +265,29 @@ func TestCreateVolume(t *testing.T) {
}
},
},
{
name: "nfs protocol only supports premium storage",
testFunc: func(t *testing.T) {
allParam := map[string]string{
protocolField: "nfs",
skuNameField: "Standard_LRS",
}

req := &csi.CreateVolumeRequest{
Name: "random-vol-name-nfs-protocol-standard-sku",
CapacityRange: stdCapRange,
VolumeCapabilities: stdVolCap,
Parameters: allParam,
}

d := NewFakeDriver()
expectedErr := status.Errorf(codes.InvalidArgument, "nfs protocol only supports premium storage, current account type: Standard_LRS")
_, err := d.CreateVolume(ctx, req)
if !reflect.DeepEqual(err, expectedErr) {
t.Errorf("Unexpected error: %v", err)
}
},
},
{
name: "Invalid accessTier",
testFunc: func(t *testing.T) {
Expand Down

0 comments on commit 68b9551

Please sign in to comment.