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
10794e7f
Commit
10794e7f
authored
Jun 29, 2017
by
Matt Landis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Arbitrarily chose first (lexicographically) subnet in AZ on AWS.
When there is more than one subnet for an AZ on AWS choose arbitrarily chose the first one lexicographically for consistency.
parent
f189d7f7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
7 deletions
+30
-7
aws.go
pkg/cloudprovider/providers/aws/aws.go
+9
-2
aws_test.go
pkg/cloudprovider/providers/aws/aws_test.go
+21
-5
No files found.
pkg/cloudprovider/providers/aws/aws.go
View file @
10794e7f
...
...
@@ -2467,8 +2467,15 @@ func (c *Cloud) findELBSubnets(internalELB bool) ([]string, error) {
continue
}
// TODO: Should this be an error?
glog
.
Warningf
(
"Found multiple subnets in AZ %q; making arbitrary choice between subnets %q and %q"
,
az
,
*
existing
.
SubnetId
,
*
subnet
.
SubnetId
)
// If we have two subnets for the same AZ we arbitrarily choose the one that is first lexicographically.
// TODO: Should this be an error.
if
strings
.
Compare
(
*
existing
.
SubnetId
,
*
subnet
.
SubnetId
)
>
0
{
glog
.
Warningf
(
"Found multiple subnets in AZ %q; choosing %q between subnets %q and %q"
,
az
,
*
subnet
.
SubnetId
,
*
existing
.
SubnetId
,
*
subnet
.
SubnetId
)
subnetsByAZ
[
az
]
=
subnet
continue
}
glog
.
Warningf
(
"Found multiple subnets in AZ %q; choosing %q between subnets %q and %q"
,
az
,
*
existing
.
SubnetId
,
*
existing
.
SubnetId
,
*
subnet
.
SubnetId
)
continue
}
...
...
pkg/cloudprovider/providers/aws/aws_test.go
View file @
10794e7f
...
...
@@ -792,12 +792,18 @@ func TestSubnetIDsinVPC(t *testing.T) {
}
}
// test with 4 subnets from 3 different AZs
// add duplicate az subnet
// Test with 5 subnets from 3 different AZs.
// Add 2 duplicate AZ subnets lexicographically chosen one is the middle element in array to
// check that we both choose the correct entry when it comes after and before another element
// in the same AZ.
subnets
[
3
]
=
make
(
map
[
string
]
string
)
subnets
[
3
][
"id"
]
=
"subnet-c000000
2
"
subnets
[
3
][
"id"
]
=
"subnet-c000000
0
"
subnets
[
3
][
"az"
]
=
"af-south-1c"
subnets
[
4
]
=
make
(
map
[
string
]
string
)
subnets
[
4
][
"id"
]
=
"subnet-c0000002"
subnets
[
4
][
"az"
]
=
"af-south-1c"
awsServices
.
ec2
.
Subnets
=
constructSubnets
(
subnets
)
routeTables
[
"subnet-c0000000"
]
=
true
routeTables
[
"subnet-c0000002"
]
=
true
awsServices
.
ec2
.
RouteTables
=
constructRouteTables
(
routeTables
)
...
...
@@ -812,6 +818,16 @@ func TestSubnetIDsinVPC(t *testing.T) {
return
}
expected
:=
[]
*
string
{
aws
.
String
(
"subnet-a0000001"
),
aws
.
String
(
"subnet-b0000001"
),
aws
.
String
(
"subnet-c0000000"
)}
for
_
,
s
:=
range
result
{
if
!
contains
(
expected
,
s
)
{
t
.
Errorf
(
"Unexpected subnet '%s' found"
,
s
)
return
}
}
delete
(
routeTables
,
"subnet-c0000002"
)
// test with 6 subnets from 3 different AZs
// with 3 private subnets
subnets
[
4
]
=
make
(
map
[
string
]
string
)
...
...
@@ -825,7 +841,7 @@ func TestSubnetIDsinVPC(t *testing.T) {
routeTables
[
"subnet-a0000001"
]
=
false
routeTables
[
"subnet-b0000001"
]
=
false
routeTables
[
"subnet-c0000001"
]
=
false
routeTables
[
"subnet-c000000
2
"
]
=
true
routeTables
[
"subnet-c000000
0
"
]
=
true
routeTables
[
"subnet-d0000001"
]
=
true
routeTables
[
"subnet-d0000002"
]
=
true
awsServices
.
ec2
.
RouteTables
=
constructRouteTables
(
routeTables
)
...
...
@@ -840,7 +856,7 @@ func TestSubnetIDsinVPC(t *testing.T) {
return
}
expected
:=
[]
*
string
{
aws
.
String
(
"subnet-c0000002
"
),
aws
.
String
(
"subnet-d0000001"
),
aws
.
String
(
"subnet-d0000002"
)}
expected
=
[]
*
string
{
aws
.
String
(
"subnet-c0000000
"
),
aws
.
String
(
"subnet-d0000001"
),
aws
.
String
(
"subnet-d0000002"
)}
for
_
,
s
:=
range
result
{
if
!
contains
(
expected
,
s
)
{
t
.
Errorf
(
"Unexpected subnet '%s' found"
,
s
)
...
...
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