Merge pull request #36882 from vwfs/azure_lb_backendpool

Automatic merge from submit-queue (batch tested with PRs 38076, 38137, 36882, 37634, 37558)

Allow backendpools in Azure Load Balancers which are not owned by cloud provider

**What this PR does / why we need it**: It fixes #36880

**Which issue this PR fixes**: fixes #36880

**Special notes for your reviewer**:

**Release note**:
```release-note
Allow backendpools in Azure Load Balancers which are not owned by cloud provider
```

Instead of bailing out when we find another backend pool, we just ignore
other backend pools and add ours to the list of existing.

Fixes #36880
pull/6/head
Kubernetes Submit Queue 2016-12-05 19:25:53 -08:00 committed by GitHub
commit f7352aeb61
1 changed files with 21 additions and 10 deletions

View File

@ -272,18 +272,29 @@ func (az *Cloud) reconcileLoadBalancer(lb network.LoadBalancer, pip *network.Pub
// Ensure LoadBalancer's Backend Pool Configuration // Ensure LoadBalancer's Backend Pool Configuration
if wantLb { if wantLb {
if lb.Properties.BackendAddressPools == nil || newBackendPools := []network.BackendAddressPool{}
len(*lb.Properties.BackendAddressPools) == 0 { if lb.Properties.BackendAddressPools != nil {
lb.Properties.BackendAddressPools = &[]network.BackendAddressPool{ newBackendPools = *lb.Properties.BackendAddressPools
{ }
Name: to.StringPtr(lbBackendPoolName),
}, foundBackendPool := false
for _, bp := range newBackendPools {
if strings.EqualFold(*bp.Name, lbBackendPoolName) {
glog.V(10).Infof("reconcile(%s)(%t): lb backendpool - found wanted backendpool. not adding anything", serviceName, wantLb)
foundBackendPool = true
break
} else {
glog.V(10).Infof("reconcile(%s)(%t): lb backendpool - found other backendpool %s", serviceName, wantLb, *bp.Name)
} }
glog.V(10).Infof("reconcile(%s)(%t): lb backendpool - adding", serviceName, wantLb) }
if !foundBackendPool {
newBackendPools = append(newBackendPools, network.BackendAddressPool{
Name: to.StringPtr(lbBackendPoolName),
})
glog.V(10).Infof("reconcile(%s)(%t): lb backendpool - adding backendpool", serviceName, wantLb)
dirtyLb = true dirtyLb = true
} else if len(*lb.Properties.BackendAddressPools) != 1 || lb.Properties.BackendAddressPools = &newBackendPools
!strings.EqualFold(*(*lb.Properties.BackendAddressPools)[0].Name, lbBackendPoolName) {
return lb, false, fmt.Errorf("loadbalancer is misconfigured with a different backend pool")
} }
} }