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
bea2d8d1
Commit
bea2d8d1
authored
Dec 02, 2017
by
Manuel de Brito Fontes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix NLB icmp permission duplication
parent
db2977fb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
22 deletions
+66
-22
aws_loadbalancer.go
pkg/cloudprovider/providers/aws/aws_loadbalancer.go
+66
-22
No files found.
pkg/cloudprovider/providers/aws/aws_loadbalancer.go
View file @
bea2d8d1
...
@@ -662,7 +662,6 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLBTraffic(actualGroups []*ec2.Se
...
@@ -662,7 +662,6 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLBTraffic(actualGroups []*ec2.Se
if
clientTraffic
{
if
clientTraffic
{
clientRuleAnnotation
:=
fmt
.
Sprintf
(
"%s=%s"
,
NLBClientRuleDescription
,
lbName
)
clientRuleAnnotation
:=
fmt
.
Sprintf
(
"%s=%s"
,
NLBClientRuleDescription
,
lbName
)
mtuRuleAnnotation
:=
fmt
.
Sprintf
(
"%s=%s"
,
NLBMtuDiscoveryRuleDescription
,
lbName
)
// Client Traffic
// Client Traffic
permission
:=
&
ec2
.
IpPermission
{
permission
:=
&
ec2
.
IpPermission
{
FromPort
:
aws
.
Int64
(
port
),
FromPort
:
aws
.
Int64
(
port
),
...
@@ -682,26 +681,6 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLBTraffic(actualGroups []*ec2.Se
...
@@ -682,26 +681,6 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLBTraffic(actualGroups []*ec2.Se
}
else
{
}
else
{
removes
=
append
(
removes
,
permission
)
removes
=
append
(
removes
,
permission
)
}
}
// MTU discovery
permission
=
&
ec2
.
IpPermission
{
IpProtocol
:
aws
.
String
(
"icmp"
),
FromPort
:
aws
.
Int64
(
3
),
ToPort
:
aws
.
Int64
(
4
),
}
ranges
=
[]
*
ec2
.
IpRange
{}
for
_
,
cidr
:=
range
clientCidrs
{
ranges
=
append
(
ranges
,
&
ec2
.
IpRange
{
CidrIp
:
aws
.
String
(
cidr
),
Description
:
aws
.
String
(
mtuRuleAnnotation
),
})
}
permission
.
IpRanges
=
ranges
if
add
{
adds
=
append
(
adds
,
permission
)
}
else
{
removes
=
append
(
removes
,
permission
)
}
}
else
{
}
else
{
healthRuleAnnotation
:=
fmt
.
Sprintf
(
"%s=%s"
,
NLBHealthCheckRuleDescription
,
lbName
)
healthRuleAnnotation
:=
fmt
.
Sprintf
(
"%s=%s"
,
NLBHealthCheckRuleDescription
,
lbName
)
...
@@ -725,8 +704,8 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLBTraffic(actualGroups []*ec2.Se
...
@@ -725,8 +704,8 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLBTraffic(actualGroups []*ec2.Se
removes
=
append
(
removes
,
permission
)
removes
=
append
(
removes
,
permission
)
}
}
}
}
}
}
if
len
(
adds
)
>
0
{
if
len
(
adds
)
>
0
{
changed
,
err
:=
c
.
addSecurityGroupIngress
(
instanceSecurityGroupID
,
adds
)
changed
,
err
:=
c
.
addSecurityGroupIngress
(
instanceSecurityGroupID
,
adds
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -736,6 +715,7 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLBTraffic(actualGroups []*ec2.Se
...
@@ -736,6 +715,7 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLBTraffic(actualGroups []*ec2.Se
glog
.
Warning
(
"Allowing ingress was not needed; concurrent change? groupId="
,
instanceSecurityGroupID
)
glog
.
Warning
(
"Allowing ingress was not needed; concurrent change? groupId="
,
instanceSecurityGroupID
)
}
}
}
}
if
len
(
removes
)
>
0
{
if
len
(
removes
)
>
0
{
changed
,
err
:=
c
.
removeSecurityGroupIngress
(
instanceSecurityGroupID
,
removes
)
changed
,
err
:=
c
.
removeSecurityGroupIngress
(
instanceSecurityGroupID
,
removes
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -745,6 +725,70 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLBTraffic(actualGroups []*ec2.Se
...
@@ -745,6 +725,70 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLBTraffic(actualGroups []*ec2.Se
glog
.
Warning
(
"Revoking ingress was not needed; concurrent change? groupId="
,
instanceSecurityGroupID
)
glog
.
Warning
(
"Revoking ingress was not needed; concurrent change? groupId="
,
instanceSecurityGroupID
)
}
}
}
}
if
clientTraffic
{
// MTU discovery
mtuRuleAnnotation
:=
fmt
.
Sprintf
(
"%s=%s"
,
NLBMtuDiscoveryRuleDescription
,
lbName
)
mtuPermission
:=
&
ec2
.
IpPermission
{
IpProtocol
:
aws
.
String
(
"icmp"
),
FromPort
:
aws
.
Int64
(
3
),
ToPort
:
aws
.
Int64
(
4
),
}
ranges
:=
[]
*
ec2
.
IpRange
{}
for
_
,
cidr
:=
range
clientCidrs
{
ranges
=
append
(
ranges
,
&
ec2
.
IpRange
{
CidrIp
:
aws
.
String
(
cidr
),
Description
:
aws
.
String
(
mtuRuleAnnotation
),
})
}
mtuPermission
.
IpRanges
=
ranges
group
,
err
:=
c
.
findSecurityGroup
(
instanceSecurityGroupID
)
if
err
!=
nil
{
glog
.
Warningf
(
"Error retrieving security group: %q"
,
err
)
return
err
}
if
group
==
nil
{
glog
.
Warning
(
"Security group not found: "
,
instanceSecurityGroupID
)
return
nil
}
icmpExists
:=
false
permCount
:=
0
for
_
,
perm
:=
range
group
.
IpPermissions
{
if
*
perm
.
IpProtocol
==
"icmp"
{
icmpExists
=
true
continue
}
if
perm
.
FromPort
!=
nil
{
permCount
++
}
}
if
!
icmpExists
&&
permCount
>
0
{
// the icmp permission is missing
changed
,
err
:=
c
.
addSecurityGroupIngress
(
instanceSecurityGroupID
,
[]
*
ec2
.
IpPermission
{
mtuPermission
})
if
err
!=
nil
{
glog
.
Warningf
(
"Error adding MTU permission to security group: %q"
,
err
)
return
err
}
if
!
changed
{
glog
.
Warning
(
"Allowing ingress was not needed; concurrent change? groupId="
,
instanceSecurityGroupID
)
}
}
else
if
icmpExists
&&
permCount
==
0
{
// there is no additional permissions, remove icmp
changed
,
err
:=
c
.
removeSecurityGroupIngress
(
instanceSecurityGroupID
,
[]
*
ec2
.
IpPermission
{
mtuPermission
})
if
err
!=
nil
{
glog
.
Warningf
(
"Error removing MTU permission to security group: %q"
,
err
)
return
err
}
if
!
changed
{
glog
.
Warning
(
"Revoking ingress was not needed; concurrent change? groupId="
,
instanceSecurityGroupID
)
}
}
}
}
}
return
nil
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