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
2520d4be
Commit
2520d4be
authored
Jan 23, 2018
by
FengyunPan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix non-interface type ErrResourceNotFound on left
Related to #58145 The gophercloud.ErrResourceNotFound is not a interface, so should use reflect to get its type then do a check.
parent
1789a851
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
7 deletions
+19
-7
openstack_loadbalancer.go
...oudprovider/providers/openstack/openstack_loadbalancer.go
+19
-7
No files found.
pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go
View file @
2520d4be
...
...
@@ -19,6 +19,7 @@ package openstack
import
(
"fmt"
"net"
"reflect"
"strings"
"time"
...
...
@@ -568,6 +569,21 @@ func getNodeSecurityGroupIDForLB(compute *gophercloud.ServiceClient, nodes []*v1
return
nodeSecurityGroupIDs
.
List
(),
nil
}
// isSecurityGroupNotFound return true while 'err' is object of gophercloud.ErrResourceNotFound
func
isSecurityGroupNotFound
(
err
error
)
bool
{
errType
:=
reflect
.
TypeOf
(
err
)
.
String
()
errTypeSlice
:=
strings
.
Split
(
errType
,
"."
)
errTypeValue
:=
""
if
len
(
errTypeSlice
)
!=
0
{
errTypeValue
=
errTypeSlice
[
len
(
errTypeSlice
)
-
1
]
}
if
errTypeValue
==
"ErrResourceNotFound"
{
return
true
}
return
false
}
// getFloatingNetworkIdForLB returns a floating-network-id for cluster.
func
getFloatingNetworkIdForLB
(
client
*
gophercloud
.
ServiceClient
)
(
string
,
error
)
{
var
floatingNetworkIds
[]
string
...
...
@@ -993,10 +1009,8 @@ func (lbaas *LbaasV2) ensureSecurityGroup(clusterName string, apiService *v1.Ser
lbSecGroupName
:=
getSecurityGroupName
(
apiService
)
lbSecGroupID
,
err
:=
groups
.
IDFromName
(
lbaas
.
network
,
lbSecGroupName
)
if
err
!=
nil
{
// check whether security group does not exist
_
,
ok
:=
err
.
(
*
gophercloud
.
ErrResourceNotFound
)
if
ok
{
// create it later
// If the security group of LB not exist, create it later
if
isSecurityGroupNotFound
(
err
)
{
lbSecGroupID
=
""
}
else
{
return
fmt
.
Errorf
(
"error occurred finding security group: %s: %v"
,
lbSecGroupName
,
err
)
...
...
@@ -1495,9 +1509,7 @@ func (lbaas *LbaasV2) EnsureSecurityGroupDeleted(clusterName string, service *v1
lbSecGroupName
:=
getSecurityGroupName
(
service
)
lbSecGroupID
,
err
:=
groups
.
IDFromName
(
lbaas
.
network
,
lbSecGroupName
)
if
err
!=
nil
{
// check whether security group does not exist
_
,
ok
:=
err
.
(
*
gophercloud
.
ErrResourceNotFound
)
if
ok
{
if
isSecurityGroupNotFound
(
err
)
{
// It is OK when the security group has been deleted by others.
return
nil
}
else
{
...
...
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