Skip to content

Fix get iamserviceaccount returning error for unrelated CloudFormation Stack #8350

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

Merged

Conversation

naclonts
Copy link
Member

@naclonts naclonts commented Apr 16, 2025

Description

Fixes an issue where, if one IAM service account had errors creating, eksctl get iamserviceaccount would fail even when filtering for different service accounts. See issue report for more details: #8314

Closes #8314

The problem was that the manager package's GetIAMServiceAccounts queried all CloudFormation stacks and returned an error for any service account that it finds, before filtering the service account based on the user's CLI filters.

This PR moves the filtering prior to the error returning, meaning errors will only be returned if the error was in a stack that the user is including in their filter.

Checklist

  • Added tests that cover your change (if possible)
  • Added/modified documentation as required (such as the README.md, or the userdocs directory)
  • Manually tested
  • Made sure the title of the PR is a good description that can go into the release notes
  • (Core team) Added labels for change area (e.g. area/nodegroup) and kind (e.g. kind/improvement)

BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯

  • Backfilled missing tests for code in same general area 🎉 -- A little bit: the iam.go file didn't have any tests previously
  • Refactored something and made the world a better place 🌟

Sorry, something went wrong.

@naclonts naclonts changed the title Bug serviceaccounts list error Fix get IAM Service Accounts returning error for unrelated CloudFormation Stack Apr 16, 2025
@@ -24,8 +24,8 @@ var _ = Describe("Get", func() {
irsaManager = irsa.New("my-cluster", fakeStackManager, nil, nil)
})

When("no options are specified", func() {
It("returns all service accounts", func() {
When("no error occurs", func() {
Copy link
Member Author

Choose a reason for hiding this comment

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

Most of the logic that these tests covered is now in GetIAMServiceAccounts, with test coverage in iam_test.go.

Copy link
Member

@cheeseandcereal cheeseandcereal left a comment

Choose a reason for hiding this comment

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

Looks great to me! Thanks for both reducing/simplifying the actual code while adding additional tests! Wins all around.

@cheeseandcereal
Copy link
Member

Note you need to rebase this because of the conflicts with go.mod/go.sum that have changed since you made this

@cheeseandcereal cheeseandcereal changed the title Fix get IAM Service Accounts returning error for unrelated CloudFormation Stack Fix get iamserviceaccount returning error for unrelated CloudFormation Stack Apr 17, 2025
@cheeseandcereal cheeseandcereal enabled auto-merge (squash) April 17, 2025 17:17
@cheeseandcereal cheeseandcereal merged commit e22a0d0 into eksctl-io:main Apr 17, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Can't get iamserviceaccount because of an issue with an unrelated cloud formation stack
2 participants