Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete old tags when cloudLabels / labels / taints are removed #3207

Merged

Conversation

KashifSaadat
Copy link
Contributor

If you remove custom cloudLabels/labels/taints from the cluster configuration, kops does not correctly update the AWS resources to delete the tags. This seems to be because it only calls the AWS API method CreateOrUpdateTags, which won't remove tags that aren't in the supplied list.

The current behaviour is that every kops update cluster will show a tag difference but never successfully apply the changes (remove the extra tags).

This PR will perform a diff of the current and expected tags, and call the DeleteTags API if there are any tags to delete.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 15, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @KashifSaadat. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@KashifSaadat
Copy link
Contributor Author

/assign @justinsb

if tagsRequest != nil {
_, err := t.Cloud.Autoscaling().CreateOrUpdateTags(tagsRequest)
if updateTagsRequest != nil {
_, err := t.Cloud.Autoscaling().CreateOrUpdateTags(updateTagsRequest)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might as well .. if _, err := ; err != nil here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update, cheers.

if err != nil {
return fmt.Errorf("error updating AutoscalingGroup tags: %v", err)
}
}

if (deleteTagsRequest != nil) && (len(deleteTagsRequest.Tags) > 0) {
_, err := t.Cloud.Autoscaling().DeleteTags(deleteTagsRequest)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here ... if _, err :=

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating..

if err != nil {
return fmt.Errorf("error updating AutoscalingGroup tags: %v", err)
}
}

if (deleteTagsRequest != nil) && (len(deleteTagsRequest.Tags) > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

brackets aren't required

if changes.Tags != nil {
tagsRequest = &autoscaling.CreateOrUpdateTagsInput{}
tagsRequest.Tags = tags
updateTagsRequest = &autoscaling.CreateOrUpdateTagsInput{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&autoscaling.CreateOrUpdateTagsInput{Tag: tags}

@@ -149,7 +149,28 @@ func (_ *EBSVolume) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *EBSVolume) e
e.ID = response.VolumeId
}

return t.AddAWSTags(*e.ID, e.Tags)
err := t.AddAWSTags(*e.ID, e.Tags)
Copy link
Contributor

@gambol99 gambol99 Aug 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if err := |thing|; err != nil

@gambol99
Copy link
Contributor

awesome 👍

@@ -27,6 +28,7 @@ import (
"github.com/aws/aws-sdk-go/service/iam"
"github.com/aws/aws-sdk-go/service/route53/route53iface"
"github.com/golang/glog"

"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kubernetes/federation/pkg/dnsprovider"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is third party

}

// TODO: Use PropagateAtLaunch = false for tagging?

return nil // We have
}

// getASGTagsToDelete loops through the currently set tags and builds a list of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment is incorrect

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated function names now. :)

@KashifSaadat KashifSaadat force-pushed the delete-old-cloud-labels branch 3 times, most recently from 8b8b604 to 8261767 Compare August 16, 2017 08:05
@chrislovecnm
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 18, 2017
@chrislovecnm
Copy link
Contributor

@gambol99 since you reviewed I probably do not need to ... can I get a LGTM from you?

@chrislovecnm
Copy link
Contributor

…ted resources (cloudLabels, labels, taints).
@KashifSaadat
Copy link
Contributor Author

@chrislovecnm I've fixed the panic, just had to check that the a object was set before attempting to retrieve and analyse the tags.

@gambol99
Copy link
Contributor

lgtm @KashifSaadat ...

@chrislovecnm
Copy link
Contributor

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 21, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: KashifSaadat, chrislovecnm

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 21, 2017
@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 0eabaa8 into kubernetes:master Aug 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants