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

Fix deletion of IAM roles and policies #11558

Merged
merged 1 commit into from
May 22, 2021

Conversation

johngmyers
Copy link
Member

No description provided.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 22, 2021
@k8s-ci-robot k8s-ci-robot added the area/provider/aws Issues or PRs related to aws provider label May 22, 2021
if err != nil {
return fmt.Errorf("error detaching IAM role policy %q: %v", *policy.PolicyArn, err)
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if it works to UpdateAssumeRolePolicy to a PolicyDocument that grants nothing, but I consider that future cleanup work.

@@ -143,6 +143,87 @@ func (s *IAMRole) CheckChanges(a, e, changes *IAMRole) error {
}

func (_ *IAMRole) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *IAMRole) error {
if e.RolePolicyDocument == nil {
klog.V(2).Infof("Deleting IAM role %q", a.Name)
Copy link
Member

Choose a reason for hiding this comment

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

What was the reason for doing deletion in RenderAWS rather than in a fi.Deletion? I believe you can just do the same check as above in findDeletion and all the logic below in Delete.

Copy link
Member Author

Choose a reason for hiding this comment

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

We want the dryrun behavior of fi.Task. For other task types we'll probably want the cloud provider selection.

A followup work item is to write a fi.Deletion adapter to fi.Task, so the cluster deletion code could be subsumed into the task reconciliation code for object such as this that have to be deleted in both cluster delete and apply.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good. For some tasks, we added Delete flag that sort of gives both the dryrun behaviour and fi.Deletion, but it would be nice if we could allow deletion without that property.

Copy link
Member Author

Choose a reason for hiding this comment

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

We do need some way to represent the deleted state so that dryrun can print something useful. I do need to look at how dryrun represents IamRole changes, as it doesn't currently show well what attached policies are changing.

@olemarkus
Copy link
Member

/hold if anyone else wants to review

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 22, 2021
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 22, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: olemarkus

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 22, 2021
@johngmyers
Copy link
Member Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 22, 2021
@k8s-ci-robot k8s-ci-robot merged commit b0cb528 into kubernetes:master May 22, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.22 milestone May 22, 2021
@johngmyers johngmyers deleted the fix-remove-role branch May 22, 2021 18:36
k8s-ci-robot added a commit that referenced this pull request May 23, 2021
…1497-upstream-release-1.21

Automated cherry pick of #11497, #11558: Delete IAM roles no longer in the model
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. area/provider/aws Issues or PRs related to aws provider 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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants