From efebd6a17e20878eb52fb8b95d95f5563b1a7b08 Mon Sep 17 00:00:00 2001 From: Denis Moiseev Date: Fri, 23 Jul 2021 18:00:12 +0200 Subject: [PATCH] UPSTREAM: 716: Disable zones on azure stack cloud --- pkg/provider/azure.go | 27 ++++++++++++++++++++------- pkg/provider/azure_zones.go | 7 +++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/pkg/provider/azure.go b/pkg/provider/azure.go index 644082e8a9..386c88a80d 100644 --- a/pkg/provider/azure.go +++ b/pkg/provider/azure.go @@ -573,14 +573,18 @@ func (az *Cloud) InitializeCloudFromConfig(config *Config, fromSecret, callFromC az.routeUpdater = newDelayedRouteUpdater(az, routeUpdateInterval) go az.routeUpdater.run() - // wait for the success first time of syncing zones - err = az.syncRegionZonesMap() - if err != nil { - klog.Errorf("InitializeCloudFromConfig: failed to sync regional zones map for the first time: %s", err.Error()) - return err - } + // Azure Stack does not support zones at the moment + // https://docs.microsoft.com/en-us/azure-stack/user/azure-stack-network-differences?view=azs-2102 + if !az.isStackCloud() { + // wait for the success first time of syncing zones + err = az.syncRegionZonesMap() + if err != nil { + klog.Errorf("InitializeCloudFromConfig: failed to sync regional zones map for the first time: %s", err.Error()) + return err + } - go az.refreshZones(az.syncRegionZonesMap) + go az.refreshZones(az.syncRegionZonesMap) + } } return nil @@ -824,6 +828,10 @@ func parseConfig(configReader io.Reader) (*Config, error) { return &config, nil } +func (az *Cloud) isStackCloud() bool { + return strings.EqualFold(az.Config.Cloud, consts.AzureStackCloudName) && !az.Config.DisableAzureStackCloud +} + // Initialize passes a Kubernetes clientBuilder interface to the cloud provider func (az *Cloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{}) { az.KubeClient = clientBuilder.ClientOrDie("azure-cloud-provider") @@ -849,6 +857,11 @@ func (az *Cloud) InstancesV2() (cloudprovider.InstancesV2, bool) { // Zones returns a zones interface. Also returns true if the interface is supported, false otherwise. func (az *Cloud) Zones() (cloudprovider.Zones, bool) { + if az.isStackCloud() { + // Azure stack does not support zones at this point + // https://docs.microsoft.com/en-us/azure-stack/user/azure-stack-network-differences?view=azs-2102 + return nil, false + } return az, true } diff --git a/pkg/provider/azure_zones.go b/pkg/provider/azure_zones.go index e2180df605..c190c30715 100644 --- a/pkg/provider/azure_zones.go +++ b/pkg/provider/azure_zones.go @@ -73,6 +73,13 @@ func (az *Cloud) updateRegionZonesMap(zones map[string][]string) { } func (az *Cloud) getRegionZonesBackoff(region string) ([]string, error) { + if az.isStackCloud() { + // Azure Stack does not support zones at the moment + // https://docs.microsoft.com/en-us/azure-stack/user/azure-stack-network-differences?view=azs-2102 + klog.V(3).Infof("getRegionZonesMapWrapper: Azure Stack does not support Zones at the moment, skipping") + return az.regionZonesMap[region], nil + } + if len(az.regionZonesMap) != 0 { az.refreshZonesLock.RLock() defer az.refreshZonesLock.RUnlock()