add ultrassd support

update stagin Godeps.json

update godeps license

fix test failure

fix comments
This commit is contained in:
andyzhangx 2018-10-31 09:27:45 +00:00
parent d210b4bcf3
commit f1bd292c76
8 changed files with 86 additions and 39 deletions

2
Godeps/LICENSES generated
View File

@ -8137,7 +8137,7 @@ SOFTWARE.
================================================================================ ================================================================================
= vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute licensed under: = = vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute licensed under: =
Apache License Apache License

View File

@ -24,7 +24,7 @@ import (
"strings" "strings"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage" "github.com/Azure/go-autorest/autorest/to"
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
@ -35,6 +35,12 @@ import (
"k8s.io/kubernetes/pkg/volume/util" "k8s.io/kubernetes/pkg/volume/util"
) )
const (
// default IOPS Caps & Throughput Cap (MBps) per https://docs.microsoft.com/en-us/azure/virtual-machines/linux/disks-ultra-ssd
defaultDiskIOPSReadWrite = 1200
defaultDiskMBpsReadWrite = 300
)
//ManagedDiskController : managed disk controller struct //ManagedDiskController : managed disk controller struct
type ManagedDiskController struct { type ManagedDiskController struct {
common *controllerCommon common *controllerCommon
@ -55,7 +61,11 @@ type ManagedDiskOptions struct {
// The tags of the disk. // The tags of the disk.
Tags map[string]string Tags map[string]string
// The SKU of storage account. // The SKU of storage account.
StorageAccountType storage.SkuName StorageAccountType compute.DiskStorageAccountTypes
// IOPS Caps for UltraSSD disk
DiskIOPSReadWrite string
// Throughput Cap (MBps) for UltraSSD disk
DiskMBpsReadWrite string
} }
func newManagedDiskController(common *controllerCommon) (*ManagedDiskController, error) { func newManagedDiskController(common *controllerCommon) (*ManagedDiskController, error) {
@ -87,17 +97,49 @@ func (c *ManagedDiskController) CreateManagedDisk(options *ManagedDiskOptions) (
} }
diskSizeGB := int32(options.SizeGB) diskSizeGB := int32(options.SizeGB)
diskSku := compute.DiskStorageAccountTypes(options.StorageAccountType)
diskProperties := compute.DiskProperties{
DiskSizeGB: &diskSizeGB,
CreationData: &compute.CreationData{CreateOption: compute.Empty},
}
if diskSku == compute.UltraSSDLRS {
diskIOPSReadWrite := int64(defaultDiskIOPSReadWrite)
if options.DiskIOPSReadWrite != "" {
v, err := strconv.Atoi(options.DiskIOPSReadWrite)
if err != nil {
return "", fmt.Errorf("AzureDisk - failed to parse DiskIOPSReadWrite: %v", err)
}
diskIOPSReadWrite = int64(v)
}
diskProperties.DiskIOPSReadWrite = to.Int64Ptr(diskIOPSReadWrite)
diskMBpsReadWrite := int32(defaultDiskMBpsReadWrite)
if options.DiskMBpsReadWrite != "" {
v, err := strconv.Atoi(options.DiskMBpsReadWrite)
if err != nil {
return "", fmt.Errorf("AzureDisk - failed to parse DiskMBpsReadWrite: %v", err)
}
diskMBpsReadWrite = int32(v)
}
diskProperties.DiskMBpsReadWrite = to.Int32Ptr(diskMBpsReadWrite)
} else {
if options.DiskIOPSReadWrite != "" {
return "", fmt.Errorf("AzureDisk - DiskIOPSReadWrite parameter is only applicable in UltraSSD_LRS disk type")
}
if options.DiskMBpsReadWrite != "" {
return "", fmt.Errorf("AzureDisk - DiskMBpsReadWrite parameter is only applicable in UltraSSD_LRS disk type")
}
}
model := compute.Disk{ model := compute.Disk{
Location: &c.common.location, Location: &c.common.location,
Tags: newTags, Tags: newTags,
Zones: createZones, Zones: createZones,
Sku: &compute.DiskSku{ Sku: &compute.DiskSku{
Name: compute.DiskStorageAccountTypes(options.StorageAccountType), Name: diskSku,
},
DiskProperties: &compute.DiskProperties{
DiskSizeGB: &diskSizeGB,
CreationData: &compute.CreationData{CreateOption: compute.Empty},
}, },
DiskProperties: &diskProperties,
} }
if options.ResourceGroup == "" { if options.ResourceGroup == "" {

View File

@ -76,7 +76,6 @@ go_test(
"//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/compute/mgmt/2018-10-01/compute:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library", "//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library", "//vendor/github.com/stretchr/testify/assert:go_default_library",
], ],

View File

@ -25,7 +25,7 @@ import (
"strconv" "strconv"
libstrings "strings" libstrings "strings"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
@ -38,7 +38,7 @@ import (
) )
const ( const (
defaultStorageAccountType = storage.StandardLRS defaultStorageAccountType = compute.StandardLRS
defaultAzureDiskKind = v1.AzureManagedDisk defaultAzureDiskKind = v1.AzureManagedDisk
defaultAzureDataDiskCachingMode = v1.AzureDataDiskCachingNone defaultAzureDataDiskCachingMode = v1.AzureDataDiskCachingNone
) )
@ -124,13 +124,13 @@ func normalizeKind(kind string) (v1.AzureDataDiskKind, error) {
return v1.AzureDataDiskKind(kind), nil return v1.AzureDataDiskKind(kind), nil
} }
func normalizeStorageAccountType(storageAccountType string) (storage.SkuName, error) { func normalizeStorageAccountType(storageAccountType string) (compute.DiskStorageAccountTypes, error) {
if storageAccountType == "" { if storageAccountType == "" {
return defaultStorageAccountType, nil return defaultStorageAccountType, nil
} }
sku := storage.SkuName(storageAccountType) sku := compute.DiskStorageAccountTypes(storageAccountType)
supportedSkuNames := storage.PossibleSkuNameValues() supportedSkuNames := compute.PossibleDiskStorageAccountTypesValues()
for _, s := range supportedSkuNames { for _, s := range supportedSkuNames {
if sku == s { if sku == s {
return sku, nil return sku, nil

View File

@ -24,7 +24,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/util/mount"
@ -141,12 +141,12 @@ func TestIoHandler(t *testing.T) {
func TestNormalizeStorageAccountType(t *testing.T) { func TestNormalizeStorageAccountType(t *testing.T) {
tests := []struct { tests := []struct {
storageAccountType string storageAccountType string
expectedAccountType storage.SkuName expectedAccountType compute.DiskStorageAccountTypes
expectError bool expectError bool
}{ }{
{ {
storageAccountType: "", storageAccountType: "",
expectedAccountType: storage.StandardLRS, expectedAccountType: compute.StandardLRS,
expectError: false, expectError: false,
}, },
{ {
@ -156,27 +156,22 @@ func TestNormalizeStorageAccountType(t *testing.T) {
}, },
{ {
storageAccountType: "Standard_LRS", storageAccountType: "Standard_LRS",
expectedAccountType: storage.StandardLRS, expectedAccountType: compute.StandardLRS,
expectError: false, expectError: false,
}, },
{ {
storageAccountType: "Premium_LRS", storageAccountType: "Premium_LRS",
expectedAccountType: storage.PremiumLRS, expectedAccountType: compute.PremiumLRS,
expectError: false, expectError: false,
}, },
{ {
storageAccountType: "Standard_GRS", storageAccountType: "StandardSSD_LRS",
expectedAccountType: storage.StandardGRS, expectedAccountType: compute.StandardSSDLRS,
expectError: false, expectError: false,
}, },
{ {
storageAccountType: "Standard_RAGRS", storageAccountType: "UltraSSD_LRS",
expectedAccountType: storage.StandardRAGRS, expectedAccountType: compute.UltraSSDLRS,
expectError: false,
},
{
storageAccountType: "Standard_ZRS",
expectedAccountType: storage.StandardZRS,
expectError: false, expectError: false,
}, },
} }

View File

@ -22,6 +22,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -127,6 +128,9 @@ func (p *azureDiskProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
availabilityZone string availabilityZone string
availabilityZones sets.String availabilityZones sets.String
selectedAvailabilityZone string selectedAvailabilityZone string
diskIopsReadWrite string
diskMbpsReadWrite string
) )
// maxLength = 79 - (4 for ".vhd") = 75 // maxLength = 79 - (4 for ".vhd") = 75
name := util.GenerateVolumeName(p.options.ClusterName, p.options.PVName, 75) name := util.GenerateVolumeName(p.options.ClusterName, p.options.PVName, 75)
@ -165,6 +169,10 @@ func (p *azureDiskProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
} }
case "zoned": case "zoned":
strZoned = v strZoned = v
case "diskiopsreadwrite":
diskIopsReadWrite = v
case "diskmbpsreadwrite":
diskMbpsReadWrite = v
default: default:
return nil, fmt.Errorf("AzureDisk - invalid option %s in storage class", k) return nil, fmt.Errorf("AzureDisk - invalid option %s in storage class", k)
} }
@ -241,6 +249,8 @@ func (p *azureDiskProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
SizeGB: requestGiB, SizeGB: requestGiB,
Tags: tags, Tags: tags,
AvailabilityZone: selectedAvailabilityZone, AvailabilityZone: selectedAvailabilityZone,
DiskIOPSReadWrite: diskIopsReadWrite,
DiskMBpsReadWrite: diskMbpsReadWrite,
} }
diskURI, err = diskController.CreateManagedDisk(volumeOptions) diskURI, err = diskController.CreateManagedDisk(volumeOptions)
if err != nil { if err != nil {
@ -257,7 +267,7 @@ func (p *azureDiskProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
return nil, err return nil, err
} }
} else { } else {
diskURI, err = diskController.CreateBlobDisk(name, skuName, requestGiB) diskURI, err = diskController.CreateBlobDisk(name, storage.SkuName(storageAccountType), requestGiB)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -16,27 +16,27 @@
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest", "ImportPath": "github.com/Azure/go-autorest/autorest",
"Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed" "Rev": "ea233b6412b0421a65dc6160e16c893364664a95"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest/adal", "ImportPath": "github.com/Azure/go-autorest/autorest/adal",
"Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed" "Rev": "ea233b6412b0421a65dc6160e16c893364664a95"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest/azure", "ImportPath": "github.com/Azure/go-autorest/autorest/azure",
"Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed" "Rev": "ea233b6412b0421a65dc6160e16c893364664a95"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest/date", "ImportPath": "github.com/Azure/go-autorest/autorest/date",
"Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed" "Rev": "ea233b6412b0421a65dc6160e16c893364664a95"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/logger", "ImportPath": "github.com/Azure/go-autorest/logger",
"Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed" "Rev": "ea233b6412b0421a65dc6160e16c893364664a95"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/version", "ImportPath": "github.com/Azure/go-autorest/version",
"Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed" "Rev": "ea233b6412b0421a65dc6160e16c893364664a95"
}, },
{ {
"ImportPath": "github.com/davecgh/go-spew/spew", "ImportPath": "github.com/davecgh/go-spew/spew",

View File

@ -17,6 +17,7 @@ limitations under the License.
package azure package azure
import ( import (
"encoding/json"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
@ -115,8 +116,8 @@ func token2Cfg(token *azureToken) map[string]string {
cfg[cfgClientID] = token.clientID cfg[cfgClientID] = token.clientID
cfg[cfgTenantID] = token.tenantID cfg[cfgTenantID] = token.tenantID
cfg[cfgApiserverID] = token.apiserverID cfg[cfgApiserverID] = token.apiserverID
cfg[cfgExpiresIn] = token.token.ExpiresIn cfg[cfgExpiresIn] = string(token.token.ExpiresIn)
cfg[cfgExpiresOn] = token.token.ExpiresOn cfg[cfgExpiresOn] = string(token.token.ExpiresOn)
return cfg return cfg
} }
@ -125,8 +126,8 @@ func newFackeAzureToken(accessToken string, expiresOn string) adal.Token {
AccessToken: accessToken, AccessToken: accessToken,
RefreshToken: "fake", RefreshToken: "fake",
ExpiresIn: "3600", ExpiresIn: "3600",
ExpiresOn: expiresOn, ExpiresOn: json.Number(expiresOn),
NotBefore: expiresOn, NotBefore: json.Number(expiresOn),
Resource: "fake", Resource: "fake",
Type: "fake", Type: "fake",
} }