Permalink
Browse files

Merge pull request #67528 from andyzhangx/azuredisk-sku

Automatic merge from submit-queue (batch tested with PRs 66920, 67316, 67363, 67528, 66963). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

add more storage account sku support for azure disk

add error msg



**What this PR does / why we need it**:
Original hard coded storage account sku list is not good design, swith to use `storage.PossibleSkuNameValues()` to add more sku support for azure disk

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #67527

**Special notes for your reviewer**:

**Release note**:

```
add more storage account sku support for azure disk
```

/sig azure
@feiskyer 
FYI @khenidak
  • Loading branch information...
k8s-merge-robot committed Aug 17, 2018
2 parents 7b2f16b + aa4594f commit 53ee2e53077d54fcc3f5fbd83a6704a4b6562f79
Showing with 61 additions and 5 deletions.
  1. +1 −0 pkg/volume/azure_dd/BUILD
  2. +7 −5 pkg/volume/azure_dd/azure_common.go
  3. +53 −0 pkg/volume/azure_dd/azure_common_test.go
@@ -75,6 +75,7 @@ go_test(
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
"//staging/src/k8s.io/client-go/util/testing:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
],
)
@@ -59,8 +59,6 @@ var (
string(api.AzureSharedBlobDisk),
string(api.AzureDedicatedBlobDisk),
string(api.AzureManagedDisk))
supportedStorageAccountTypes = sets.NewString("Premium_LRS", "Standard_LRS", "Standard_GRS", "Standard_RAGRS")
)
func getPath(uid types.UID, volName string, host volume.VolumeHost) string {
@@ -127,11 +125,15 @@ func normalizeStorageAccountType(storageAccountType string) (storage.SkuName, er
return defaultStorageAccountType, nil
}
if !supportedStorageAccountTypes.Has(storageAccountType) {
return "", fmt.Errorf("azureDisk - %s is not supported sku/storageaccounttype. Supported values are %s", storageAccountType, supportedStorageAccountTypes.List())
sku := storage.SkuName(storageAccountType)
supportedSkuNames := storage.PossibleSkuNameValues()
for _, s := range supportedSkuNames {
if sku == s {
return sku, nil
}
}
return storage.SkuName(storageAccountType), nil
return "", fmt.Errorf("azureDisk - %s is not supported sku/storageaccounttype. Supported values are %s", storageAccountType, supportedSkuNames)
}
func normalizeCachingMode(cachingMode v1.AzureDataDiskCachingMode) (v1.AzureDataDiskCachingMode, error) {
@@ -24,6 +24,9 @@ import (
"testing"
"time"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage"
"github.com/stretchr/testify/assert"
"k8s.io/kubernetes/pkg/util/mount"
)
@@ -134,3 +137,53 @@ func TestIoHandler(t *testing.T) {
}
}
}
func TestNormalizeStorageAccountType(t *testing.T) {
tests := []struct {
storageAccountType string
expectedAccountType storage.SkuName
expectError bool
}{
{
storageAccountType: "",
expectedAccountType: storage.StandardLRS,
expectError: false,
},
{
storageAccountType: "NOT_EXISTING",
expectedAccountType: "",
expectError: true,
},
{
storageAccountType: "Standard_LRS",
expectedAccountType: storage.StandardLRS,
expectError: false,
},
{
storageAccountType: "Premium_LRS",
expectedAccountType: storage.PremiumLRS,
expectError: false,
},
{
storageAccountType: "Standard_GRS",
expectedAccountType: storage.StandardGRS,
expectError: false,
},
{
storageAccountType: "Standard_RAGRS",
expectedAccountType: storage.StandardRAGRS,
expectError: false,
},
{
storageAccountType: "Standard_ZRS",
expectedAccountType: storage.StandardZRS,
expectError: false,
},
}
for _, test := range tests {
result, err := normalizeStorageAccountType(test.storageAccountType)
assert.Equal(t, result, test.expectedAccountType)
assert.Equal(t, err != nil, test.expectError, fmt.Sprintf("error msg: %v", err))
}
}

0 comments on commit 53ee2e5

Please sign in to comment.