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
5613dec9
Commit
5613dec9
authored
Jan 19, 2018
by
FengyunPan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove getOldSecurityGroupName() from OpenStack cloud provider
Related to #53764 The getOldSecurityGroupName() is used to get the old security group name, we can remove it now.
parent
5d8a2b9e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
79 deletions
+0
-79
openstack_loadbalancer.go
...oudprovider/providers/openstack/openstack_loadbalancer.go
+0
-79
No files found.
pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go
View file @
5613dec9
...
...
@@ -959,14 +959,6 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(clusterName string, apiService *v1.Serv
_
=
lbaas
.
EnsureLoadBalancerDeleted
(
clusterName
,
apiService
)
return
status
,
err
}
// delete the old Security Group for the service
// Related to #53764
// TODO(FengyunPan): Remove it at V1.10
err
=
lbaas
.
EnsureOldSecurityGroupDeleted
(
clusterName
,
apiService
)
if
err
!=
nil
{
return
status
,
fmt
.
Errorf
(
"Failed to delete the Security Group for loadbalancer service %s/%s: %v"
,
apiService
.
Namespace
,
apiService
.
Name
,
err
)
}
}
return
status
,
nil
...
...
@@ -1492,14 +1484,6 @@ func (lbaas *LbaasV2) EnsureLoadBalancerDeleted(clusterName string, service *v1.
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to delete Security Group for loadbalancer service %s/%s: %v"
,
service
.
Namespace
,
service
.
Name
,
err
)
}
// delete the old Security Group for the service
// Related to #53764
// TODO(FengyunPan): Remove it at V1.10
err
=
lbaas
.
EnsureOldSecurityGroupDeleted
(
clusterName
,
service
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to delete the Security Group for loadbalancer service %s/%s: %v"
,
service
.
Namespace
,
service
.
Name
,
err
)
}
}
return
nil
...
...
@@ -1557,66 +1541,3 @@ func (lbaas *LbaasV2) EnsureSecurityGroupDeleted(clusterName string, service *v1
return
nil
}
// getOldSecurityGroupName is used to get the old security group name
// Related to #53764
// TODO(FengyunPan): Remove it at V1.10
func
getOldSecurityGroupName
(
clusterName
string
,
service
*
v1
.
Service
)
string
{
return
fmt
.
Sprintf
(
"lb-sg-%s-%v"
,
clusterName
,
service
.
Name
)
}
// EnsureOldSecurityGroupDeleted deleting old security group for specific loadbalancer service.
// Related to #53764
// TODO(FengyunPan): Remove it at V1.10
func
(
lbaas
*
LbaasV2
)
EnsureOldSecurityGroupDeleted
(
clusterName
string
,
service
*
v1
.
Service
)
error
{
glog
.
V
(
4
)
.
Infof
(
"EnsureOldSecurityGroupDeleted(%v, %v)"
,
clusterName
,
service
)
// Generate Name
lbSecGroupName
:=
getOldSecurityGroupName
(
clusterName
,
service
)
lbSecGroupID
,
err
:=
groups
.
IDFromName
(
lbaas
.
network
,
lbSecGroupName
)
if
err
!=
nil
{
// check whether security group does not exist
_
,
ok
:=
err
.
(
*
gophercloud
.
ErrResourceNotFound
)
if
ok
{
// It is OK when the security group has been deleted by others.
return
nil
}
else
{
return
fmt
.
Errorf
(
"Error occurred finding security group: %s: %v"
,
lbSecGroupName
,
err
)
}
}
lbSecGroup
:=
groups
.
Delete
(
lbaas
.
network
,
lbSecGroupID
)
if
lbSecGroup
.
Err
!=
nil
&&
!
isNotFound
(
lbSecGroup
.
Err
)
{
return
lbSecGroup
.
Err
}
if
len
(
lbaas
.
opts
.
NodeSecurityGroupIDs
)
==
0
{
// Just happen when nodes have not Security Group, or should not happen
// UpdateLoadBalancer and EnsureLoadBalancer can set lbaas.opts.NodeSecurityGroupIDs when it is empty
// And service controller call UpdateLoadBalancer to set lbaas.opts.NodeSecurityGroupIDs when controller manager service is restarted.
glog
.
Warningf
(
"Can not find node-security-group from all the nodes of this cluster when delete loadbalancer service %s/%s"
,
service
.
Namespace
,
service
.
Name
)
}
else
{
// Delete the rules in the Node Security Group
for
_
,
nodeSecurityGroupID
:=
range
lbaas
.
opts
.
NodeSecurityGroupIDs
{
opts
:=
rules
.
ListOpts
{
SecGroupID
:
nodeSecurityGroupID
,
RemoteGroupID
:
lbSecGroupID
,
}
secGroupRules
,
err
:=
getSecurityGroupRules
(
lbaas
.
network
,
opts
)
if
err
!=
nil
&&
!
isNotFound
(
err
)
{
msg
:=
fmt
.
Sprintf
(
"Error finding rules for remote group id %s in security group id %s: %v"
,
lbSecGroupID
,
nodeSecurityGroupID
,
err
)
return
fmt
.
Errorf
(
msg
)
}
for
_
,
rule
:=
range
secGroupRules
{
res
:=
rules
.
Delete
(
lbaas
.
network
,
rule
.
ID
)
if
res
.
Err
!=
nil
&&
!
isNotFound
(
res
.
Err
)
{
return
fmt
.
Errorf
(
"Error occurred deleting security group rule: %s: %v"
,
rule
.
ID
,
res
.
Err
)
}
}
}
}
return
nil
}
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