mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
fix: change storage account client API version for Azure Stack
This commit is contained in:
parent
2343b8a68b
commit
09112ed1f4
@ -74,6 +74,8 @@ import (
|
|||||||
const (
|
const (
|
||||||
// CloudProviderName is the value used for the --cloud-provider flag
|
// 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
|
rateLimitQPSDefault = 1.0
|
||||||
rateLimitBucketDefault = 5
|
rateLimitBucketDefault = 5
|
||||||
backoffRetriesDefault = 6
|
backoffRetriesDefault = 6
|
||||||
@ -609,6 +611,7 @@ func (az *Cloud) configAzureClients(
|
|||||||
|
|
||||||
func (az *Cloud) getAzureClientConfig(servicePrincipalToken *adal.ServicePrincipalToken) *azclients.ClientConfig {
|
func (az *Cloud) getAzureClientConfig(servicePrincipalToken *adal.ServicePrincipalToken) *azclients.ClientConfig {
|
||||||
azClientConfig := &azclients.ClientConfig{
|
azClientConfig := &azclients.ClientConfig{
|
||||||
|
CloudName: az.Config.Cloud,
|
||||||
Location: az.Config.Location,
|
Location: az.Config.Location,
|
||||||
SubscriptionID: az.Config.SubscriptionID,
|
SubscriptionID: az.Config.SubscriptionID,
|
||||||
ResourceManagerEndpoint: az.Environment.ResourceManagerEndpoint,
|
ResourceManagerEndpoint: az.Environment.ResourceManagerEndpoint,
|
||||||
|
@ -141,7 +141,7 @@ func (as *availabilitySet) DetachDisk(diskName, diskURI string, nodeName types.N
|
|||||||
(disk.ManagedDisk != nil && diskURI != "" && strings.EqualFold(*disk.ManagedDisk.ID, diskURI)) {
|
(disk.ManagedDisk != nil && diskURI != "" && strings.EqualFold(*disk.ManagedDisk.ID, diskURI)) {
|
||||||
// found the disk
|
// found the disk
|
||||||
klog.V(2).Infof("azureDisk - detach disk: name %q uri %q", diskName, diskURI)
|
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:]...)
|
disks = append(disks[:i], disks[i+1:]...)
|
||||||
} else {
|
} else {
|
||||||
disks[i].ToBeDetached = to.BoolPtr(true)
|
disks[i].ToBeDetached = to.BoolPtr(true)
|
||||||
|
@ -143,7 +143,7 @@ func (ss *scaleSet) DetachDisk(diskName, diskURI string, nodeName types.NodeName
|
|||||||
(disk.ManagedDisk != nil && diskURI != "" && strings.EqualFold(*disk.ManagedDisk.ID, diskURI)) {
|
(disk.ManagedDisk != nil && diskURI != "" && strings.EqualFold(*disk.ManagedDisk.ID, diskURI)) {
|
||||||
// found the disk
|
// found the disk
|
||||||
klog.V(2).Infof("azureDisk - detach disk: name %q uri %q", diskName, diskURI)
|
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:]...)
|
disks = append(disks[:i], disks[i+1:]...)
|
||||||
} else {
|
} else {
|
||||||
disks[i].ToBeDetached = to.BoolPtr(true)
|
disks[i].ToBeDetached = to.BoolPtr(true)
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
|
|
||||||
// ClientConfig contains all essential information to create an Azure client.
|
// ClientConfig contains all essential information to create an Azure client.
|
||||||
type ClientConfig struct {
|
type ClientConfig struct {
|
||||||
|
CloudName string
|
||||||
Location string
|
Location string
|
||||||
SubscriptionID string
|
SubscriptionID string
|
||||||
ResourceManagerEndpoint string
|
ResourceManagerEndpoint string
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
|
"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 {
|
func New(config *azclients.ClientConfig) *Client {
|
||||||
baseURI := config.ResourceManagerEndpoint
|
baseURI := config.ResourceManagerEndpoint
|
||||||
authorizer := config.Authorizer
|
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)
|
rateLimiterReader, rateLimiterWriter := azclients.NewRateLimiter(config.RateLimitConfig)
|
||||||
|
|
||||||
klog.V(2).Infof("Azure StorageAccountClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure StorageAccountClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
|
@ -28,6 +28,10 @@ import (
|
|||||||
const (
|
const (
|
||||||
// APIVersion is the API version for network.
|
// APIVersion is the API version for network.
|
||||||
APIVersion = "2019-06-01"
|
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.
|
// Interface is the client interface for StorageAccounts.
|
||||||
|
Loading…
Reference in New Issue
Block a user