mirror of https://github.com/k3s-io/k3s
Merge pull request #59083 from feiskyer/fix-59046
Automatic merge from submit-queue. 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 IP is set for Azure internal loadbalancer **What this PR does / why we need it**: Internal Load Balancer created and associated with availability set but no target network ip configurations on Azure. And kube-controller-manager would panic because of nil pointer dereference. This PR ensures it is set correctly. **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 #59046 **Special notes for your reviewer**: Should cherry-pick to v1.9 **Release note**: ```release-note Ensure IP is set for Azure internal load balancer. ```pull/6/head
commit
d8605eb7eb
|
@ -772,6 +772,19 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
|
|||
glog.V(2).Infof("ensure(%s) abort backoff: lb(%s) - updating", serviceName, lbName)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if isInternal {
|
||||
// Refresh updated lb which will be used later in other places.
|
||||
newLB, exist, err := az.getAzureLoadBalancer(lbName)
|
||||
if err != nil {
|
||||
glog.V(2).Infof("getAzureLoadBalancer(%s) failed: %v", lbName, err)
|
||||
return nil, err
|
||||
}
|
||||
if !exist {
|
||||
return nil, fmt.Errorf("load balancer %q not found", lbName)
|
||||
}
|
||||
lb = &newLB
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -173,3 +173,19 @@ func (az *Cloud) getSubnet(virtualNetworkName string, subnetName string) (subnet
|
|||
|
||||
return subnet, exists, err
|
||||
}
|
||||
|
||||
func (az *Cloud) getAzureLoadBalancer(name string) (lb network.LoadBalancer, exists bool, err error) {
|
||||
var realErr error
|
||||
|
||||
lb, err = az.LoadBalancerClient.Get(az.ResourceGroup, name, "")
|
||||
exists, realErr = checkResourceExistsFromError(err)
|
||||
if realErr != nil {
|
||||
return lb, false, realErr
|
||||
}
|
||||
|
||||
if !exists {
|
||||
return lb, false, nil
|
||||
}
|
||||
|
||||
return lb, exists, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue