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

Handle ResourceNotFoundException while iterating certificates #646

Merged

Conversation

sebastien-rosset
Copy link
Contributor

@sebastien-rosset sebastien-rosset commented Jan 28, 2022

SUMMARY

The module/utils/acm.py was not correctly handling deletion of certificates. While iterating over a list of certificates, the get_certificate function was making API calls to obtain more information about the certificates, but some certificates may be deleted while iterating.

Fixes #622

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

acm.py

ADDITIONAL INFORMATION

Wow, it seems many tests are very flaky. I'm attempting to fix an issue in ACM, but problems occur elsewhere. Not to mention I raised this PR to fix #622, which was discovered while working on ansible-collections/community.aws#870. And I discovered other issues as well, and so it looks like it's not possible to make any progress without going down a tree of bug fixes.

TypeError: 'NoneType' object is not subscriptable
fatal: [testhost]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 121, in <module>\n  File \"<stdin>\", line 113, in _ansiballz_main\n  File \"<stdin>\", line 61, in invoke_module\n  File \"/usr/lib64/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib64/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_ec2_vpc_igw_payload_g4o1kl_r/ansible_ec2_vpc_igw_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_vpc_igw.py\", line 248, in <module>\n  File \"/tmp/ansible_ec2_vpc_igw_payload_g4o1kl_r/ansible_ec2_vpc_igw_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_vpc_igw.py\", line 242, in main\n  File \"/tmp/ansible_ec2_vpc_igw_payload_g4o1kl_r/ansible_ec2_vpc_igw_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_vpc_igw.py\", line 132, in process\n  File \"/tmp/ansible_ec2_vpc_igw_payload_g4o1kl_r/ansible_ec2_vpc_igw_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_vpc_igw.py\", line 220, in ensure_igw_present\n  File \"/tmp/ansible_ec2_vpc_igw_payload_g4o1kl_r/ansible_ec2_vpc_igw_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_vpc_igw.py\", line 158, in get_igw_info\nTypeError: 'NoneType' object is not subscriptable\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

@softwarefactory-project-zuul
Copy link
Contributor

@sebastien-rosset
Copy link
Contributor Author

It looks like I have hit another unrelated bug that cause a failure of the integration tests: #647

@alinabuzachis
Copy link
Contributor

It looks like I have hit another unrelated bug that cause a failure of the integration tests: #647

@sebastien-rosset Thank you for taking time to work on this. I have a fix for that bug related to ec2_vpc_igw in this PR #553

@softwarefactory-project-zuul
Copy link
Contributor

Copy link
Contributor

@alinabuzachis alinabuzachis left a comment

Choose a reason for hiding this comment

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

@sebastien-rosset Could you please add a changelog fragment for this fix?

@softwarefactory-project-zuul
Copy link
Contributor

@jillr jillr added the gate label Feb 8, 2022
@alinabuzachis alinabuzachis added backport-3 PR should be backported to the stable-3 branch mergeit Merge the PR (SoftwareFactory) and removed gate labels Feb 9, 2022
@softwarefactory-project-zuul
Copy link
Contributor

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 4b12454 into ansible-collections:main Feb 9, 2022
@patchback
Copy link

patchback bot commented Feb 9, 2022

Backport to stable-3: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-3/4b1245477f19b8e3312bc093530597986b0f19ad/pr-646

Backported as #657

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Feb 9, 2022
Handle ResourceNotFoundException while iterating certificates

SUMMARY

The module/utils/acm.py was not correctly handling deletion of certificates. While iterating over a list of certificates, the get_certificate function was making API calls to obtain more information about the certificates, but some certificates may be deleted while iterating.
Fixes #622

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

acm.py
ADDITIONAL INFORMATION

Wow, it seems many tests are very flaky. I'm attempting to fix an issue in ACM, but problems occur elsewhere. Not to mention I raised this PR to fix #622, which was discovered while working on ansible-collections/community.aws#870. And I discovered other issues as well, and so it looks like it's not possible to make any progress without going down a tree of bug fixes.
TypeError: 'NoneType' object is not subscriptable
fatal: [testhost]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 121, in <module>\n  File \"<stdin>\", line 113, in _ansiballz_main\n  File \"<stdin>\", line 61, in invoke_module\n  File \"/usr/lib64/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib64/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_ec2_vpc_igw_payload_g4o1kl_r/ansible_ec2_vpc_igw_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_vpc_igw.py\", line 248, in <module>\n  File \"/tmp/ansible_ec2_vpc_igw_payload_g4o1kl_r/ansible_ec2_vpc_igw_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_vpc_igw.py\", line 242, in main\n  File \"/tmp/ansible_ec2_vpc_igw_payload_g4o1kl_r/ansible_ec2_vpc_igw_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_vpc_igw.py\", line 132, in process\n  File \"/tmp/ansible_ec2_vpc_igw_payload_g4o1kl_r/ansible_ec2_vpc_igw_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_vpc_igw.py\", line 220, in ensure_igw_present\n  File \"/tmp/ansible_ec2_vpc_igw_payload_g4o1kl_r/ansible_ec2_vpc_igw_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_vpc_igw.py\", line 158, in get_igw_info\nTypeError: 'NoneType' object is not subscriptable\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Jill R <None>
(cherry picked from commit 4b12454)
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Feb 9, 2022
…657)

[PR #646/4b124547 backport][stable-3] Handle ResourceNotFoundException while iterating certificates

This is a backport of PR #646 as merged into main (4b12454).
SUMMARY

The module/utils/acm.py was not correctly handling deletion of certificates. While iterating over a list of certificates, the get_certificate function was making API calls to obtain more information about the certificates, but some certificates may be deleted while iterating.
Fixes #622

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

acm.py
ADDITIONAL INFORMATION



Wow, it seems many tests are very flaky. I'm attempting to fix an issue in ACM, but problems occur elsewhere. Not to mention I raised this PR to fix #622, which was discovered while working on ansible-collections/community.aws#870. And I discovered other issues as well, and so it looks like it's not possible to make any progress without going down a tree of bug fixes.
TypeError: 'NoneType' object is not subscriptable
fatal: [testhost]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 121, in <module>\n  File \"<stdin>\", line 113, in _ansiballz_main\n  File \"<stdin>\", line 61, in invoke_module\n  File \"/usr/lib64/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib64/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_ec2_vpc_igw_payload_g4o1kl_r/ansible_ec2_vpc_igw_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_vpc_igw.py\", line 248, in <module>\n  File \"/tmp/ansible_ec2_vpc_igw_payload_g4o1kl_r/ansible_ec2_vpc_igw_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_vpc_igw.py\", line 242, in main\n  File \"/tmp/ansible_ec2_vpc_igw_payload_g4o1kl_r/ansible_ec2_vpc_igw_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_vpc_igw.py\", line 132, in process\n  File \"/tmp/ansible_ec2_vpc_igw_payload_g4o1kl_r/ansible_ec2_vpc_igw_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_vpc_igw.py\", line 220, in ensure_igw_present\n  File \"/tmp/ansible_ec2_vpc_igw_payload_g4o1kl_r/ansible_ec2_vpc_igw_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_vpc_igw.py\", line 158, in get_igw_info\nTypeError: 'NoneType' object is not subscriptable\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
…n group (ansible-collections#646)

[Plugin elasticache_info] includes the description of each replication group

SUMMARY
This pull request add the description of the corresponding Elasticache replication group into each described cache cluster.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
elasticache_info
ADDITIONAL INFORMATION
Actually the only way to describe Elasticache replication groups with Ansible is to use the dynamic inventory.
However, exposing the informations about each replication group could be useful in other contexts.
In my case, I am generating a few .env files and I need to include some Elasticache replication group primary endpoint and reader endpoint.
Since the elasticache_info plugin already exist and already retrieves the appropriate replication_group_id, I believe that this plugin should also retrieve the replication group description when it exists.
OTHER REMARKS CONCERNING THIS PULL REQUEST
Each provided description is copy/pasted from the official boto3 documentation which is distributed under an Apache 2.0 licence. I did it for consistency reason between and also because I am not a native speaker.
Also the provided description is incomplete : I only documented the fields that I was able to retrieve from my current AWS clusters.
Boto3 documentation of the "describe_replication_groups" function : https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/elasticache.html#ElastiCache.Client.describe_replication_groups
Moreover this pull request might violates the "integration tests" rule : I didn't find any integration test for the elasticache_info plugin and I don't know why no integration test have been made.

Reviewed-by: Mark Chappell <None>
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
…n group (ansible-collections#646)

[Plugin elasticache_info] includes the description of each replication group

SUMMARY
This pull request add the description of the corresponding Elasticache replication group into each described cache cluster.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
elasticache_info
ADDITIONAL INFORMATION
Actually the only way to describe Elasticache replication groups with Ansible is to use the dynamic inventory.
However, exposing the informations about each replication group could be useful in other contexts.
In my case, I am generating a few .env files and I need to include some Elasticache replication group primary endpoint and reader endpoint.
Since the elasticache_info plugin already exist and already retrieves the appropriate replication_group_id, I believe that this plugin should also retrieve the replication group description when it exists.
OTHER REMARKS CONCERNING THIS PULL REQUEST
Each provided description is copy/pasted from the official boto3 documentation which is distributed under an Apache 2.0 licence. I did it for consistency reason between and also because I am not a native speaker.
Also the provided description is incomplete : I only documented the fields that I was able to retrieve from my current AWS clusters.
Boto3 documentation of the "describe_replication_groups" function : https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/elasticache.html#ElastiCache.Client.describe_replication_groups
Moreover this pull request might violates the "integration tests" rule : I didn't find any integration test for the elasticache_info plugin and I don't know why no integration test have been made.

Reviewed-by: Mark Chappell <None>
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Oct 24, 2023
…n group (ansible-collections#646)

[Plugin elasticache_info] includes the description of each replication group

SUMMARY
This pull request add the description of the corresponding Elasticache replication group into each described cache cluster.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
elasticache_info
ADDITIONAL INFORMATION
Actually the only way to describe Elasticache replication groups with Ansible is to use the dynamic inventory.
However, exposing the informations about each replication group could be useful in other contexts.
In my case, I am generating a few .env files and I need to include some Elasticache replication group primary endpoint and reader endpoint.
Since the elasticache_info plugin already exist and already retrieves the appropriate replication_group_id, I believe that this plugin should also retrieve the replication group description when it exists.
OTHER REMARKS CONCERNING THIS PULL REQUEST
Each provided description is copy/pasted from the official boto3 documentation which is distributed under an Apache 2.0 licence. I did it for consistency reason between and also because I am not a native speaker.
Also the provided description is incomplete : I only documented the fields that I was able to retrieve from my current AWS clusters.
Boto3 documentation of the "describe_replication_groups" function : https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/elasticache.html#ElastiCache.Client.describe_replication_groups
Moreover this pull request might violates the "integration tests" rule : I didn't find any integration test for the elasticache_info plugin and I don't know why no integration test have been made.

Reviewed-by: Mark Chappell <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-3 PR should be backported to the stable-3 branch bug This issue/PR relates to a bug community_review has_issue mergeit Merge the PR (SoftwareFactory) module_utils module_utils needs_triage new_contributor Help guide this first time contributor plugins plugin (any type) python3 traceback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ResourceNotFoundException is raised when querying ACM certificates
4 participants