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

feat: add AccessTier and SMB MultiChannel support in storage account creation #2464

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 20 additions & 2 deletions pkg/provider/azure_storageaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type AccountOptions struct {
AllowBlobPublicAccess *bool
RequireInfrastructureEncryption *bool
AllowSharedKeyAccess *bool
IsMultichannelEnabled *bool
KeyName *string
KeyVersion *string
KeyVaultURI *string
Expand All @@ -62,6 +63,7 @@ type AccountOptions struct {
VNetResourceGroup string
VNetName string
SubnetName string
AccessTier string
MatchTags bool
}

Expand Down Expand Up @@ -266,6 +268,7 @@ func (az *Cloud) EnsureStorageAccount(ctx context.Context, accountOptions *Accou
IsHnsEnabled: accountOptions.IsHnsEnabled,
EnableNfsV3: accountOptions.EnableNfsV3,
MinimumTLSVersion: storage.MinimumTLSVersionTLS12,
AccessTier: storage.AccessTier(accountOptions.AccessTier),
},
Tags: tags,
Location: &location}
Expand Down Expand Up @@ -317,20 +320,35 @@ func (az *Cloud) EnsureStorageAccount(ctx context.Context, accountOptions *Accou
}

if accountOptions.DisableFileServiceDeleteRetentionPolicy {
klog.V(2).Infof("disable DisableFileServiceDeleteRetentionPolicy on account(%s), subscroption(%s), resource group(%s)", accountName, subsID, resourceGroup)
klog.V(2).Infof("disable DisableFileServiceDeleteRetentionPolicy on account(%s), subscription(%s), resource group(%s)", accountName, subsID, resourceGroup)
prop, err := az.FileClient.WithSubscriptionID(subsID).GetServiceProperties(ctx, resourceGroup, accountName)
if err != nil {
return "", "", err
}
if prop.FileServicePropertiesProperties == nil {
return "", "", fmt.Errorf("FileServicePropertiesProperties of account(%s), subscroption(%s), resource group(%s) is nil", accountName, subsID, resourceGroup)
return "", "", fmt.Errorf("FileServicePropertiesProperties of account(%s), subscription(%s), resource group(%s) is nil", accountName, subsID, resourceGroup)
}
prop.FileServicePropertiesProperties.ShareDeleteRetentionPolicy = &storage.DeleteRetentionPolicy{Enabled: to.BoolPtr(false)}
if _, err := az.FileClient.WithSubscriptionID(subsID).SetServiceProperties(ctx, resourceGroup, accountName, prop); err != nil {
return "", "", err
}
}

if to.Bool(accountOptions.IsMultichannelEnabled) {
klog.V(2).Infof("enable SMB Multichannel setting on account(%s), subscription(%s), resource group(%s)", accountName, subsID, resourceGroup)
prop, err := az.FileClient.WithSubscriptionID(subsID).GetServiceProperties(ctx, resourceGroup, accountName)
if err != nil {
return "", "", err
}
if prop.FileServicePropertiesProperties == nil {
return "", "", fmt.Errorf("FileServicePropertiesProperties of account(%s), subscription(%s), resource group(%s) is nil", accountName, subsID, resourceGroup)
}
prop.FileServicePropertiesProperties.ProtocolSettings = &storage.ProtocolSettings{Smb: &storage.SmbSetting{Multichannel: &storage.Multichannel{Enabled: to.BoolPtr(true)}}}
if _, err := az.FileClient.WithSubscriptionID(subsID).SetServiceProperties(ctx, resourceGroup, accountName, prop); err != nil {
return "", "", err
}
}

if accountOptions.CreatePrivateEndpoint {
// Get properties of the storageAccount
storageAccount, err := az.StorageAccountClient.GetProperties(ctx, subsID, resourceGroup, accountName)
Expand Down
3 changes: 3 additions & 0 deletions pkg/provider/azure_storageaccount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ func TestEnsureStorageAccount(t *testing.T) {
SubnetPropertiesFormatNil bool
mockStorageAccountsClient bool
setAccountOptions bool
accessTier string
requireInfrastructureEncryption *bool
keyVaultURL *string
accountName string
Expand All @@ -391,6 +392,7 @@ func TestEnsureStorageAccount(t *testing.T) {
requireInfrastructureEncryption: to.BoolPtr(true),
keyVaultURL: to.StringPtr("keyVaultURL"),
resourceGroup: "rg",
accessTier: "AccessTierHot",
accountName: "",
expectedErr: "",
},
Expand Down Expand Up @@ -479,6 +481,7 @@ func TestEnsureStorageAccount(t *testing.T) {
Name: test.accountName,
CreateAccount: test.createAccount,
SubscriptionID: test.subscriptionID,
AccessTier: test.accessTier,
}
}

Expand Down