From ae1e452e7d6d48c07becceac1bb5d894be515044 Mon Sep 17 00:00:00 2001 From: Jiaxun Song Date: Mon, 23 Nov 2020 23:13:19 -0800 Subject: [PATCH] fix: change disk client API version for Azure Stack --- .../azure/clients/diskclient/azure_diskclient.go | 7 ++++++- .../azure/clients/diskclient/interface.go | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/legacy-cloud-providers/azure/clients/diskclient/azure_diskclient.go b/staging/src/k8s.io/legacy-cloud-providers/azure/clients/diskclient/azure_diskclient.go index d0de9c5611f95..cd8a85a5d7f3e 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/azure/clients/diskclient/azure_diskclient.go +++ b/staging/src/k8s.io/legacy-cloud-providers/azure/clients/diskclient/azure_diskclient.go @@ -22,6 +22,7 @@ import ( "context" "fmt" "net/http" + "strings" "time" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute" @@ -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 DisksClient (read ops) using rate limit config: QPS=%g, bucket=%d", diff --git a/staging/src/k8s.io/legacy-cloud-providers/azure/clients/diskclient/interface.go b/staging/src/k8s.io/legacy-cloud-providers/azure/clients/diskclient/interface.go index f68c4282c4bd8..f3bf2ff796e49 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/azure/clients/diskclient/interface.go +++ b/staging/src/k8s.io/legacy-cloud-providers/azure/clients/diskclient/interface.go @@ -28,6 +28,10 @@ import ( const ( // APIVersion is the API version for compute. APIVersion = "2019-11-01" + // AzureStackCloudAPIVersion is the API version for Azure Stack + AzureStackCloudAPIVersion = "2019-07-01" + // AzureStackCloudName is the cloud name of Azure Stack + AzureStackCloudName = "AZURESTACKCLOUD" ) // Interface is the client interface for Disks.