From 8d804287d34080630cbe420032ff8e7e74271724 Mon Sep 17 00:00:00 2001 From: Christian Huffman Date: Tue, 16 Feb 2021 10:57:41 -0500 Subject: [PATCH] Updates the Azure File minimum size for premium accounts --- pkg/volume/azure_file/azure_file.go | 5 +++-- pkg/volume/azure_file/azure_provision.go | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/volume/azure_file/azure_file.go b/pkg/volume/azure_file/azure_file.go index 95e88c14a95..08b02a782f6 100644 --- a/pkg/volume/azure_file/azure_file.go +++ b/pkg/volume/azure_file/azure_file.go @@ -55,8 +55,9 @@ var _ volume.PersistentVolumePlugin = &azureFilePlugin{} var _ volume.ExpandableVolumePlugin = &azureFilePlugin{} const ( - azureFilePluginName = "kubernetes.io/azure-file" - defaultSecretNamespace = "default" + azureFilePluginName = "kubernetes.io/azure-file" + defaultSecretNamespace = "default" + minimumPremiumShareSize = 100 // GB ) func getPath(uid types.UID, volName string, host volume.VolumeHost) string { diff --git a/pkg/volume/azure_file/azure_provision.go b/pkg/volume/azure_file/azure_provision.go index 6b4c8f834a2..a9dc31b6909 100644 --- a/pkg/volume/azure_file/azure_provision.go +++ b/pkg/volume/azure_file/azure_provision.go @@ -207,10 +207,15 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie resourceGroup = a.options.PVC.ObjectMeta.Annotations[resourceGroupAnnotation] } + fileShareSize := int(requestGiB) // when use azure file premium, account kind should be specified as FileStorage accountKind := string(storage.StorageV2) if strings.HasPrefix(strings.ToLower(sku), "premium") { accountKind = string(storage.FileStorage) + // when using azure file premium, the shares have a minimum size + if fileShareSize < minimumPremiumShareSize { + fileShareSize = minimumPremiumShareSize + } } accountOptions := &azure.AccountOptions{ @@ -225,7 +230,7 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie shareOptions := &fileclient.ShareOptions{ Name: shareName, Protocol: storage.SMB, - RequestGiB: requestGiB, + RequestGiB: fileShareSize, } account, key, err := a.azureProvider.CreateFileShare(accountOptions, shareOptions) @@ -252,7 +257,7 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie PersistentVolumeReclaimPolicy: a.options.PersistentVolumeReclaimPolicy, AccessModes: a.options.PVC.Spec.AccessModes, Capacity: v1.ResourceList{ - v1.ResourceName(v1.ResourceStorage): resource.MustParse(fmt.Sprintf("%dGi", requestGiB)), + v1.ResourceName(v1.ResourceStorage): resource.MustParse(fmt.Sprintf("%dGi", fileShareSize)), }, PersistentVolumeSource: v1.PersistentVolumeSource{ AzureFile: &v1.AzureFilePersistentVolumeSource{