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

add more storage account sku support for azure disk #67528

Merged
merged 1 commit into from Aug 17, 2018
Jump to file or symbol
Failed to load files and symbols.
+61 −5
Diff settings

Always

Just for now

add more sku support for azure disk

add error msg

update bazel
  • Loading branch information...
andyzhangx committed Aug 16, 2018
commit aa4594ffae0fb910ef1a10a7cfebaab5e29ded4f
@@ -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))
}
}
ProTip! Use n and p to navigate between commits in a pull request.