Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
370ad205
Commit
370ad205
authored
Oct 09, 2017
by
FengyunPan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[OpenStack]Add codes to check the count of nodes(members)
After merging this PR(#53146), if there is no available nodes for the loadbalancer service, UpdateLoadBalancer() will run panic.
parent
6e2249b7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
openstack_loadbalancer.go
...oudprovider/providers/openstack/openstack_loadbalancer.go
+9
-1
No files found.
pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go
View file @
370ad205
...
...
@@ -623,6 +623,10 @@ func getSubnetIDForLB(compute *gophercloud.ServiceClient, node v1.Node) (string,
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
(
nodes
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"There are no available nodes for LoadBalancer service %s/%s"
,
apiService
.
Namespace
,
apiService
.
Name
)
}
if
len
(
lbaas
.
opts
.
SubnetId
)
==
0
{
// Get SubnetId automatically.
// The LB needs to be configured with instance addresses on the same subnet, so get SubnetId by one node.
...
...
@@ -1024,7 +1028,7 @@ 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
{
if
len
(
lbaas
.
opts
.
SubnetId
)
==
0
&&
len
(
nodes
)
>
0
{
// Get SubnetId automatically.
// The LB needs to be configured with instance addresses on the same subnet, so get SubnetId by one node.
subnetID
,
err
:=
getSubnetIDForLB
(
lbaas
.
compute
,
*
nodes
[
0
])
...
...
@@ -1322,6 +1326,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
(
nodes
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"There are no available nodes for LoadBalancer service %s/%s"
,
apiService
.
Namespace
,
apiService
.
Name
)
}
if
len
(
lb
.
opts
.
SubnetId
)
==
0
{
// Get SubnetId automatically.
// The LB needs to be configured with instance addresses on the same subnet, so get SubnetId by one node.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment