Skip to content

Commit 8245f53

Browse files
Fix panic on failure to get loadbalancer status (kubernetes#2512)
After loadbalancer creation, the controller calls a wait function that polls the Octavia API until its state turns ACTIVE, or timeout is reached. Before this patch, a failure to GET the loadbalancer in the wait function would result in a nil loadbalancer to be returned to the caller, resulting in an immediate panic when accessing its members. With this patch: * GET failures are logged and don't break the polling; * if the wait timeout is reached while GET is failing, the behaviour exactly matches what happens when reaching the timeout.
1 parent 1f9a46d commit 8245f53

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

pkg/openstack/loadbalancer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ func (lbaas *LbaasV2) createOctaviaLoadBalancer(name, clusterName string, servic
302302
}
303303

304304
if loadbalancer, err = openstackutil.WaitActiveAndGetLoadBalancer(lbaas.lb, loadbalancer.ID); err != nil {
305-
if loadbalancer.ProvisioningStatus == errorStatus {
305+
if loadbalancer != nil && loadbalancer.ProvisioningStatus == errorStatus {
306306
// If LB landed in ERROR state we should delete it and retry the creation later.
307307
if err = lbaas.deleteLoadBalancer(loadbalancer, service, svcConf, true); err != nil {
308308
return nil, fmt.Errorf("loadbalancer %s is in ERROR state and there was an error when removing it: %v", loadbalancer.ID, err)
@@ -1896,7 +1896,7 @@ func (lbaas *LbaasV2) deleteFIPIfCreatedByProvider(fip *floatingips.FloatingIP,
18961896
return true, nil
18971897
}
18981898

1899-
// deleteLoadBalancer removes the LB and it's children either by using Octavia cascade deletion or manually
1899+
// deleteLoadBalancer removes the LB and its children either by using Octavia cascade deletion or manually
19001900
func (lbaas *LbaasV2) deleteLoadBalancer(loadbalancer *loadbalancers.LoadBalancer, service *corev1.Service, svcConf *serviceConfig, needDeleteLB bool) error {
19011901
if needDeleteLB && lbaas.opts.CascadeDelete {
19021902
klog.InfoS("Deleting load balancer", "lbID", loadbalancer.ID, "service", klog.KObj(service))

pkg/util/openstack/loadbalancer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ func WaitActiveAndGetLoadBalancer(client *gophercloud.ServiceClient, loadbalance
177177
var err error
178178
loadbalancer, err = loadbalancers.Get(client, loadbalancerID).Extract()
179179
if mc.ObserveRequest(err) != nil {
180-
return false, err
180+
klog.Warningf("Failed to fetch loadbalancer status from OpenStack (lbID %q): %s", loadbalancerID, err)
181+
return false, nil
181182
}
182183
if loadbalancer.ProvisioningStatus == activeStatus {
183184
klog.InfoS("Load balancer ACTIVE", "lbID", loadbalancerID)

0 commit comments

Comments
 (0)