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

ec2_vpc_nat_gateway show fails if EIP doesn't exist #1604

Merged

Conversation

taehopark32
Copy link
Contributor

@taehopark32 taehopark32 commented Jun 6, 2023

SUMMARY

Fixes #1295

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

plugins/modules/ec2_vpc_nat_gateway

ADDITIONAL INFORMATION

@taehopark32 taehopark32 changed the title ec2_vpc_nat_gateway show fails if EIP doesn't exist WIP: ec2_vpc_nat_gateway show fails if EIP doesn't exist Jun 6, 2023
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/8598e269ee384b9aa5a3de5e3bb59992

✔️ ansible-galaxy-importer SUCCESS in 5m 02s
✔️ build-ansible-collection SUCCESS in 12m 45s
✔️ ansible-test-splitter SUCCESS in 4m 39s
✔️ integration-amazon.aws-1 SUCCESS in 19m 07s
Skipped 43 jobs

@taehopark32 taehopark32 changed the title WIP: ec2_vpc_nat_gateway show fails if EIP doesn't exist [WIP] ec2_vpc_nat_gateway show fails if EIP doesn't exist Jun 7, 2023
@taehopark32 taehopark32 changed the title [WIP] ec2_vpc_nat_gateway show fails if EIP doesn't exist ec2_vpc_nat_gateway show fails if EIP doesn't exist Jun 15, 2023
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/1f7703703ef747be92c385cae71e4854

✔️ ansible-galaxy-importer SUCCESS in 4m 12s
✔️ build-ansible-collection SUCCESS in 12m 32s
✔️ ansible-test-splitter SUCCESS in 5m 10s
✔️ integration-amazon.aws-1 SUCCESS in 22m 15s
Skipped 43 jobs

@github-actions
Copy link

github-actions bot commented Jun 15, 2023

Docs Build 📝

Thank you for contribution!✨

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

jillr
jillr previously requested changes Jun 15, 2023
Copy link
Contributor

@jillr jillr left a comment

Choose a reason for hiding this comment

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

The new parameter needs to be added in a couple other places.
In the DOCUMENTATION block at the top of the file (make sure to document that the default value is False) https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_documenting.html#documentation-block

In the module argument_spec in main().
This is also where you set the default value as False. (The types in the documentation must match the types in the arg spec, linting rules will check this)
https://docs.ansible.com/ansible/latest/dev_guide/developing_program_flow_modules.html#argument-spec

The value of the parameter must then be assigned to a variable in this section: https://github.com/ansible-collections/amazon.aws/blob/main/plugins/modules/ec2_vpc_nat_gateway.py#L881-L892
That value would be passed to functions that need it, instead of being defined through the code.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/3f03290b4cd348faac1ffc642034b288

✔️ ansible-galaxy-importer SUCCESS in 4m 57s
✔️ build-ansible-collection SUCCESS in 14m 14s
✔️ ansible-test-splitter SUCCESS in 4m 43s
✔️ integration-amazon.aws-1 SUCCESS in 22m 21s
Skipped 43 jobs

plugins/modules/ec2_vpc_nat_gateway.py Show resolved Hide resolved
@@ -75,6 +75,11 @@
When specifying this option, ensure you specify the eip_address parameter
as well otherwise any subsequent runs will fail.
type: str
default_create:
description:
- if EIP address is not found, create NAT gateway with EIP address as null.
Copy link
Collaborator

@alinabuzachis alinabuzachis Jun 16, 2023

Choose a reason for hiding this comment

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

I guess the description of this parameter must be carified. What happens when the users specifies an invalid allocation_id? Does default_create: True allow to still create the NAT gateway and allocate a new EIP?

Something like this:

  • When I(default_create=True), if I(eip_address) is set and it is invalid or does not exist, the NAT gateway is successfully created and a new EIP is automatically allocated.
  • When I(default_create=True), if I(allocation_id) is set and it is invalid or not found, the NAT gateway is successfully created and a new EIP is automatically allocated. (If this is true!!!)
  • When I(default_create=False), what happens?

Please feel free to rephrase and correct my suggestions.

taehopark32 and others added 2 commits June 16, 2023 09:48
Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>
Co-authored-by: Alina Buzachis <abuzachis@redhat.com>
@softwarefactory-project-zuul
Copy link
Contributor

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

✔️ ansible-galaxy-importer SUCCESS in 4m 13s
✔️ build-ansible-collection SUCCESS in 12m 54s
✔️ ansible-test-splitter SUCCESS in 4m 44s
✔️ integration-amazon.aws-1 SUCCESS in 22m 06s
Skipped 43 jobs

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/7457322da94c4d009ad5fc0c39e6c5d3

✔️ ansible-galaxy-importer SUCCESS in 4m 43s
✔️ build-ansible-collection SUCCESS in 13m 21s
✔️ ansible-test-splitter SUCCESS in 4m 40s
✔️ integration-amazon.aws-1 SUCCESS in 19m 21s
Skipped 43 jobs

Comment on lines 80 to 89
- When I(default_create=True), if I(eip_address) is set and it is not found, the NAT
gateway is successfully created and a new EIP is automatically allocated.
- The validity of the I(allocation_id) is independent of the I(default_create). If
I(allocation_id) is set and it is invalid or not found, this will fail, regardless
of I(default_create).
- The validity of the I(eip_address) is independent of the I(default_create). If
I(eip_address) is set and it is invalid, this will fail, regardless of
I(default_create).
- When I (default_create=False), if I(eip_address) is set and it is invalid or does not
exist, this will fail.
Copy link
Member

Choose a reason for hiding this comment

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

This parameter only comes into play when eip_address has been set. IMO I would keep the allocation_id out of the description and state that the parameter has no effect when eip_address has not been set:

- When I(default_create=True) and I(eip_address) has been set, but not yet allocated, the NAT gateway is created and a new EIP is automatically allocated.
- When I(default_create=False) and I(eip_address) has been set, but not yet allocated, the module will fail.
- If I(eip_address) has not been set, this parameter has no effect.

That said, what you have looks correct and makes sense, so I don't have a problem with merging as is. I'll let @alinabuzachis make the call.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If allocation_id is out, it does not make sense to mention it. Agreed with @gravesm! @taehopark32 Thanks for updating docs!

Copy link
Collaborator

@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.

@taehopark32 This looks great to me if you remove the reference to the allocation_id since the parameter applies only to eip_address.

Comment on lines 80 to 89
- When I(default_create=True), if I(eip_address) is set and it is not found, the NAT
gateway is successfully created and a new EIP is automatically allocated.
- The validity of the I(allocation_id) is independent of the I(default_create). If
I(allocation_id) is set and it is invalid or not found, this will fail, regardless
of I(default_create).
- The validity of the I(eip_address) is independent of the I(default_create). If
I(eip_address) is set and it is invalid, this will fail, regardless of
I(default_create).
- When I (default_create=False), if I(eip_address) is set and it is invalid or does not
exist, this will fail.
Copy link
Collaborator

Choose a reason for hiding this comment

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

If allocation_id is out, it does not make sense to mention it. Agreed with @gravesm! @taehopark32 Thanks for updating docs!

@alinabuzachis alinabuzachis added the backport-6 PR should be backported to the stable-6 branch label Jun 16, 2023
@softwarefactory-project-zuul
Copy link
Contributor

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

✔️ ansible-galaxy-importer SUCCESS in 4m 55s
✔️ build-ansible-collection SUCCESS in 13m 03s
✔️ ansible-test-splitter SUCCESS in 7m 19s
✔️ integration-amazon.aws-1 SUCCESS in 20m 46s
Skipped 43 jobs

@taehopark32
Copy link
Contributor Author

@alinabuzachis Thank you. I fixed the description and passed all the tests.

@alinabuzachis alinabuzachis requested a review from abikouo June 27, 2023 09:19
@alinabuzachis alinabuzachis requested a review from jillr June 27, 2023 09:20
@alinabuzachis alinabuzachis added the mergeit Merge the PR (SoftwareFactory) label Jul 3, 2023
@alinabuzachis alinabuzachis dismissed stale reviews from abikouo and jillr July 4, 2023 11:31

We have already 2 approvals.

@alinabuzachis
Copy link
Collaborator

regate

@softwarefactory-project-zuul
Copy link
Contributor

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

✔️ ansible-galaxy-importer SUCCESS in 4m 30s
✔️ build-ansible-collection SUCCESS in 13m 29s
✔️ ansible-test-splitter SUCCESS in 4m 47s
✔️ integration-amazon.aws-1 SUCCESS in 30m 21s
Skipped 43 jobs

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 6f207ec into ansible-collections:main Jul 4, 2023
@patchback
Copy link

patchback bot commented Jul 4, 2023

Backport to stable-6: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-6/6f207ec1b77bcee134df9e51d59215e8e6a948c7/pr-1604

Backported as #1642

🤖 @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 Jul 4, 2023
ec2_vpc_nat_gateway show fails if EIP doesn't exist

SUMMARY

Fixes #1295

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
plugins/modules/ec2_vpc_nat_gateway
ADDITIONAL INFORMATION

Reviewed-by: Jill R
Reviewed-by: Bikouo Aubin
Reviewed-by: Alina Buzachis
Reviewed-by: Mike Graves <mgraves@redhat.com>
(cherry picked from commit 6f207ec)
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Jul 4, 2023
[PR #1604/6f207ec1 backport][stable-6] ec2_vpc_nat_gateway show fails if EIP doesn't exist

This is a backport of PR #1604 as merged into main (6f207ec).
SUMMARY

Fixes #1295

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME
plugins/modules/ec2_vpc_nat_gateway
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-6 PR should be backported to the stable-6 branch mergeit Merge the PR (SoftwareFactory)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ec2_vpc_nat_gateway fails silently if EIP doesn't exist
5 participants