Unverified Commit 4b26d70d authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #62450 from feiskyer/select-lb

Automatic merge from submit-queue (batch tested with PRs 62146, 62450). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Ensure expected load balancer is selected for Azure **What this PR does / why we need it**: Azure cloud provider is always selecting the last element of LB list. The reason is: getServiceLoadBalancer() refers the pointer of an local variable within for loop: https://github.com/kubernetes/kubernetes/blob/e7ed9b408adaaec1e5ddfc167fc18b6aaeca425f/pkg/cloudprovider/providers/azure/azure_loadbalancer.go#L202-L206 This is a common mistake as golang is actually reusing same variable within the loop. This PR fixes this issue. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #62449 **Special notes for your reviewer**: **Release note**: ```release-note Ensure expected load balancer is selected for Azure ``` /sig azure /kind bug
parents 39194c13 0f0e2719
......@@ -199,7 +199,8 @@ func (az *Cloud) getServiceLoadBalancer(service *v1.Service, clusterName string,
// check if the service already has a load balancer
if existingLBs != nil {
for _, existingLB := range existingLBs {
for i := range existingLBs {
existingLB := existingLBs[i]
if strings.EqualFold(*existingLB.Name, defaultLBName) {
defaultLB = &existingLB
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment