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

Remove an unreachable code fragment in ec2_security_group #1348

Conversation

openrefactory
Copy link
Contributor

In file: ec2_security_group.py, method: ensure_present, a logical expression uses the identity operator. A new object is created inside the identity check operation and then used for matching identity. Since this is a distinct, new object, it will not have identity and match with anything else. As a result, the identity check will have a logical short circuit and the program may have unintended behavior.

I suggested that the logical operation should be done properly.

@ansibullbot
Copy link

@ansibullbot ansibullbot added community_review module module needs_triage new_contributor Help guide this first time contributor plugins plugin (any type) small_patch Hopefully easy to review labels Feb 2, 2023
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

✔️ ansible-galaxy-importer SUCCESS in 3m 48s
✔️ build-ansible-collection SUCCESS in 5m 06s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 9m 38s (non-voting)
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 9m 39s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 9m 30s
✔️ ansible-test-sanity-aws-ansible-2.14 SUCCESS in 9m 22s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 8m 26s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 9m 00s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 9m 56s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 9m 15s
✔️ cloud-tox-py3 SUCCESS in 5m 58s
ansible-test-changelog FAILURE in 2m 17s
✔️ ansible-test-splitter SUCCESS in 2m 49s
integration-amazon.aws-1 FAILURE in 18m 38s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-amazon.aws-14 SKIPPED
⚠️ integration-amazon.aws-15 SKIPPED
⚠️ integration-amazon.aws-16 SKIPPED
⚠️ integration-amazon.aws-17 SKIPPED
⚠️ integration-amazon.aws-18 SKIPPED
⚠️ integration-amazon.aws-19 SKIPPED
⚠️ integration-amazon.aws-20 SKIPPED
⚠️ integration-amazon.aws-21 SKIPPED
⚠️ integration-amazon.aws-22 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED
⚠️ integration-community.aws-14 SKIPPED
⚠️ integration-community.aws-15 SKIPPED
⚠️ integration-community.aws-16 SKIPPED
⚠️ integration-community.aws-17 SKIPPED
⚠️ integration-community.aws-18 SKIPPED
⚠️ integration-community.aws-19 SKIPPED
⚠️ integration-community.aws-20 SKIPPED
⚠️ integration-community.aws-21 SKIPPED
⚠️ integration-community.aws-22 SKIPPED

Copy link
Contributor

@tremble tremble left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to open this PR.

The description of the PR is a little misleading since the change doesn't remove the code it 'fixes' an accidental bug.

Looking at the integration tests it looks like the expected behaviour (with purge==True) now includes purging the default rules, and looking at the history of the module this has been the behaviour since the creation of this collection, with the behaviour being documented as such since the addition of purge_egress_rules.

Please update this PR to remove the unreachable code. Additionally, please add a changelog fragment: https://docs.ansible.com/ansible/latest/community/development_process.html#changelogs-how-to

@openrefactory
Copy link
Contributor Author

@tremble According to your comment, should I remove the entire if block and keep only the else block(of course after removing the else logic)?

@tremble
Copy link
Contributor

tremble commented Feb 9, 2023

@openrefactory Yes please

@openrefactory openrefactory changed the title Remove an unnecessary check in code which always evaluates to false Remove an unreachable code fragment in ec2_security_group Feb 10, 2023
@openrefactory
Copy link
Contributor Author

@tremble Thanks. I have updated the PR and changes. Please check.

@ansibullbot ansibullbot removed the small_patch Hopefully easy to review label Feb 10, 2023
Copy link
Contributor

@tremble tremble left a comment

Choose a reason for hiding this comment

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

Looks good to me, our CI's currently unavailable due to maintenance. I'll test & merge once CI's back (assuming the integration tests pass)

changelogs/fragments/1348-remove-unreachable-code.yml Outdated Show resolved Hide resolved
@tremble
Copy link
Contributor

tremble commented Feb 13, 2023

recheck (command to CI - ignore me)

@github-actions
Copy link

github-actions bot commented Feb 13, 2023

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and your docs changes will be incorporated when they are next published.

@softwarefactory-project-zuul

This comment was marked as outdated.

@tremble
Copy link
Contributor

tremble commented Feb 13, 2023

recheck (command to CI - ignore me)

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/3426ef69701c42c6931a373e7f0a9645

✔️ ansible-galaxy-importer SUCCESS in 4m 38s
✔️ build-ansible-collection SUCCESS in 13m 52s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 13m 08s (non-voting)
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 10m 51s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 12m 48s
✔️ ansible-test-sanity-aws-ansible-2.14 SUCCESS in 13m 53s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 8m 45s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 10m 43s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 9m 19s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 11m 34s
✔️ cloud-tox-py3 SUCCESS in 7m 29s
✔️ ansible-test-changelog SUCCESS in 4m 28s
✔️ ansible-test-splitter SUCCESS in 5m 03s
✔️ integration-amazon.aws-1 SUCCESS in 13m 01s
Skipped 43 jobs

@tremble tremble added the mergeit Merge the PR (SoftwareFactory) label Feb 13, 2023
@softwarefactory-project-zuul

This comment was marked as outdated.

@tremble
Copy link
Contributor

tremble commented Feb 14, 2023

regate

@softwarefactory-project-zuul
Copy link
Contributor

Build failed (gate pipeline). For information on how to proceed, see
http://docs.openstack.org/infra/manual/developers.html#automated-testing

https://ansible.softwarefactory-project.io/zuul/buildset/85e0bed80d9641188e96f5bf06f60e7e

ansible-galaxy-importer RETRY_LIMIT in 14s
✔️ build-ansible-collection SUCCESS in 12m 38s
✔️ ansible-test-splitter SUCCESS in 4m 45s
integration-amazon.aws-1 RETRY_LIMIT in 16s
Skipped 43 jobs

@tremble
Copy link
Contributor

tremble commented Feb 17, 2023

regate

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).
https://ansible.softwarefactory-project.io/zuul/buildset/91effef50a004514a99ba574319d1508

✔️ ansible-galaxy-importer SUCCESS in 3m 51s
✔️ build-ansible-collection SUCCESS in 12m 58s
✔️ ansible-test-splitter SUCCESS in 5m 06s
✔️ integration-amazon.aws-1 SUCCESS in 14m 30s
Skipped 43 jobs

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 192b21d into ansible-collections:main Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community_review mergeit Merge the PR (SoftwareFactory) module module new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants