mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
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:
e7ed9b408a/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
This commit is contained in:
commit
4b26d70daf
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user