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
This commit is contained in:
Davanum Srinivas 2017-07-19 16:25:33 -04:00
parent c9f8c26209
commit 8fd21d67a8
3 changed files with 15 additions and 2 deletions

View File

@ -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,

View File

@ -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")

View File

@ -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",