Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-1.30] fix: nfs protocol does not support standard account #1747

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
1 change: 1 addition & 0 deletions pkg/azurefile/azurefile.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading