-
Notifications
You must be signed in to change notification settings - Fork 342
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
ec2_instance module broken in Python 3.8 - dict keys modified during iteration #709
Comments
Files identified in the description:
If these files are inaccurate, please update the |
@Razique Thank you for raising this. Would you be willing to open a pull request with the patch? |
Yup! I can work on this. I'll have to see whether contribution guide differs between AWS community collections and "core". |
@Razique Awesome! Let me know if you need any help. If you want, you can also reach out to us on IRC #ansible-aws. What you need is a changelog fragment https://docs.ansible.com/ansible/latest/community/development_process.html#id11 and also an integration test for this change. |
@alinabuzachis I pushed the PR and created a fragment as required. Let me know if I forgot something! |
… 3.8 (#767) Update ec2_instance find_instances to fix incompatibility with Python 3.8 SUMMARY Update ec2_instance find_instances to use temporary dict. instead of inline changes. Fixes #709 ISSUE TYPE Bugfix Pull Request COMPONENT NAME ec2_instance ADDITIONAL INFORMATION Current ec2_module iterates over a filters dictionary to perform hyphen to underscore substitution while popping keys in the process. This is not compatible with Python 3.8. I have simply created a second dictionary, I can also create a shallow copy via the copy() module if the team prefers. Reviewed-by: Bikouo Aubin <None> Reviewed-by: Alina Buzachis <None> Reviewed-by: Mark Chappell <None>
… 3.8 (#767) Update ec2_instance find_instances to fix incompatibility with Python 3.8 SUMMARY Update ec2_instance find_instances to use temporary dict. instead of inline changes. Fixes #709 ISSUE TYPE Bugfix Pull Request COMPONENT NAME ec2_instance ADDITIONAL INFORMATION Current ec2_module iterates over a filters dictionary to perform hyphen to underscore substitution while popping keys in the process. This is not compatible with Python 3.8. I have simply created a second dictionary, I can also create a shallow copy via the copy() module if the team prefers. Reviewed-by: Bikouo Aubin <None> Reviewed-by: Alina Buzachis <None> Reviewed-by: Mark Chappell <None> (cherry picked from commit 0ca065c)
… 3.8 (#767) Update ec2_instance find_instances to fix incompatibility with Python 3.8 SUMMARY Update ec2_instance find_instances to use temporary dict. instead of inline changes. Fixes #709 ISSUE TYPE Bugfix Pull Request COMPONENT NAME ec2_instance ADDITIONAL INFORMATION Current ec2_module iterates over a filters dictionary to perform hyphen to underscore substitution while popping keys in the process. This is not compatible with Python 3.8. I have simply created a second dictionary, I can also create a shallow copy via the copy() module if the team prefers. Reviewed-by: Bikouo Aubin <None> Reviewed-by: Alina Buzachis <None> Reviewed-by: Mark Chappell <None> (cherry picked from commit 0ca065c)
… 3.8 (#767) (#800) [PR #767/0ca065cf backport][stable-2] Update ec2_instance find_instances to fix incompatibility with Python 3.8 This is a backport of PR #767 as merged into main (0ca065c). SUMMARY Update ec2_instance find_instances to use temporary dict. instead of inline changes. Fixes #709 ISSUE TYPE Bugfix Pull Request COMPONENT NAME ec2_instance ADDITIONAL INFORMATION Current ec2_module iterates over a filters dictionary to perform hyphen to underscore substitution while popping keys in the process. This is not compatible with Python 3.8. I have simply created a second dictionary, I can also create a shallow copy via the copy() module if the team prefers. Reviewed-by: Alina Buzachis <None> Reviewed-by: Jill R <None>
… 3.8 (#767) (#801) [PR #767/0ca065cf backport][stable-3] Update ec2_instance find_instances to fix incompatibility with Python 3.8 This is a backport of PR #767 as merged into main (0ca065c). SUMMARY Update ec2_instance find_instances to use temporary dict. instead of inline changes. Fixes #709 ISSUE TYPE Bugfix Pull Request COMPONENT NAME ec2_instance ADDITIONAL INFORMATION Current ec2_module iterates over a filters dictionary to perform hyphen to underscore substitution while popping keys in the process. This is not compatible with Python 3.8. I have simply created a second dictionary, I can also create a shallow copy via the copy() module if the team prefers. Reviewed-by: Alina Buzachis <None> Reviewed-by: Mark Chappell <None>
Summary
The
ec2_instance
AWS module doesn't work in Python 3.8. This is due to the fact that thefind_instances
method pops keys from thefilters
dictionary while it is being iterated:The fix consists in adding the sanitized keys to a new dictionary and passing it to the paginator instead of modifying the existing one as follows:
Issue Type
Bug Report
Component Name
ec2_instance
Ansible Version
Collection Versions
$ ansible-galaxy collection list
AWS SDK versions
Configuration
OS / Environment
Fedora 33
Steps to Reproduce
Expected Results
EC2 instances should provision instead of the module failing with an error of
RuntimeError: dictionary keys changed during iteration"
Actual Results
Code of Conduct
The text was updated successfully, but these errors were encountered: