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

Add NotFound retries when tagging a new VPC Peering connection #614

Merged
merged 2 commits into from
Jun 29, 2021

Conversation

tremble
Copy link
Contributor

@tremble tremble commented Jun 29, 2021

SUMMARY

Prior to botocore 1.17.24 it wasn't possible to tag the connection as a part of the creation call. As such a separate create_tags call is performed after the creation. However, this leads to a race condition when "I(wait=False)".

Rather than adding hard to test logic, add InvalidVpcPeeringConnectionID.NotFound retries to the tagging.

Also move from custom tag handling code over to the shared code in ansible_collections.amazon.aws.plugins.module_utils.ec2

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

ec2_vpc_peer

ADDITIONAL INFORMATION
TASK [ec2_vpc_peer : Create local account VPC peering Connection] **************
task path: /home/zuul/.ansible/collections/ansible_collections/community/aws/tests/integration/targets/ec2_vpc_peer/tasks/main.yml:403
<testhost> ESTABLISH LOCAL CONNECTION FOR USER: zuul
<testhost> EXEC /bin/sh -c 'echo ~zuul && sleep 0'
<testhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/zuul/.ansible/tmp `"&& mkdir "` echo /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910 `" && echo ansible-tmp-1624925621.1931164-8629-186765425497910="` echo /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910 `" ) && sleep 0'
Using module file /home/zuul/.ansible/collections/ansible_collections/community/aws/plugins/modules/ec2_vpc_peer.py
<testhost> PUT /home/zuul/.ansible/tmp/ansible-local-8151h1f3kbcc/tmplyozom8u TO /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/AnsiballZ_ec2_vpc_peer.py
<testhost> EXEC /bin/sh -c 'chmod u+x /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/ /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/AnsiballZ_ec2_vpc_peer.py && sleep 0'
<testhost> EXEC /bin/sh -c 'ANSIBLE_DEBUG_BOTOCORE_LOGS=True /home/zuul/venv/bin/python3.6 /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/AnsiballZ_ec2_vpc_peer.py && sleep 0'
<testhost> EXEC /bin/sh -c 'rm -f -r /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
  File "/tmp/ansible_ec2_vpc_peer_payload_bbdh2ojz/ansible_ec2_vpc_peer_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_vpc_peer.py", line 559, in create_tags
  File "/tmp/ansible_ec2_vpc_peer_payload_bbdh2ojz/ansible_ec2_vpc_peer_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/core.py", line 288, in deciding_wrapper
    return retrying_wrapper(*args, **kwargs)
  File "/tmp/ansible_ec2_vpc_peer_payload_bbdh2ojz/ansible_ec2_vpc_peer_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/cloud.py", line 154, in retry_func
    raise e
  File "/tmp/ansible_ec2_vpc_peer_payload_bbdh2ojz/ansible_ec2_vpc_peer_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/cloud.py", line 144, in retry_func
    return f(*args, **kwargs)
  File "/home/zuul/venv/lib/python3.6/site-packages/botocore/client.py", line 386, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/zuul/venv/lib/python3.6/site-packages/botocore/client.py", line 705, in _make_api_call
    raise error_class(parsed_response, operation_name)
fatal: [testhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "aws_access_key": "ASIA6CCDWXDOPPPI445H",
            "aws_ca_bundle": null,
            "aws_config": null,
            "aws_secret_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "debug_botocore_endpoint_logs": true,
            "ec2_url": null,
            "peer_owner_id": null,
            "peer_region": null,
            "peer_vpc_id": "vpc-0deec00ddeb3584bf",
            "peering_id": null,
            "profile": null,
            "region": "us-east-1",
            "security_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "state": "present",
            "tags": {
                "Name": "Peering connection for VPC vpc-018bc7cc64b0731f9 to VPC vpc-0deec00ddeb3584bf"
            },
            "validate_certs": true,
            "vpc_id": "vpc-018bc7cc64b0731f9",
            "wait": false
        }
    },
    "msg": "An error occurred (InvalidVpcPeeringConnectionID.NotFound) when calling the CreateTags operation: The vpcPeeringConnection ID 'pcx-06ed26ea8993aba5b' does not exist",
    "resource_actions": [
        "ec2:DeleteTags",
        "ec2:CreateTags",
        "ec2:CreateVpcPeeringConnection",
        "ec2:DescribeVpcPeeringConnections"
    ]
}

Add NotFound retries when tagging a new VPC Peering connection
@ansibullbot
Copy link

@ansibullbot ansibullbot added bug This issue/PR relates to a bug community_review module module needs_triage owner_pr PR created by owner/maintainer plugins plugin (any type) python3 traceback labels Jun 29, 2021
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.

LGTM. Thanks @tremble.

@tremble tremble added the gate label Jun 29, 2021
@ansible-zuul ansible-zuul bot merged commit 9024067 into ansible-collections:main Jun 29, 2021
@tremble tremble deleted the stability/ec2_vpc_peer branch June 29, 2021 12:54
alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this pull request Jul 16, 2021
…bility/ec2_vpc_peer

Add NotFound retries when tagging a new VPC Peering connection

SUMMARY
Prior to botocore 1.17.24 it wasn't possible to tag the connection as a part of the creation call.  As such a separate create_tags call is performed after the creation.  However, this leads to a race condition when "I(wait=False)".
Rather than adding hard to test logic, add InvalidVpcPeeringConnectionID.NotFound retries to the tagging.
Also move from custom tag handling code over to the shared code in ansible_collections.amazon.aws.plugins.module_utils.ec2
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ec2_vpc_peer
ADDITIONAL INFORMATION
TASK [ec2_vpc_peer : Create local account VPC peering Connection] **************
task path: /home/zuul/.ansible/collections/ansible_collections/community/aws/tests/integration/targets/ec2_vpc_peer/tasks/main.yml:403
<testhost> ESTABLISH LOCAL CONNECTION FOR USER: zuul
<testhost> EXEC /bin/sh -c 'echo ~zuul && sleep 0'
<testhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/zuul/.ansible/tmp `"&& mkdir "` echo /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910 `" && echo ansible-tmp-1624925621.1931164-8629-186765425497910="` echo /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910 `" ) && sleep 0'
Using module file /home/zuul/.ansible/collections/ansible_collections/community/aws/plugins/modules/ec2_vpc_peer.py
<testhost> PUT /home/zuul/.ansible/tmp/ansible-local-8151h1f3kbcc/tmplyozom8u TO /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/AnsiballZ_ec2_vpc_peer.py
<testhost> EXEC /bin/sh -c 'chmod u+x /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/ /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/AnsiballZ_ec2_vpc_peer.py && sleep 0'
<testhost> EXEC /bin/sh -c 'ANSIBLE_DEBUG_BOTOCORE_LOGS=True /home/zuul/venv/bin/python3.6 /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/AnsiballZ_ec2_vpc_peer.py && sleep 0'
<testhost> EXEC /bin/sh -c 'rm -f -r /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
  File "/tmp/ansible_ec2_vpc_peer_payload_bbdh2ojz/ansible_ec2_vpc_peer_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_vpc_peer.py", line 559, in create_tags
  File "/tmp/ansible_ec2_vpc_peer_payload_bbdh2ojz/ansible_ec2_vpc_peer_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/core.py", line 288, in deciding_wrapper
    return retrying_wrapper(*args, **kwargs)
  File "/tmp/ansible_ec2_vpc_peer_payload_bbdh2ojz/ansible_ec2_vpc_peer_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/cloud.py", line 154, in retry_func
    raise e
  File "/tmp/ansible_ec2_vpc_peer_payload_bbdh2ojz/ansible_ec2_vpc_peer_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/cloud.py", line 144, in retry_func
    return f(*args, **kwargs)
  File "/home/zuul/venv/lib/python3.6/site-packages/botocore/client.py", line 386, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/zuul/venv/lib/python3.6/site-packages/botocore/client.py", line 705, in _make_api_call
    raise error_class(parsed_response, operation_name)
fatal: [testhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "aws_access_key": "ASIA6CCDWXDOPPPI445H",
            "aws_ca_bundle": null,
            "aws_config": null,
            "aws_secret_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "debug_botocore_endpoint_logs": true,
            "ec2_url": null,
            "peer_owner_id": null,
            "peer_region": null,
            "peer_vpc_id": "vpc-0deec00ddeb3584bf",
            "peering_id": null,
            "profile": null,
            "region": "us-east-1",
            "security_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "state": "present",
            "tags": {
                "Name": "Peering connection for VPC vpc-018bc7cc64b0731f9 to VPC vpc-0deec00ddeb3584bf"
            },
            "validate_certs": true,
            "vpc_id": "vpc-018bc7cc64b0731f9",
            "wait": false
        }
    },
    "msg": "An error occurred (InvalidVpcPeeringConnectionID.NotFound) when calling the CreateTags operation: The vpcPeeringConnection ID 'pcx-06ed26ea8993aba5b' does not exist",
    "resource_actions": [
        "ec2:DeleteTags",
        "ec2:CreateTags",
        "ec2:CreateVpcPeeringConnection",
        "ec2:DescribeVpcPeeringConnections"
    ]
}

Reviewed-by: Alina Buzachis <None>

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections@9024067
alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this pull request Jul 19, 2021
…_vpc_peer

Add NotFound retries when tagging a new VPC Peering connection

SUMMARY
Prior to botocore 1.17.24 it wasn't possible to tag the connection as a part of the creation call.  As such a separate create_tags call is performed after the creation.  However, this leads to a race condition when "I(wait=False)".
Rather than adding hard to test logic, add InvalidVpcPeeringConnectionID.NotFound retries to the tagging.
Also move from custom tag handling code over to the shared code in ansible_collections.amazon.aws.plugins.module_utils.ec2
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ec2_vpc_peer
ADDITIONAL INFORMATION
TASK [ec2_vpc_peer : Create local account VPC peering Connection] **************
task path: /home/zuul/.ansible/collections/ansible_collections/community/aws/tests/integration/targets/ec2_vpc_peer/tasks/main.yml:403
<testhost> ESTABLISH LOCAL CONNECTION FOR USER: zuul
<testhost> EXEC /bin/sh -c 'echo ~zuul && sleep 0'
<testhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/zuul/.ansible/tmp `"&& mkdir "` echo /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910 `" && echo ansible-tmp-1624925621.1931164-8629-186765425497910="` echo /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910 `" ) && sleep 0'
Using module file /home/zuul/.ansible/collections/ansible_collections/community/aws/plugins/modules/ec2_vpc_peer.py
<testhost> PUT /home/zuul/.ansible/tmp/ansible-local-8151h1f3kbcc/tmplyozom8u TO /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/AnsiballZ_ec2_vpc_peer.py
<testhost> EXEC /bin/sh -c 'chmod u+x /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/ /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/AnsiballZ_ec2_vpc_peer.py && sleep 0'
<testhost> EXEC /bin/sh -c 'ANSIBLE_DEBUG_BOTOCORE_LOGS=True /home/zuul/venv/bin/python3.6 /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/AnsiballZ_ec2_vpc_peer.py && sleep 0'
<testhost> EXEC /bin/sh -c 'rm -f -r /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
  File "/tmp/ansible_ec2_vpc_peer_payload_bbdh2ojz/ansible_ec2_vpc_peer_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_vpc_peer.py", line 559, in create_tags
  File "/tmp/ansible_ec2_vpc_peer_payload_bbdh2ojz/ansible_ec2_vpc_peer_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/core.py", line 288, in deciding_wrapper
    return retrying_wrapper(*args, **kwargs)
  File "/tmp/ansible_ec2_vpc_peer_payload_bbdh2ojz/ansible_ec2_vpc_peer_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/cloud.py", line 154, in retry_func
    raise e
  File "/tmp/ansible_ec2_vpc_peer_payload_bbdh2ojz/ansible_ec2_vpc_peer_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/cloud.py", line 144, in retry_func
    return f(*args, **kwargs)
  File "/home/zuul/venv/lib/python3.6/site-packages/botocore/client.py", line 386, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/zuul/venv/lib/python3.6/site-packages/botocore/client.py", line 705, in _make_api_call
    raise error_class(parsed_response, operation_name)
fatal: [testhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "aws_access_key": "ASIA6CCDWXDOPPPI445H",
            "aws_ca_bundle": null,
            "aws_config": null,
            "aws_secret_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "debug_botocore_endpoint_logs": true,
            "ec2_url": null,
            "peer_owner_id": null,
            "peer_region": null,
            "peer_vpc_id": "vpc-0deec00ddeb3584bf",
            "peering_id": null,
            "profile": null,
            "region": "us-east-1",
            "security_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "state": "present",
            "tags": {
                "Name": "Peering connection for VPC vpc-018bc7cc64b0731f9 to VPC vpc-0deec00ddeb3584bf"
            },
            "validate_certs": true,
            "vpc_id": "vpc-018bc7cc64b0731f9",
            "wait": false
        }
    },
    "msg": "An error occurred (InvalidVpcPeeringConnectionID.NotFound) when calling the CreateTags operation: The vpcPeeringConnection ID 'pcx-06ed26ea8993aba5b' does not exist",
    "resource_actions": [
        "ec2:DeleteTags",
        "ec2:CreateTags",
        "ec2:CreateVpcPeeringConnection",
        "ec2:DescribeVpcPeeringConnections"
    ]
}

Reviewed-by: Alina Buzachis <None>
alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this pull request Jul 19, 2021
…_vpc_peer

Add NotFound retries when tagging a new VPC Peering connection

SUMMARY
Prior to botocore 1.17.24 it wasn't possible to tag the connection as a part of the creation call.  As such a separate create_tags call is performed after the creation.  However, this leads to a race condition when "I(wait=False)".
Rather than adding hard to test logic, add InvalidVpcPeeringConnectionID.NotFound retries to the tagging.
Also move from custom tag handling code over to the shared code in ansible_collections.amazon.aws.plugins.module_utils.ec2
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ec2_vpc_peer
ADDITIONAL INFORMATION
TASK [ec2_vpc_peer : Create local account VPC peering Connection] **************
task path: /home/zuul/.ansible/collections/ansible_collections/community/aws/tests/integration/targets/ec2_vpc_peer/tasks/main.yml:403
<testhost> ESTABLISH LOCAL CONNECTION FOR USER: zuul
<testhost> EXEC /bin/sh -c 'echo ~zuul && sleep 0'
<testhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/zuul/.ansible/tmp `"&& mkdir "` echo /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910 `" && echo ansible-tmp-1624925621.1931164-8629-186765425497910="` echo /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910 `" ) && sleep 0'
Using module file /home/zuul/.ansible/collections/ansible_collections/community/aws/plugins/modules/ec2_vpc_peer.py
<testhost> PUT /home/zuul/.ansible/tmp/ansible-local-8151h1f3kbcc/tmplyozom8u TO /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/AnsiballZ_ec2_vpc_peer.py
<testhost> EXEC /bin/sh -c 'chmod u+x /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/ /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/AnsiballZ_ec2_vpc_peer.py && sleep 0'
<testhost> EXEC /bin/sh -c 'ANSIBLE_DEBUG_BOTOCORE_LOGS=True /home/zuul/venv/bin/python3.6 /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/AnsiballZ_ec2_vpc_peer.py && sleep 0'
<testhost> EXEC /bin/sh -c 'rm -f -r /home/zuul/.ansible/tmp/ansible-tmp-1624925621.1931164-8629-186765425497910/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
  File "/tmp/ansible_ec2_vpc_peer_payload_bbdh2ojz/ansible_ec2_vpc_peer_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_vpc_peer.py", line 559, in create_tags
  File "/tmp/ansible_ec2_vpc_peer_payload_bbdh2ojz/ansible_ec2_vpc_peer_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/core.py", line 288, in deciding_wrapper
    return retrying_wrapper(*args, **kwargs)
  File "/tmp/ansible_ec2_vpc_peer_payload_bbdh2ojz/ansible_ec2_vpc_peer_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/cloud.py", line 154, in retry_func
    raise e
  File "/tmp/ansible_ec2_vpc_peer_payload_bbdh2ojz/ansible_ec2_vpc_peer_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/cloud.py", line 144, in retry_func
    return f(*args, **kwargs)
  File "/home/zuul/venv/lib/python3.6/site-packages/botocore/client.py", line 386, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/zuul/venv/lib/python3.6/site-packages/botocore/client.py", line 705, in _make_api_call
    raise error_class(parsed_response, operation_name)
fatal: [testhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "aws_access_key": "ASIA6CCDWXDOPPPI445H",
            "aws_ca_bundle": null,
            "aws_config": null,
            "aws_secret_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "debug_botocore_endpoint_logs": true,
            "ec2_url": null,
            "peer_owner_id": null,
            "peer_region": null,
            "peer_vpc_id": "vpc-0deec00ddeb3584bf",
            "peering_id": null,
            "profile": null,
            "region": "us-east-1",
            "security_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "state": "present",
            "tags": {
                "Name": "Peering connection for VPC vpc-018bc7cc64b0731f9 to VPC vpc-0deec00ddeb3584bf"
            },
            "validate_certs": true,
            "vpc_id": "vpc-018bc7cc64b0731f9",
            "wait": false
        }
    },
    "msg": "An error occurred (InvalidVpcPeeringConnectionID.NotFound) when calling the CreateTags operation: The vpcPeeringConnection ID 'pcx-06ed26ea8993aba5b' does not exist",
    "resource_actions": [
        "ec2:DeleteTags",
        "ec2:CreateTags",
        "ec2:CreateVpcPeeringConnection",
        "ec2:DescribeVpcPeeringConnections"
    ]
}

Reviewed-by: Alina Buzachis <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug community_review module module needs_triage owner_pr PR created by owner/maintainer plugins plugin (any type) python3 traceback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants