mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
add more sku support for azure disk
add error msg update bazel
This commit is contained in:
parent
dbe3b1a3b3
commit
aa4594ffae
@ -75,6 +75,7 @@ go_test(
|
|||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
"//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/apimachinery/pkg/types:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/util/testing: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",
|
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -59,8 +59,6 @@ var (
|
|||||||
string(api.AzureSharedBlobDisk),
|
string(api.AzureSharedBlobDisk),
|
||||||
string(api.AzureDedicatedBlobDisk),
|
string(api.AzureDedicatedBlobDisk),
|
||||||
string(api.AzureManagedDisk))
|
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 {
|
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
|
return defaultStorageAccountType, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if !supportedStorageAccountTypes.Has(storageAccountType) {
|
sku := storage.SkuName(storageAccountType)
|
||||||
return "", fmt.Errorf("azureDisk - %s is not supported sku/storageaccounttype. Supported values are %s", storageAccountType, supportedStorageAccountTypes.List())
|
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) {
|
func normalizeCachingMode(cachingMode v1.AzureDataDiskCachingMode) (v1.AzureDataDiskCachingMode, error) {
|
||||||
|
@ -24,6 +24,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"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"
|
"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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user