Skip to content

Commit

Permalink
Merge pull request #10 from lobziik/disable-zones-ocp
Browse files Browse the repository at this point in the history
Bug 1987255: UPSTREAM: <716>: Disable zones on azure stack cloud
  • Loading branch information
openshift-merge-robot committed Jul 29, 2021
2 parents 799f060 + efebd6a commit c02678d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
27 changes: 20 additions & 7 deletions pkg/provider/azure.go
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/provider/azure_zones.go
Expand Up @@ -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()
Expand Down

0 comments on commit c02678d

Please sign in to comment.