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
319c608f
Commit
319c608f
authored
May 25, 2017
by
Matthew Wong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get instances of all states in DisksAreAttached, not just "running"
parent
749ac27e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
aws.go
pkg/cloudprovider/providers/aws/aws.go
+10
-9
aws_test.go
pkg/cloudprovider/providers/aws/aws_test.go
+1
-1
No files found.
pkg/cloudprovider/providers/aws/aws.go
View file @
319c608f
...
...
@@ -2599,7 +2599,7 @@ func (c *Cloud) EnsureLoadBalancer(clusterName string, apiService *v1.Service, n
return
nil
,
fmt
.
Errorf
(
"LoadBalancerIP cannot be specified for AWS ELB"
)
}
instances
,
err
:=
c
.
getInstancesByNodeNamesCached
(
nodeNames
(
nodes
))
instances
,
err
:=
c
.
getInstancesByNodeNamesCached
(
nodeNames
(
nodes
)
,
"running"
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -3157,7 +3157,7 @@ func (c *Cloud) EnsureLoadBalancerDeleted(clusterName string, service *v1.Servic
// UpdateLoadBalancer implements LoadBalancer.UpdateLoadBalancer
func
(
c
*
Cloud
)
UpdateLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
,
nodes
[]
*
v1
.
Node
)
error
{
instances
,
err
:=
c
.
getInstancesByNodeNamesCached
(
nodeNames
(
nodes
))
instances
,
err
:=
c
.
getInstancesByNodeNamesCached
(
nodeNames
(
nodes
)
,
"running"
)
if
err
!=
nil
{
return
err
}
...
...
@@ -3229,10 +3229,11 @@ func (c *Cloud) getInstancesByIDs(instanceIDs []*string) (map[string]*ec2.Instan
return
instancesByID
,
nil
}
// Fetches and caches instances by node names; returns an error if any cannot be found.
// Fetches and caches instances in the given state, by node names; returns an error if any cannot be found. If no states
// are given, no state filter is used and instances of all states are fetched.
// This is implemented with a multi value filter on the node names, fetching the desired instances with a single query.
// TODO(therc): make all the caching more rational during the 1.4 timeframe
func
(
c
*
Cloud
)
getInstancesByNodeNamesCached
(
nodeNames
sets
.
String
)
([]
*
ec2
.
Instance
,
error
)
{
func
(
c
*
Cloud
)
getInstancesByNodeNamesCached
(
nodeNames
sets
.
String
,
states
...
string
)
([]
*
ec2
.
Instance
,
error
)
{
c
.
mutex
.
Lock
()
defer
c
.
mutex
.
Unlock
()
if
nodeNames
.
Equal
(
c
.
lastNodeNames
)
{
...
...
@@ -3243,7 +3244,7 @@ func (c *Cloud) getInstancesByNodeNamesCached(nodeNames sets.String) ([]*ec2.Ins
return
c
.
lastInstancesByNodeNames
,
nil
}
}
instances
,
err
:=
c
.
getInstancesByNodeNames
(
nodeNames
.
List
())
instances
,
err
:=
c
.
getInstancesByNodeNames
(
nodeNames
.
List
()
,
states
...
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -3259,7 +3260,7 @@ func (c *Cloud) getInstancesByNodeNamesCached(nodeNames sets.String) ([]*ec2.Ins
return
instances
,
nil
}
func
(
c
*
Cloud
)
getInstancesByNodeNames
(
nodeNames
[]
string
)
([]
*
ec2
.
Instance
,
error
)
{
func
(
c
*
Cloud
)
getInstancesByNodeNames
(
nodeNames
[]
string
,
states
...
string
)
([]
*
ec2
.
Instance
,
error
)
{
names
:=
aws
.
StringSlice
(
nodeNames
)
nodeNameFilter
:=
&
ec2
.
Filter
{
...
...
@@ -3267,9 +3268,9 @@ func (c *Cloud) getInstancesByNodeNames(nodeNames []string) ([]*ec2.Instance, er
Values
:
names
,
}
filters
:=
[]
*
ec2
.
Filter
{
nodeNameFilter
,
newEc2Filter
(
"instance-state-name"
,
"running"
),
filters
:=
[]
*
ec2
.
Filter
{
nodeNameFilter
}
if
len
(
states
)
>
0
{
filters
=
append
(
filters
,
newEc2Filter
(
"instance-state-name"
,
states
...
))
}
instances
,
err
:=
c
.
describeInstances
(
filters
)
...
...
pkg/cloudprovider/providers/aws/aws_test.go
View file @
319c608f
...
...
@@ -1050,7 +1050,7 @@ func TestFindInstancesByNodeNameCached(t *testing.T) {
}
nodeNames
:=
sets
.
NewString
(
nodeNameOne
)
returnedInstances
,
errr
:=
c
.
getInstancesByNodeNamesCached
(
nodeNames
)
returnedInstances
,
errr
:=
c
.
getInstancesByNodeNamesCached
(
nodeNames
,
"running"
)
if
errr
!=
nil
{
t
.
Errorf
(
"Failed to find instance: %v"
,
err
)
...
...
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