Merge pull request #49235 from dims/allow-cinder-scenarios-without-load-balancer
Automatic merge from submit-queue (batch tested with PRs 49276, 49235) Don't fail fast if LoadBalancer section is missing **What this PR does / why we need it**: 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 **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
This commit is contained in:
		| @@ -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", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Submit Queue
					Kubernetes Submit Queue