Skip to content

Commit

Permalink
fix: change storage account client API version for Azure Stack
Browse files Browse the repository at this point in the history
  • Loading branch information
songjiaxun committed Nov 10, 2020
1 parent 2343b8a commit 09112ed
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
5 changes: 4 additions & 1 deletion staging/src/k8s.io/legacy-cloud-providers/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 09112ed

Please sign in to comment.