Skip to content

Commit 32540b0

Browse files
authored
Merge pull request kubernetes#90280 from gaurav1086/azure_lb_remove_unncessary_check
[Provider/Azure] remove unncessary nil check for range
2 parents e951061 + a0c2af4 commit 32540b0

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

staging/src/k8s.io/legacy-cloud-providers/azure/azure_loadbalancer.go

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -265,26 +265,24 @@ func (az *Cloud) getServiceLoadBalancer(service *v1.Service, clusterName string,
265265
}
266266

267267
// check if the service already has a load balancer
268-
if existingLBs != nil {
269-
for i := range existingLBs {
270-
existingLB := existingLBs[i]
271-
if strings.EqualFold(*existingLB.Name, defaultLBName) {
272-
defaultLB = &existingLB
273-
}
274-
if isInternalLoadBalancer(&existingLB) != isInternal {
275-
continue
276-
}
277-
status, err = az.getServiceLoadBalancerStatus(service, &existingLB)
278-
if err != nil {
279-
return nil, nil, false, err
280-
}
281-
if status == nil {
282-
// service is not on this load balancer
283-
continue
284-
}
285-
286-
return &existingLB, status, true, nil
268+
for i := range existingLBs {
269+
existingLB := existingLBs[i]
270+
if strings.EqualFold(*existingLB.Name, defaultLBName) {
271+
defaultLB = &existingLB
287272
}
273+
if isInternalLoadBalancer(&existingLB) != isInternal {
274+
continue
275+
}
276+
status, err = az.getServiceLoadBalancerStatus(service, &existingLB)
277+
if err != nil {
278+
return nil, nil, false, err
279+
}
280+
if status == nil {
281+
// service is not on this load balancer
282+
continue
283+
}
284+
285+
return &existingLB, status, true, nil
288286
}
289287

290288
hasMode, _, _ := getServiceLoadBalancerMode(service)

0 commit comments

Comments
 (0)