fix: change storage account client API version for Azure Stack

This commit is contained in:
Jiaxun Song 2020-11-08 21:25:58 -08:00
parent 2343b8a68b
commit 09112ed1f4
6 changed files with 17 additions and 4 deletions

View File

@ -73,7 +73,9 @@ import (
const (
// CloudProviderName is the value used for the --cloud-provider flag
CloudProviderName = "azure"
CloudProviderName = "azure"
// AzureStackCloudName is the cloud name of Azure Stack
AzureStackCloudName = "AZURESTACKCLOUD"
rateLimitQPSDefault = 1.0
rateLimitBucketDefault = 5
backoffRetriesDefault = 6
@ -609,6 +611,7 @@ func (az *Cloud) configAzureClients(
func (az *Cloud) getAzureClientConfig(servicePrincipalToken *adal.ServicePrincipalToken) *azclients.ClientConfig {
azClientConfig := &azclients.ClientConfig{
CloudName: az.Config.Cloud,
Location: az.Config.Location,
SubscriptionID: az.Config.SubscriptionID,
ResourceManagerEndpoint: az.Environment.ResourceManagerEndpoint,

View File

@ -141,7 +141,7 @@ func (as *availabilitySet) DetachDisk(diskName, diskURI string, nodeName types.N
(disk.ManagedDisk != nil && diskURI != "" && strings.EqualFold(*disk.ManagedDisk.ID, diskURI)) {
// found the disk
klog.V(2).Infof("azureDisk - detach disk: name %q uri %q", diskName, diskURI)
if strings.EqualFold(as.cloud.Environment.Name, "AZURESTACKCLOUD") {
if strings.EqualFold(as.cloud.Environment.Name, AzureStackCloudName) {
disks = append(disks[:i], disks[i+1:]...)
} else {
disks[i].ToBeDetached = to.BoolPtr(true)

View File

@ -143,7 +143,7 @@ func (ss *scaleSet) DetachDisk(diskName, diskURI string, nodeName types.NodeName
(disk.ManagedDisk != nil && diskURI != "" && strings.EqualFold(*disk.ManagedDisk.ID, diskURI)) {
// found the disk
klog.V(2).Infof("azureDisk - detach disk: name %q uri %q", diskName, diskURI)
if strings.EqualFold(ss.cloud.Environment.Name, "AZURESTACKCLOUD") {
if strings.EqualFold(ss.cloud.Environment.Name, AzureStackCloudName) {
disks = append(disks[:i], disks[i+1:]...)
} else {
disks[i].ToBeDetached = to.BoolPtr(true)

View File

@ -26,6 +26,7 @@ import (
// ClientConfig contains all essential information to create an Azure client.
type ClientConfig struct {
CloudName string
Location string
SubscriptionID string
ResourceManagerEndpoint string

View File

@ -22,6 +22,7 @@ import (
"context"
"fmt"
"net/http"
"strings"
"time"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
@ -57,7 +58,11 @@ type Client struct {
func New(config *azclients.ClientConfig) *Client {
baseURI := config.ResourceManagerEndpoint
authorizer := config.Authorizer
armClient := armclient.New(authorizer, baseURI, config.UserAgent, APIVersion, config.Location, config.Backoff)
apiVersion := APIVersion
if strings.EqualFold(config.CloudName, AzureStackCloudName) {
apiVersion = AzureStackCloudAPIVersion
}
armClient := armclient.New(authorizer, baseURI, config.UserAgent, apiVersion, config.Location, config.Backoff)
rateLimiterReader, rateLimiterWriter := azclients.NewRateLimiter(config.RateLimitConfig)
klog.V(2).Infof("Azure StorageAccountClient (read ops) using rate limit config: QPS=%g, bucket=%d",

View File

@ -28,6 +28,10 @@ import (
const (
// APIVersion is the API version for network.
APIVersion = "2019-06-01"
// AzureStackCloudAPIVersion is the API version for Azure Stack
AzureStackCloudAPIVersion = "2018-02-01"
// AzureStackCloudName is the cloud name of Azure Stack
AzureStackCloudName = "AZURESTACKCLOUD"
)
// Interface is the client interface for StorageAccounts.