Skip to content

td/aws_networkmanager_core network_policy-enhancements #30879

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

Conversation

GlennChia
Copy link
Collaborator

Description

Currently the api ExecuteCoreNetworkChangeSetWithContext is called in a retry when there is an error of Incorrect input which stems from a network policy not being in the correct state. Instead of using a retry, this PR introduces a wait condition to ensure the policy is in the READY_TO_EXECUTE state before executing it. The waiter also catches errors when a FAILED_GENERATION state is detected.

As part of this waiter, the finder function is refactored to take in a policy version id so that we can accurately wait for the correct policy to finish. For compatibility with the other APIs, we introduce a -1 check and default to reading the latest policy versions.

Separetely, this PR also adds a test case to check for expected errors should there be an incorrect policy. This helps to test if policy errors can be detected early with an intuitive error message.

Relations

Relates #28867

References

Output from Acceptance Testing

$ make testacc TESTARGS='-run=TestAccNetworkManagerCoreNetwork' PKG=networkmanager
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/networkmanager/... -v -count 1 -parallel 20  -run=TestAccNetworkManagerCoreNetwork -timeout 180m
=== RUN   TestAccNetworkManagerCoreNetworkPolicyAttachment_basic
=== PAUSE TestAccNetworkManagerCoreNetworkPolicyAttachment_basic
=== RUN   TestAccNetworkManagerCoreNetworkPolicyAttachment_vpcAttachment
=== PAUSE TestAccNetworkManagerCoreNetworkPolicyAttachment_vpcAttachment
=== RUN   TestAccNetworkManagerCoreNetworkPolicyAttachment_vpcAttachmentMultiRegion
=== PAUSE TestAccNetworkManagerCoreNetworkPolicyAttachment_vpcAttachmentMultiRegion
=== RUN   TestAccNetworkManagerCoreNetworkPolicyAttachment_expectPolicyErrorInvalidASNRange
=== PAUSE TestAccNetworkManagerCoreNetworkPolicyAttachment_expectPolicyErrorInvalidASNRange
=== RUN   TestAccNetworkManagerCoreNetworkPolicyDocumentDataSource_basic
=== PAUSE TestAccNetworkManagerCoreNetworkPolicyDocumentDataSource_basic
=== RUN   TestAccNetworkManagerCoreNetwork_basic
=== PAUSE TestAccNetworkManagerCoreNetwork_basic
=== RUN   TestAccNetworkManagerCoreNetwork_disappears
=== PAUSE TestAccNetworkManagerCoreNetwork_disappears
=== RUN   TestAccNetworkManagerCoreNetwork_tags
=== PAUSE TestAccNetworkManagerCoreNetwork_tags
=== RUN   TestAccNetworkManagerCoreNetwork_description
=== PAUSE TestAccNetworkManagerCoreNetwork_description
=== RUN   TestAccNetworkManagerCoreNetwork_policyDocument
=== PAUSE TestAccNetworkManagerCoreNetwork_policyDocument
=== RUN   TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithoutRegion
=== PAUSE TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithoutRegion
=== RUN   TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithRegion
=== PAUSE TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithRegion
=== RUN   TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithMultiRegion
=== PAUSE TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithMultiRegion
=== RUN   TestAccNetworkManagerCoreNetwork_withoutPolicyDocumentUpdateToCreateBasePolicyDocument
=== PAUSE TestAccNetworkManagerCoreNetwork_withoutPolicyDocumentUpdateToCreateBasePolicyDocument
=== CONT  TestAccNetworkManagerCoreNetworkPolicyAttachment_basic
=== CONT  TestAccNetworkManagerCoreNetwork_tags
=== CONT  TestAccNetworkManagerCoreNetworkPolicyDocumentDataSource_basic
=== CONT  TestAccNetworkManagerCoreNetwork_disappears
=== CONT  TestAccNetworkManagerCoreNetworkPolicyAttachment_vpcAttachmentMultiRegion
=== CONT  TestAccNetworkManagerCoreNetworkPolicyAttachment_expectPolicyErrorInvalidASNRange
=== CONT  TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithRegion
=== CONT  TestAccNetworkManagerCoreNetwork_withoutPolicyDocumentUpdateToCreateBasePolicyDocument
=== CONT  TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithoutRegion
=== CONT  TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithMultiRegion
=== CONT  TestAccNetworkManagerCoreNetwork_policyDocument
=== CONT  TestAccNetworkManagerCoreNetwork_basic
=== CONT  TestAccNetworkManagerCoreNetwork_description
=== CONT  TestAccNetworkManagerCoreNetworkPolicyAttachment_vpcAttachment
--- PASS: TestAccNetworkManagerCoreNetworkPolicyDocumentDataSource_basic (29.47s)
--- PASS: TestAccNetworkManagerCoreNetworkPolicyAttachment_expectPolicyErrorInvalidASNRange (58.66s)
--- PASS: TestAccNetworkManagerCoreNetwork_basic (69.61s)
--- PASS: TestAccNetworkManagerCoreNetwork_disappears (75.73s)
--- PASS: TestAccNetworkManagerCoreNetwork_tags (87.07s)
--- PASS: TestAccNetworkManagerCoreNetwork_description (90.99s)
--- PASS: TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithRegion (551.62s)
--- PASS: TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithoutRegion (560.44s)
--- PASS: TestAccNetworkManagerCoreNetwork_withoutPolicyDocumentUpdateToCreateBasePolicyDocument (571.07s)
--- PASS: TestAccNetworkManagerCoreNetworkPolicyAttachment_basic (710.74s)
--- PASS: TestAccNetworkManagerCoreNetwork_policyDocument (819.73s)
--- PASS: TestAccNetworkManagerCoreNetworkPolicyAttachment_vpcAttachment (1238.58s)
--- PASS: TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithMultiRegion (1511.70s)
--- PASS: TestAccNetworkManagerCoreNetworkPolicyAttachment_vpcAttachmentMultiRegion (2130.35s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/networkmanager     2130.479s

...

@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/M Managed by automation to categorize the size of a PR. service/networkmanager Issues and PRs that pertain to the networkmanager service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. partner Contribution from a partner. needs-triage Waiting for first response or review from a maintainer. labels Apr 22, 2023
@GlennChia GlennChia force-pushed the f-aws_networkmanager_core_network_policy-enhancements branch from 59ac7ff to e620b93 Compare April 22, 2023 16:27
@GlennChia GlennChia force-pushed the f-aws_networkmanager_core_network_policy-enhancements branch from e620b93 to cd63ec9 Compare April 22, 2023 16:43
@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Apr 24, 2023
@ewbankkit ewbankkit self-assigned this Apr 24, 2023
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

% make testacc TESTARGS='-run=TestAccNetworkManagerCoreNetwork_' PKG=networkmanager ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/networkmanager/... -v -count 1 -parallel 2  -run=TestAccNetworkManagerCoreNetwork_ -timeout 180m
=== RUN   TestAccNetworkManagerCoreNetwork_basic
=== PAUSE TestAccNetworkManagerCoreNetwork_basic
=== RUN   TestAccNetworkManagerCoreNetwork_disappears
=== PAUSE TestAccNetworkManagerCoreNetwork_disappears
=== RUN   TestAccNetworkManagerCoreNetwork_tags
=== PAUSE TestAccNetworkManagerCoreNetwork_tags
=== RUN   TestAccNetworkManagerCoreNetwork_description
=== PAUSE TestAccNetworkManagerCoreNetwork_description
=== RUN   TestAccNetworkManagerCoreNetwork_policyDocument
=== PAUSE TestAccNetworkManagerCoreNetwork_policyDocument
=== RUN   TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithoutRegion
=== PAUSE TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithoutRegion
=== RUN   TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithRegion
=== PAUSE TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithRegion
=== RUN   TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithMultiRegion
=== PAUSE TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithMultiRegion
=== RUN   TestAccNetworkManagerCoreNetwork_withoutPolicyDocumentUpdateToCreateBasePolicyDocument
=== PAUSE TestAccNetworkManagerCoreNetwork_withoutPolicyDocumentUpdateToCreateBasePolicyDocument
=== CONT  TestAccNetworkManagerCoreNetwork_basic
=== CONT  TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithoutRegion
--- PASS: TestAccNetworkManagerCoreNetwork_basic (47.72s)
=== CONT  TestAccNetworkManagerCoreNetwork_description
--- PASS: TestAccNetworkManagerCoreNetwork_description (69.92s)
=== CONT  TestAccNetworkManagerCoreNetwork_policyDocument
--- PASS: TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithoutRegion (483.35s)
=== CONT  TestAccNetworkManagerCoreNetwork_tags
--- PASS: TestAccNetworkManagerCoreNetwork_tags (79.78s)
=== CONT  TestAccNetworkManagerCoreNetwork_disappears
--- PASS: TestAccNetworkManagerCoreNetwork_disappears (42.23s)
=== CONT  TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithMultiRegion
--- PASS: TestAccNetworkManagerCoreNetwork_policyDocument (637.44s)
=== CONT  TestAccNetworkManagerCoreNetwork_withoutPolicyDocumentUpdateToCreateBasePolicyDocument
--- PASS: TestAccNetworkManagerCoreNetwork_withoutPolicyDocumentUpdateToCreateBasePolicyDocument (526.78s)
=== CONT  TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithRegion
--- PASS: TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithRegion (423.43s)
--- PASS: TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithMultiRegion (1382.64s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/networkmanager	1993.449s

@ewbankkit
Copy link
Contributor

@GlennChia Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit 2ec33c7 into hashicorp:main Apr 24, 2023
@github-actions github-actions bot added this to the v4.65.0 milestone Apr 24, 2023
@github-actions
Copy link

This functionality has been released in v4.65.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
partner Contribution from a partner. service/networkmanager Issues and PRs that pertain to the networkmanager service. size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants