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
1de4c5bb
Commit
1de4c5bb
authored
Mar 17, 2017
by
Hemant Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix AWS untagged instances
To revert to 1.5 behaviour we need to consider untagged instances if no clusterID has been specified or found.
parent
0ed150f3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
8 deletions
+26
-8
tags.go
pkg/cloudprovider/providers/aws/tags.go
+26
-8
No files found.
pkg/cloudprovider/providers/aws/tags.go
View file @
1de4c5bb
...
...
@@ -19,11 +19,12 @@ package aws
import
(
"fmt"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/golang/glog"
"k8s.io/apimachinery/pkg/util/wait"
"strings"
)
// TagNameKubernetesClusterPrefix is the tag name we use to differentiate multiple
...
...
@@ -129,6 +130,10 @@ func (t *awsTagging) clusterTagKey() string {
}
func
(
t
*
awsTagging
)
hasClusterTag
(
tags
[]
*
ec2
.
Tag
)
bool
{
// if the clusterID is not configured -- we consider all instances.
if
len
(
t
.
ClusterID
)
==
0
{
return
true
}
clusterTagKey
:=
t
.
clusterTagKey
()
for
_
,
tag
:=
range
tags
{
tagKey
:=
aws
.
StringValue
(
tag
.
Key
)
...
...
@@ -227,17 +232,23 @@ func (t *awsTagging) createTags(client EC2, resourceID string, lifecycle Resourc
// Add additional filters, to match on our tags
// This lets us run multiple k8s clusters in a single EC2 AZ
func
(
t
*
awsTagging
)
addFilters
(
filters
[]
*
ec2
.
Filter
)
[]
*
ec2
.
Filter
{
// if there are no clusterID configured - no filtering by special tag names
// should be applied to revert to legacy behaviour.
if
len
(
t
.
ClusterID
)
==
0
{
if
len
(
filters
)
==
0
{
// We can't pass a zero-length Filters to AWS (it's an error)
// So if we end up with no filters; just return nil
return
nil
}
return
filters
}
// For 1.6, we always recognize the legacy tag, for the 1.5 -> 1.6 upgrade
// There are no "or" filters by key, so we look for both the legacy and new key, and then we have to post-filter
f
:=
newEc2Filter
(
"tag-key"
,
TagNameKubernetesClusterLegacy
,
t
.
clusterTagKey
())
filters
=
append
(
filters
,
f
)
if
len
(
filters
)
==
0
{
// We can't pass a zero-length Filters to AWS (it's an error)
// So if we end up with no filters; just return nil
return
nil
}
// We can't pass a zero-length Filters to AWS (it's an error)
// So if we end up with no filters; we need to return nil
filters
=
append
(
filters
,
f
)
return
filters
}
...
...
@@ -246,6 +257,13 @@ func (t *awsTagging) buildTags(lifecycle ResourceLifecycle, additionalTags map[s
for
k
,
v
:=
range
additionalTags
{
tags
[
k
]
=
v
}
// no clusterID is a sign of misconfigured cluster, but we can't be tagging the resources with empty
// strings
if
len
(
t
.
ClusterID
)
==
0
{
return
tags
}
// We only create legacy tags if we are using legacy tags, i.e. if we have seen a legacy tag on our instance
if
t
.
usesLegacyTags
{
tags
[
TagNameKubernetesClusterLegacy
]
=
t
.
ClusterID
...
...
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