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

IAM controller leaves on orphaned role when patching .spec.name #2268

Open
demikl opened this issue Feb 6, 2025 · 4 comments
Open

IAM controller leaves on orphaned role when patching .spec.name #2268

demikl opened this issue Feb 6, 2025 · 4 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. service/iam Indicates issues or PRs that are related to iam-controller.

Comments

@demikl
Copy link

demikl commented Feb 6, 2025

Describe the bug

When I change the .spec.name field in an already synced roles.iam resource, a new role with the updated name is effectively created, but the old IAM role is not deleted.

Steps to reproduce

  1. create a valid roles.iam resource with .spec.name = foo
  2. wait for it to be successfully reconciled (the IAM role foo should now exist)
  3. patch the resource by modifying .spec.name = bar
  4. wait for it to be successfully reconciled (the IAM role bar should now exist)
  5. the IAM role foo still exists but is not managed anymore by the ACK IAM controller

Expected outcome

The old IAM role should be deleted, as if the role.iam resource has been deleted.

Environment

  • Kubernetes version

1.30

  • Using EKS (yes/no), if so version?

yes : eks.24

  • AWS service targeted (S3, RDS, etc.)

IAM controller, v1.3.13

@michaelhtm michaelhtm added kind/bug Categorizes issue or PR as related to a bug. service/iam Indicates issues or PRs that are related to iam-controller. labels Feb 10, 2025
@michaelhtm
Copy link
Member

Hey @demikl, thanks for bringing this to our attention. Looks like it needs a custom code on update..we'll schedule this in our backlog!

@michaelhtm
Copy link
Member

Hey @demikl, it looks like custom code would not be enough to solve this issue, as there wouldn't be a way to retrieve old the role name after it's changed. What do you think if we make the role name immutable at the API level instead?

Another solution could be storing the old role name in the annotation, so when there's a diff, we can delete the old one and create a new one..
cc @a-hilaly @gfrey

@demikl
Copy link
Author

demikl commented Feb 11, 2025 via email

@rushmash91 rushmash91 self-assigned this Feb 11, 2025
@rushmash91
Copy link
Member

Hey @demikl,

Thank you for the detailed description for the issue!

This is a known behavior in the ACK IAM controller because the Name field in a RoleName is Unique.

Since, the Name field serves as a unique identifier, any changes to these fields are treated by IAM as the creation of a new resource record set rather than an update to an existing one, leaving a orphaned role.

https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateRole.html

I agree Name should be made immutable.

We'll have a patch for all the controllers and move to CEL-Based Immutability this month. So, that immutable checks are handled at the admission layer.

As @michaelhtm mentioned, we'll schedule this in our backlog after the patch above is merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. service/iam Indicates issues or PRs that are related to iam-controller.
Projects
None yet
Development

No branches or pull requests

3 participants