check service status value returned by EnsureLoadBalancer

when service status returned by EnsureLoadBalancer is nil, return the
function directly to avoid NPE
This commit is contained in:
Rong Gao 2019-11-21 21:44:44 +08:00
parent 3c5dad61f7
commit 99603e105a

View File

@ -351,6 +351,10 @@ func (s *Controller) syncLoadBalancerIfNeeded(service *v1.Service, key string) (
}
return op, fmt.Errorf("failed to ensure load balancer: %v", err)
}
if newStatus == nil {
return op, fmt.Errorf("service status returned by EnsureLoadBalancer is nil")
}
s.eventRecorder.Event(service, v1.EventTypeNormal, "EnsuredLoadBalancer", "Ensured load balancer")
}