Commit 8fd21d67 authored by Davanum Srinivas's avatar Davanum Srinivas

Don't fail fast if LoadBalancer section is missing

We should allow scenarios where cinder can be used even if the operator does not want to use the openstack load balancer. So let's warn in the beginning if subnet-id is missing but fail only if they try to use the load balancer
parent c9f8c262
......@@ -222,7 +222,8 @@ func checkOpenStackOpts(openstackOpts *OpenStack) error {
// subnet-id is required
if len(lbOpts.SubnetId) == 0 {
return fmt.Errorf("subnet-id not set in cloud provider config")
glog.Warningf("subnet-id not set in cloud provider config. " +
"OpenStack Load balancer will not work.")
}
// if need to create health monitor for Neutron LB,
......
......@@ -589,6 +589,10 @@ func nodeAddressForLB(node *v1.Node) (string, error) {
func (lbaas *LbaasV2) EnsureLoadBalancer(clusterName string, apiService *v1.Service, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) {
glog.V(4).Infof("EnsureLoadBalancer(%v, %v, %v, %v, %v, %v, %v)", clusterName, apiService.Namespace, apiService.Name, apiService.Spec.LoadBalancerIP, apiService.Spec.Ports, nodes, apiService.Annotations)
if len(lbaas.opts.SubnetId) == 0 {
return nil, fmt.Errorf("subnet-id not set in cloud provider config")
}
ports := apiService.Spec.Ports
if len(ports) == 0 {
return nil, fmt.Errorf("no ports provided to openstack load balancer")
......@@ -950,6 +954,10 @@ func (lbaas *LbaasV2) UpdateLoadBalancer(clusterName string, service *v1.Service
loadBalancerName := cloudprovider.GetLoadBalancerName(service)
glog.V(4).Infof("UpdateLoadBalancer(%v, %v, %v)", clusterName, loadBalancerName, nodes)
if len(lbaas.opts.SubnetId) == 0 {
return fmt.Errorf("subnet-id not set in cloud provider config")
}
ports := service.Spec.Ports
if len(ports) == 0 {
return fmt.Errorf("no ports provided to openstack load balancer")
......@@ -1225,6 +1233,10 @@ func (lb *LbaasV1) GetLoadBalancer(clusterName string, service *v1.Service) (*v1
func (lb *LbaasV1) EnsureLoadBalancer(clusterName string, apiService *v1.Service, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) {
glog.V(4).Infof("EnsureLoadBalancer(%v, %v, %v, %v, %v, %v, %v)", clusterName, apiService.Namespace, apiService.Name, apiService.Spec.LoadBalancerIP, apiService.Spec.Ports, nodes, apiService.Annotations)
if len(lb.opts.SubnetId) == 0 {
return nil, fmt.Errorf("subnet-id not set in cloud provider config")
}
ports := apiService.Spec.Ports
if len(ports) > 1 {
return nil, fmt.Errorf("multiple ports are not supported in openstack v1 load balancers")
......
......@@ -188,7 +188,7 @@ func TestCheckOpenStackOpts(t *testing.T) {
NodeSecurityGroupID: "b41d28c2-d02f-4e1e-8ffb-23b8e4f5c144",
},
},
expectedError: fmt.Errorf("subnet-id not set in cloud provider config"),
expectedError: nil,
},
{
name: "test3",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment