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
9803840b
Commit
9803840b
authored
Jun 12, 2017
by
Justin Santa Barbara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AWS: Perform ELB listener comparison in case-insensitive manner
Fix #47067
parent
17244ea5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
149 additions
and
3 deletions
+149
-3
BUILD
pkg/cloudprovider/providers/aws/BUILD
+1
-0
aws_loadbalancer.go
pkg/cloudprovider/providers/aws/aws_loadbalancer.go
+21
-3
aws_loadbalancer_test.go
pkg/cloudprovider/providers/aws/aws_loadbalancer_test.go
+127
-0
No files found.
pkg/cloudprovider/providers/aws/BUILD
View file @
9803840b
...
@@ -56,6 +56,7 @@ go_library(
...
@@ -56,6 +56,7 @@ go_library(
go_test(
go_test(
name = "go_default_test",
name = "go_default_test",
srcs = [
srcs = [
"aws_loadbalancer_test.go",
"aws_test.go",
"aws_test.go",
"device_allocator_test.go",
"device_allocator_test.go",
"regions_test.go",
"regions_test.go",
...
...
pkg/cloudprovider/providers/aws/aws_loadbalancer.go
View file @
9803840b
...
@@ -190,10 +190,10 @@ func (c *Cloud) ensureLoadBalancer(namespacedName types.NamespacedName, loadBala
...
@@ -190,10 +190,10 @@ func (c *Cloud) ensureLoadBalancer(namespacedName types.NamespacedName, loadBala
found
:=
-
1
found
:=
-
1
for
i
,
expected
:=
range
listeners
{
for
i
,
expected
:=
range
listeners
{
if
orEmpty
(
actual
.
Protocol
)
!=
orEmpty
(
expected
.
Protocol
)
{
if
elbProtocolsAreEqual
(
actual
.
Protocol
,
expected
.
Protocol
)
{
continue
continue
}
}
if
orEmpty
(
actual
.
InstanceProtocol
)
!=
orEmpty
(
expected
.
InstanceProtocol
)
{
if
elbProtocolsAreEqual
(
actual
.
InstanceProtocol
,
expected
.
InstanceProtocol
)
{
continue
continue
}
}
if
orZero
(
actual
.
InstancePort
)
!=
orZero
(
expected
.
InstancePort
)
{
if
orZero
(
actual
.
InstancePort
)
!=
orZero
(
expected
.
InstancePort
)
{
...
@@ -202,7 +202,7 @@ func (c *Cloud) ensureLoadBalancer(namespacedName types.NamespacedName, loadBala
...
@@ -202,7 +202,7 @@ func (c *Cloud) ensureLoadBalancer(namespacedName types.NamespacedName, loadBala
if
orZero
(
actual
.
LoadBalancerPort
)
!=
orZero
(
expected
.
LoadBalancerPort
)
{
if
orZero
(
actual
.
LoadBalancerPort
)
!=
orZero
(
expected
.
LoadBalancerPort
)
{
continue
continue
}
}
if
orEmpty
(
actual
.
SSLCertificateId
)
!=
orEmpty
(
expected
.
SSLCertificateId
)
{
if
awsArnEquals
(
actual
.
SSLCertificateId
,
expected
.
SSLCertificateId
)
{
continue
continue
}
}
found
=
i
found
=
i
...
@@ -355,6 +355,24 @@ func (c *Cloud) ensureLoadBalancer(namespacedName types.NamespacedName, loadBala
...
@@ -355,6 +355,24 @@ func (c *Cloud) ensureLoadBalancer(namespacedName types.NamespacedName, loadBala
return
loadBalancer
,
nil
return
loadBalancer
,
nil
}
}
// elbProtocolsAreEqual checks if two ELB protocol strings are considered the same
// Comparison is case insensitive
func
elbProtocolsAreEqual
(
l
,
r
*
string
)
bool
{
if
l
==
nil
||
r
==
nil
{
return
l
==
r
}
return
strings
.
EqualFold
(
aws
.
StringValue
(
l
),
aws
.
StringValue
(
r
))
}
// awsArnEquals checks if two ARN strings are considered the same
// Comparison is case insensitive
func
awsArnEquals
(
l
,
r
*
string
)
bool
{
if
l
==
nil
||
r
==
nil
{
return
l
==
r
}
return
strings
.
EqualFold
(
aws
.
StringValue
(
l
),
aws
.
StringValue
(
r
))
}
// Makes sure that the health check for an ELB matches the configured health check node port
// Makes sure that the health check for an ELB matches the configured health check node port
func
(
c
*
Cloud
)
ensureLoadBalancerHealthCheck
(
loadBalancer
*
elb
.
LoadBalancerDescription
,
protocol
string
,
port
int32
,
path
string
)
error
{
func
(
c
*
Cloud
)
ensureLoadBalancerHealthCheck
(
loadBalancer
*
elb
.
LoadBalancerDescription
,
protocol
string
,
port
int32
,
path
string
)
error
{
name
:=
aws
.
StringValue
(
loadBalancer
.
LoadBalancerName
)
name
:=
aws
.
StringValue
(
loadBalancer
.
LoadBalancerName
)
...
...
pkg/cloudprovider/providers/aws/aws_loadbalancer_test.go
0 → 100644
View file @
9803840b
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
aws
import
(
"github.com/aws/aws-sdk-go/aws"
"testing"
)
func
TestElbProtocolsAreEqual
(
t
*
testing
.
T
)
{
grid
:=
[]
struct
{
L
*
string
R
*
string
Expected
bool
}{
{
L
:
aws
.
String
(
"http"
),
R
:
aws
.
String
(
"http"
),
Expected
:
true
,
},
{
L
:
aws
.
String
(
"HTTP"
),
R
:
aws
.
String
(
"http"
),
Expected
:
true
,
},
{
L
:
aws
.
String
(
"HTTP"
),
R
:
aws
.
String
(
"TCP"
),
Expected
:
false
,
},
{
L
:
aws
.
String
(
""
),
R
:
aws
.
String
(
"TCP"
),
Expected
:
false
,
},
{
L
:
aws
.
String
(
""
),
R
:
aws
.
String
(
""
),
Expected
:
true
,
},
{
L
:
nil
,
R
:
aws
.
String
(
""
),
Expected
:
false
,
},
{
L
:
aws
.
String
(
""
),
R
:
nil
,
Expected
:
false
,
},
{
L
:
nil
,
R
:
nil
,
Expected
:
true
,
},
}
for
_
,
g
:=
range
grid
{
actual
:=
elbProtocolsAreEqual
(
g
.
L
,
g
.
R
)
if
actual
!=
g
.
Expected
{
t
.
Errorf
(
"unexpected result from protocolsEquals(%v, %v)"
,
g
.
L
,
g
.
R
)
}
}
}
func
TestAWSARNEquals
(
t
*
testing
.
T
)
{
grid
:=
[]
struct
{
L
*
string
R
*
string
Expected
bool
}{
{
L
:
aws
.
String
(
"arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012"
),
R
:
aws
.
String
(
"arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012"
),
Expected
:
true
,
},
{
L
:
aws
.
String
(
"ARN:AWS:ACM:US-EAST-1:123456789012:CERTIFICATE/12345678-1234-1234-1234-123456789012"
),
R
:
aws
.
String
(
"arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012"
),
Expected
:
true
,
},
{
L
:
aws
.
String
(
"arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012"
),
R
:
aws
.
String
(
""
),
Expected
:
false
,
},
{
L
:
aws
.
String
(
""
),
R
:
aws
.
String
(
""
),
Expected
:
true
,
},
{
L
:
nil
,
R
:
aws
.
String
(
""
),
Expected
:
false
,
},
{
L
:
aws
.
String
(
""
),
R
:
nil
,
Expected
:
false
,
},
{
L
:
nil
,
R
:
nil
,
Expected
:
true
,
},
}
for
_
,
g
:=
range
grid
{
actual
:=
awsArnEquals
(
g
.
L
,
g
.
R
)
if
actual
!=
g
.
Expected
{
t
.
Errorf
(
"unexpected result from awsArnEquals(%v, %v)"
,
g
.
L
,
g
.
R
)
}
}
}
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