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

Prepare ec2_vpc_vgw_* modules for promotion #2171

Conversation

mandar242
Copy link
Contributor

@mandar242 mandar242 commented Oct 10, 2024

SUMMARY

Depends-On: ansible-collections/amazon.aws#2331
Prepare ec2_vpc_vgw_* modules for promotion

ISSUE TYPE
  • Bugfix Pull Request
  • Docs Pull Request
  • Feature Pull Request
  • New Module Pull Request
COMPONENT NAME

ec2_vpc_vgw
ec2_vpc_vgw_info

ADDITIONAL INFORMATION

Copy link

github-actions bot commented Oct 10, 2024

Docs Build 📝

Thank you for contribution!✨

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

This comment was marked as outdated.

This comment was marked as outdated.

plugins/modules/ec2_vpc_vgw.py Outdated Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw_info.py Outdated Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw.py Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw_info.py Outdated Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw_info.py Outdated Show resolved Hide resolved
@mandar242 mandar242 force-pushed the prepare_ec2_vpc_vgw_ branch from a7ef6b2 to a7550db Compare October 15, 2024 21:20

This comment was marked as outdated.

This comment was marked as outdated.

Copy link
Contributor

@abikouo abikouo left a comment

Choose a reason for hiding this comment

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

Please update the documentation of the ec2_vpc_vgw module, the state argument has values C(present) and C(absent), should be V(present) and V(absent) instead.
You also need to update the ec2_vpc_vgw integration test case: add uppercase to tasks names and use FQCN for module.

plugins/modules/ec2_vpc_vgw.py Outdated Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw.py Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw.py Outdated Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw.py Outdated Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw.py Outdated Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw.py Outdated Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw.py Outdated Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw.py Outdated Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw_info.py Outdated Show resolved Hide resolved
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.

Can you also check why some tasks are commented out in the integration tests https://github.com/ansible-collections/community.aws/blob/main/tests/integration/targets/ec2_vpc_vgw/tasks/tags.yml and make sure that the module is fully tested, adding more tests if necessary?

plugins/modules/ec2_vpc_vgw.py Outdated Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw.py Outdated Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw_info.py Show resolved Hide resolved

This comment was marked as outdated.

@mandar242 mandar242 force-pushed the prepare_ec2_vpc_vgw_ branch from b8497ac to 29639e8 Compare October 17, 2024 02:58

This comment was marked as outdated.

@mandar242
Copy link
Contributor Author

Can you also check why some tasks are commented out in the integration tests https://github.com/ansible-collections/community.aws/blob/main/tests/integration/targets/ec2_vpc_vgw/tasks/tags.yml and make sure that the module is fully tested, adding more tests if necessary?

ec2_vpc_vgw did not had check_mode support. Added check_mode support and enabled tests, added more tests.

This comment was marked as outdated.

Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/708b9b23f1b745809eacaa0364525bca

✔️ ansible-galaxy-importer SUCCESS in 3m 18s (non-voting)
✔️ build-ansible-collection SUCCESS in 10m 38s
✔️ ansible-test-splitter SUCCESS in 4m 06s
integration-community.aws-1 FAILURE in 5m 40s
Skipped 21 jobs

plugins/modules/ec2_vpc_vgw.py Outdated Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw.py Outdated Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw.py Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw.py Outdated Show resolved Hide resolved
Comment on lines 222 to 239
if desired_status == "attached":
wait_for_resource_state(
client,
module,
"vpn_gateway_attached",
VpnGatewayIds=vpn_gateway_id,
delay=polling_increment_secs,
max_attempts=max_retries,
)
elif desired_status == "detached":
wait_for_resource_state(
client,
module,
"vpn_gateway_detached",
VpnGatewayIds=vpn_gateway_id,
delay=polling_increment_secs,
max_attempts=max_retries,
)
Copy link
Contributor

@alinabuzachis alinabuzachis Oct 18, 2024

Choose a reason for hiding this comment

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

Suggested change
if desired_status == "attached":
wait_for_resource_state(
client,
module,
"vpn_gateway_attached",
VpnGatewayIds=vpn_gateway_id,
delay=polling_increment_secs,
max_attempts=max_retries,
)
elif desired_status == "detached":
wait_for_resource_state(
client,
module,
"vpn_gateway_detached",
VpnGatewayIds=vpn_gateway_id,
delay=polling_increment_secs,
max_attempts=max_retries,
)
if desired_status not in ("attached", "detached"):
module.fail_json(msg=f"Unsupported status: {desired_status}")
wait_for_resource_state(
client,
module,
f"vpn_gateway_{desired_status}",
VpnGatewayIds=[vpn_gateway_id],
delay=polling_increment_secs,
max_attempts=max_retries,
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changing VpnGatewayIds=vpn_gateway_id to VpnGatewayIds=[vpn_gateway_id] causes failure with

"msg": "An exception happened while trying to wait for 'vpn_gateway_attached': Parameter validation failed:\nInvalid type for parameter VpnGatewayIds[0], value: ['vgw-0c3df60baf0acc49f'], type: <class 'list'>, valid types: <class 'str'>",
    "resource_actions": [
        "ec2:DescribeVpnGateways",
        "ec2:CreateVpnGateway",
        "ec2:AttachVpnGateway"
    ]

even though API states otherwise it to be a list of str, weird.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same as below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @alinabuzachis , fixed. It was indeed being passed as List[Str] at the API call.
Only thing was that it was handled to be passed as List[Str] earlier in the function call tree.
Updated the code to ensure it is passed as List[Str] before calling module_utils/ec2 functions.
27b07e0


result = response
return result


def find_vgw(client, module, vpn_gateway_id=None):
def find_vgw(
client, module: AnsibleAWSModule, vpn_gateway_id: Optional[Union[str, List[str]]] = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
client, module: AnsibleAWSModule, vpn_gateway_id: Optional[Union[str, List[str]]] = None
client, module: AnsibleAWSModule, vpn_gateway_id: Optional[str] = None

Copy link
Contributor

Choose a reason for hiding this comment

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

We should also update the way the VpcGatewayIds attribute of the describe_vpn_gateways()
See suggestion below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @alinabuzachis @abikouo , fixed. It was indeed being passed as List[Str] at the API call.
Only thing was that it was handled to be passed as List[Str] earlier in the function call tree.
Updated the code to ensure it is passed as List[Str] before calling module_utils/ec2 functions.
27b07e0

def find_vgw(client, module, vpn_gateway_id=None):
def find_vgw(
client, module: AnsibleAWSModule, vpn_gateway_id: Optional[Union[str, List[str]]] = None
) -> List[Dict[str, Any]]:
params = dict()
if vpn_gateway_id:
params["VpnGatewayIds"] = vpn_gateway_id
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
params["VpnGatewayIds"] = vpn_gateway_id
params["VpnGatewayIds"] = [vpn_gateway_id]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure what happens with the API but it fails with

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: Invalid type for parameter VpnGatewayIds[0], value: ['vgw-0849b49ec813d18ee'], type: <class 'list'>, valid types: <class 'str'>

Copy link
Contributor

Choose a reason for hiding this comment

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

Same as below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @alinabuzachis , fixed. It was indeed being passed as List[Str] at the API call.
Only thing was that it was handled to be passed as List[Str] earlier in the function call tree.
Updated the code to ensure it is passed as List[Str] before calling module_utils/ec2 functions.
27b07e0

plugins/modules/ec2_vpc_vgw.py Outdated Show resolved Hide resolved
plugins/modules/ec2_vpc_vgw.py Outdated Show resolved Hide resolved
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/3f5ea44d491f4bf6959d2c363854ff61

ansible-galaxy-importer FAILURE in 3m 46s (non-voting)
✔️ build-ansible-collection SUCCESS in 10m 05s
✔️ ansible-test-splitter SUCCESS in 3m 51s
integration-community.aws-1 FAILURE in 7m 13s
Skipped 21 jobs

Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/022f602238144ecaa51cbf3eff154458

ansible-galaxy-importer FAILURE in 3m 16s (non-voting)
✔️ build-ansible-collection SUCCESS in 10m 07s
✔️ ansible-test-splitter SUCCESS in 3m 52s
integration-community.aws-1 FAILURE in 4m 42s
Skipped 21 jobs

Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/68bfef1eb29e4bf58e17b1aac472e2f1

ansible-galaxy-importer FAILURE in 5m 09s (non-voting)
✔️ build-ansible-collection SUCCESS in 10m 34s
✔️ ansible-test-splitter SUCCESS in 3m 53s
integration-community.aws-1 FAILURE in 6m 12s
Skipped 21 jobs

Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/a3a0172fbbcd402088d4241473727809

ansible-galaxy-importer FAILURE in 4m 38s (non-voting)
✔️ build-ansible-collection SUCCESS in 11m 11s
✔️ ansible-test-splitter SUCCESS in 3m 54s
integration-community.aws-1 FAILURE in 7m 21s
Skipped 21 jobs

@alinabuzachis
Copy link
Contributor

recheck

Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/c3dc59f0223a4f86af0a56762d843c3f

ansible-galaxy-importer FAILURE in 4m 55s (non-voting)
✔️ build-ansible-collection SUCCESS in 10m 48s
✔️ ansible-test-splitter SUCCESS in 4m 19s
integration-community.aws-1 FAILURE in 40m 04s
✔️ integration-community.aws-2 SUCCESS in 22m 59s
✔️ integration-community.aws-3 SUCCESS in 15m 27s
✔️ integration-community.aws-4 SUCCESS in 10m 02s
✔️ integration-community.aws-5 SUCCESS in 8m 10s
✔️ integration-community.aws-6 SUCCESS in 8m 08s
✔️ integration-community.aws-7 SUCCESS in 21m 47s
✔️ integration-community.aws-8 SUCCESS in 11m 42s
✔️ integration-community.aws-9 SUCCESS in 7m 57s
Skipped 13 jobs

@alinabuzachis
Copy link
Contributor

recheck

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.

Can you please ensure that the other linter test are green (don't worry about the import errors for the moment)?

ERROR: plugins/modules/ec2_vpc_vgw.py:99:30: invalid-examples: EXAMPLES is not valid YAML
ERROR: plugins/modules/ec2_vpc_vgw_info.py:0:0: invalid-documentation-markup: Directive "RV(resource_tags)" contains a non-existing return value "resource_tags"
ERROR: plugins/modules/ec2_vpc_vgw_info.py:0:0: invalid-documentation-markup: Directive "RV(tags)" contains a non-existing return value "tags"

Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/fdf5ef40761843db97a0532008a2788a

✔️ ansible-galaxy-importer SUCCESS in 3m 12s (non-voting)
✔️ build-ansible-collection SUCCESS in 11m 04s
✔️ ansible-test-splitter SUCCESS in 4m 19s
✔️ integration-community.aws-1 SUCCESS in 37m 37s
✔️ integration-community.aws-2 SUCCESS in 31m 01s
integration-community.aws-3 FAILURE in 14m 52s
✔️ integration-community.aws-4 SUCCESS in 6m 53s
✔️ integration-community.aws-5 SUCCESS in 9m 45s
✔️ integration-community.aws-6 SUCCESS in 6m 41s
✔️ integration-community.aws-7 SUCCESS in 24m 42s
✔️ integration-community.aws-8 SUCCESS in 9m 30s
integration-community.aws-9 FAILURE in 21m 25s
Skipped 13 jobs

@alinabuzachis
Copy link
Contributor

recheck

@alinabuzachis
Copy link
Contributor

@mandar242 there are still other linting issues.

Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/303094a3f30e4f5ab642a04340a26fc2

ansible-galaxy-importer FAILURE in 4m 29s (non-voting)
✔️ build-ansible-collection SUCCESS in 10m 22s
✔️ ansible-test-splitter SUCCESS in 4m 01s
✔️ integration-community.aws-1 SUCCESS in 9m 31s
Skipped 21 jobs

@GomathiselviS GomathiselviS dismissed abikouo’s stale review October 23, 2024 13:29

When state == absent, the expectation and the current behavior is to delete the vgw.

@GomathiselviS GomathiselviS added the mergeit Merge the PR (SoftwareFactory) label Oct 23, 2024
Copy link
Contributor

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

ansible-galaxy-importer FAILURE in 3m 46s (non-voting)
✔️ build-ansible-collection SUCCESS in 10m 06s
✔️ ansible-test-splitter SUCCESS in 4m 09s
✔️ integration-community.aws-1 SUCCESS in 9m 04s
Skipped 21 jobs

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit b78cba1 into ansible-collections:main Oct 23, 2024
66 of 67 checks passed
alinabuzachis pushed a commit to abikouo/community.aws that referenced this pull request Oct 24, 2024
SUMMARY

Depends-On: ansible-collections/amazon.aws#2331
Prepare ec2_vpc_vgw_* modules for promotion

ISSUE TYPE


Bugfix Pull Request
Docs Pull Request
Feature Pull Request
New Module Pull Request

COMPONENT NAME

ec2_vpc_vgw
ec2_vpc_vgw_info
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis
Reviewed-by: Mandar Kulkarni <[email protected]>
Reviewed-by: Bikouo Aubin
Reviewed-by: GomathiselviS <[email protected]>
alinabuzachis pushed a commit to mandar242/community.aws that referenced this pull request Oct 25, 2024
SUMMARY

Depends-On: ansible-collections/amazon.aws#2331
Prepare ec2_vpc_vgw_* modules for promotion

ISSUE TYPE


Bugfix Pull Request
Docs Pull Request
Feature Pull Request
New Module Pull Request

COMPONENT NAME

ec2_vpc_vgw
ec2_vpc_vgw_info
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis
Reviewed-by: Mandar Kulkarni <[email protected]>
Reviewed-by: Bikouo Aubin
Reviewed-by: GomathiselviS <[email protected]>
alinabuzachis pushed a commit to GomathiselviS/community.aws that referenced this pull request Oct 25, 2024
SUMMARY

Depends-On: ansible-collections/amazon.aws#2331
Prepare ec2_vpc_vgw_* modules for promotion

ISSUE TYPE


Bugfix Pull Request
Docs Pull Request
Feature Pull Request
New Module Pull Request

COMPONENT NAME

ec2_vpc_vgw
ec2_vpc_vgw_info
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis
Reviewed-by: Mandar Kulkarni <[email protected]>
Reviewed-by: Bikouo Aubin
Reviewed-by: GomathiselviS <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mergeit Merge the PR (SoftwareFactory)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants