mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-19 00:31:00 +00:00
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
This commit is contained in:
parent
723690c5d9
commit
2acc7d5894
@ -272,18 +272,29 @@ func (az *Cloud) reconcileLoadBalancer(lb network.LoadBalancer, pip *network.Pub
|
||||
|
||||
// Ensure LoadBalancer's Backend Pool Configuration
|
||||
if wantLb {
|
||||
if lb.Properties.BackendAddressPools == nil ||
|
||||
len(*lb.Properties.BackendAddressPools) == 0 {
|
||||
lb.Properties.BackendAddressPools = &[]network.BackendAddressPool{
|
||||
{
|
||||
Name: to.StringPtr(lbBackendPoolName),
|
||||
},
|
||||
newBackendPools := []network.BackendAddressPool{}
|
||||
if lb.Properties.BackendAddressPools != nil {
|
||||
newBackendPools = *lb.Properties.BackendAddressPools
|
||||
}
|
||||
glog.V(10).Infof("reconcile(%s)(%t): lb backendpool - adding", serviceName, wantLb)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
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
|
||||
} else if len(*lb.Properties.BackendAddressPools) != 1 ||
|
||||
!strings.EqualFold(*(*lb.Properties.BackendAddressPools)[0].Name, lbBackendPoolName) {
|
||||
return lb, false, fmt.Errorf("loadbalancer is misconfigured with a different backend pool")
|
||||
lb.Properties.BackendAddressPools = &newBackendPools
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user