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

IAMbic AWS plugin does not play well with low ulimit value #386

Closed
smoy opened this issue May 4, 2023 · 4 comments
Closed

IAMbic AWS plugin does not play well with low ulimit value #386

smoy opened this issue May 4, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@smoy
Copy link
Contributor

smoy commented May 4, 2023

Describe the bug
macOS default ulimit -n 256 is a problem when an AWS org contains a lot of accounts.

To Reproduce
Steps to reproduce the behavior:

  1. Ensure you have ulimit -n 256 in your environment. Since IAMbic use multiprocessing, you should ensure your shell is not changing the ulimit value.
  2. in a new current working directory, go through iambic setup
  3. setup using AWS organization flow (ensure your organization have like 9+ accounts)
  4. See error
2023/05/04 10:07:00 [info     ] Beginning to retrieve AWS Identity Center Permission Sets. 
  org_accounts=[
    "REACTED_ORG_ACCOUNT"
  ]
2023/05/04 10:07:00 [info     ] Setting inline policies in role templates 
  accounts=[
    "REACTED_ACCOUNT_N_MINUS_5"
  ]
2023/05/04 10:07:00 [info     ] Setting inline policies in role templates 
  accounts=[
    "REACTED_ACCOUNT_N_MINUS_4"
  ]
2023/05/04 10:07:00 [info     ] Setting inline policies in role templates 
  accounts=[
    "REACTED_ACCOUNT_N_MINUS_3"
  ]
2023/05/04 10:07:00 [info     ] Setting inline policies in role templates 
  accounts=[
    "REACTED_ACCOUNT_N_MINUS_2"
  ]
2023/05/04 10:07:01 [info     ] Setting inline policies in role templates 
  accounts=[
    "REACTED_ACCOUNT_N_MINUS_1"
  ]
2023/05/04 10:07:02 [info     ] Setting inline policies in role templates 
  accounts=[
    "REACTED_ACCOUNT_N"
  ]
2023/05/04 10:07:04 [info     ] Failed to refresh AWS accounts 
  error=OSError(24, 'Too many open files')
? What would you like to configure in AWS? (Use arrow keys)

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: macOS Version 13.3.1 (22E261)
  • /bin/zsh
  • iambic, version 0.5.3

Additional context
Current workaround requires you to change your ulimit

(env) stevenmoy@steven-noqdev-mbp iambic % ulimit -n
256
(env) stevenmoy@steven-noqdev-mbp iambic % ulimit -n 1024
(env) stevenmoy@steven-noqdev-mbp iambic % ulimit -n     
1024
@smoy smoy added the bug Something isn't working label May 4, 2023
@smoy smoy self-assigned this May 4, 2023
smoy pushed a commit that referenced this issue May 4, 2023
@perpil
Copy link
Contributor

perpil commented May 5, 2023

There are environment variables that can tell whether you are running in a github workflow or not. Instead of changing the ulimit, I'd suggest lowering the resource consumption by default. That could be as simple as changing the connection pool size when instantiating the clients. I think it is plenty fast, so lowering it to work with the constraints of the OS defaults makes sense vs. trying to change the ulimit. If it is running in github, you could automatically raise the size of the connection pool based on it detecting it is running in a runner, or make it a command line flag.

@smoy
Copy link
Contributor Author

smoy commented May 5, 2023

That's good suggestion. I think we need a refactor the current boto3 client logic across AWS accounts. The implementation today assume it gets a client, open a file, it will succeed. There is no resource manger interface or queue on the interfaces. I will write up a feature enhancement proposal how we want to do it.

What I mean by that is if the host process has only N available fd. The implementation does not really take it into consider, if it needs N+1 FD, it will just crash.

smoy added a commit that referenced this issue May 5, 2023
Related to #386. Wizard should bump ulimit
@smoy
Copy link
Contributor Author

smoy commented May 5, 2023

I open #391 to track the work required to refactor the implementation.

@smoy
Copy link
Contributor Author

smoy commented May 5, 2023

#387 addressed the user experience, so user is not fighting ulimit. But #391 should get looked at to play nice with resource limit.

@smoy smoy closed this as completed May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants