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
e0e305c6
Commit
e0e305c6
authored
Jan 08, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19337 from danielschonfeld/optimize-list-routes
Auto commit by PR queue bot
parents
46945ab5
24c44e7a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
10 deletions
+54
-10
aws.go
pkg/cloudprovider/providers/aws/aws.go
+33
-7
aws_routes.go
pkg/cloudprovider/providers/aws/aws_routes.go
+21
-3
No files found.
pkg/cloudprovider/providers/aws/aws.go
View file @
e0e305c6
...
...
@@ -2093,22 +2093,48 @@ func (s *AWSCloud) UpdateTCPLoadBalancer(name, region string, hosts []string) er
}
// Returns the instance with the specified ID
func
(
a
*
AWSCloud
)
getInstanceById
(
instanceID
string
)
(
*
ec2
.
Instance
,
error
)
{
request
:=
&
ec2
.
DescribeInstancesInput
{
InstanceIds
:
[]
*
string
{
&
instanceID
},
}
instances
,
err
:=
a
.
ec2
.
DescribeInstances
(
request
)
// This function is currently unused, but seems very likely to be needed again
func
(
a
*
AWSCloud
)
getInstanceByID
(
instanceID
string
)
(
*
ec2
.
Instance
,
error
)
{
instances
,
err
:=
a
.
getInstancesByIDs
([]
*
string
{
&
instanceID
})
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
instances
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"no instances found for instance: %s"
,
instanceID
)
}
if
len
(
instances
)
>
1
{
return
nil
,
fmt
.
Errorf
(
"multiple instances found for instance: %s"
,
instanceID
)
}
return
instances
[
0
],
nil
return
instances
[
instanceID
],
nil
}
func
(
a
*
AWSCloud
)
getInstancesByIDs
(
instanceIDs
[]
*
string
)
(
map
[
string
]
*
ec2
.
Instance
,
error
)
{
instancesByID
:=
make
(
map
[
string
]
*
ec2
.
Instance
)
if
len
(
instanceIDs
)
==
0
{
return
instancesByID
,
nil
}
request
:=
&
ec2
.
DescribeInstancesInput
{
InstanceIds
:
instanceIDs
,
}
instances
,
err
:=
a
.
ec2
.
DescribeInstances
(
request
)
if
err
!=
nil
{
return
nil
,
err
}
for
_
,
instance
:=
range
instances
{
instanceID
:=
orEmpty
(
instance
.
InstanceId
)
if
instanceID
==
""
{
continue
}
instancesByID
[
instanceID
]
=
instance
}
return
instancesByID
,
nil
}
// TODO: Make efficient
...
...
pkg/cloudprovider/providers/aws/aws_routes.go
View file @
e0e305c6
...
...
@@ -56,6 +56,23 @@ func (s *AWSCloud) ListRoutes(clusterName string) ([]*cloudprovider.Route, error
}
var
routes
[]
*
cloudprovider
.
Route
var
instanceIDs
[]
*
string
for
_
,
r
:=
range
table
.
Routes
{
instanceID
:=
orEmpty
(
r
.
InstanceId
)
if
instanceID
==
""
{
continue
}
instanceIDs
=
append
(
instanceIDs
,
&
instanceID
)
}
instances
,
err
:=
s
.
getInstancesByIDs
(
instanceIDs
)
if
err
!=
nil
{
return
nil
,
err
}
for
_
,
r
:=
range
table
.
Routes
{
instanceID
:=
orEmpty
(
r
.
InstanceId
)
destinationCIDR
:=
orEmpty
(
r
.
DestinationCidrBlock
)
...
...
@@ -64,9 +81,10 @@ func (s *AWSCloud) ListRoutes(clusterName string) ([]*cloudprovider.Route, error
continue
}
instance
,
err
:=
s
.
getInstanceById
(
instanceID
)
if
err
!=
nil
{
return
nil
,
err
instance
,
found
:=
instances
[
instanceID
]
if
!
found
{
glog
.
Warningf
(
"unable to find instance ID %s in the list of instances being routed to"
,
instanceID
)
continue
}
instanceName
:=
orEmpty
(
instance
.
PrivateDnsName
)
routeName
:=
clusterName
+
"-"
+
destinationCIDR
...
...
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