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

resource/aws_ram: Fix eventual consistency problems #17032

Merged
merged 10 commits into from
Apr 29, 2021

Conversation

shuheiktgw
Copy link
Collaborator

@shuheiktgw shuheiktgw commented Jan 9, 2021

Community Note

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

Closes #13494
Closes #15187
Closes #16578
Closes #17658
Closes #18332

Release note for CHANGELOG:

* resource/aws_ram_resource_share_accepter: Fix eventual consistency problems

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAwsRamResourceShareAccepter_*'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAwsRamResourceShareAccepter_* -timeout 120m
=== RUN   TestAccAwsRamResourceShareAccepter_basic
=== PAUSE TestAccAwsRamResourceShareAccepter_basic
=== CONT  TestAccAwsRamResourceShareAccepter_basic
--- PASS: TestAccAwsRamResourceShareAccepter_basic (79.33s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	81.162s

$ make testacc TESTARGS='-run=TestAccAwsRamResourceShare_*'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAwsRamResourceShare_* -timeout 120m
=== RUN   TestAccAwsRamResourceShareAccepter_basic
=== PAUSE TestAccAwsRamResourceShareAccepter_basic
=== RUN   TestAccAwsRamResourceShare_basic
=== PAUSE TestAccAwsRamResourceShare_basic
=== RUN   TestAccAwsRamResourceShare_AllowExternalPrincipals
=== PAUSE TestAccAwsRamResourceShare_AllowExternalPrincipals
=== RUN   TestAccAwsRamResourceShare_Name
=== PAUSE TestAccAwsRamResourceShare_Name
=== RUN   TestAccAwsRamResourceShare_Tags
=== PAUSE TestAccAwsRamResourceShare_Tags
=== CONT  TestAccAwsRamResourceShareAccepter_basic
=== CONT  TestAccAwsRamResourceShare_Name
=== CONT  TestAccAwsRamResourceShare_AllowExternalPrincipals
=== CONT  TestAccAwsRamResourceShare_Tags
=== CONT  TestAccAwsRamResourceShare_basic
--- PASS: TestAccAwsRamResourceShare_basic (42.74s)
--- PASS: TestAccAwsRamResourceShare_Name (69.01s)
--- PASS: TestAccAwsRamResourceShare_AllowExternalPrincipals (69.10s)
--- PASS: TestAccAwsRamResourceShareAccepter_basic (90.10s)
--- PASS: TestAccAwsRamResourceShare_Tags (92.77s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	94.688s

Thank you for your review! 👍

@shuheiktgw shuheiktgw requested a review from a team as a code owner January 9, 2021 00:00
@ghost ghost added size/M Managed by automation to categorize the size of a PR. service/ram Issues and PRs that pertain to the ram service. labels Jan 9, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jan 9, 2021
@shuheiktgw shuheiktgw force-pushed the fix_ram_resource_share_accepter branch 2 times, most recently from 1035942 to db54722 Compare January 9, 2021 00:22
Comment on lines 236 to 237
i, err := findResourceShareInvitation(conn, resourceShareARN, status)
invitation = i
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a golang expert, but is there a reason i is used here and then immediately assigned to invitation instead of just using invitation, err := ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, actually you cannot substitute the returned output for the outer invitation using :=...

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, TIL. Thanks!

@shuheiktgw shuheiktgw force-pushed the fix_ram_resource_share_accepter branch from db54722 to 19293a7 Compare January 17, 2021 04:08
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Jan 17, 2021
@shuheiktgw shuheiktgw force-pushed the fix_ram_resource_share_accepter branch from 19293a7 to fa70c5e Compare January 17, 2021 11:11
@pkleanthous
Copy link

Hey guys,

Can you please merge this PR?

Base automatically changed from master to main January 23, 2021 01:00
@datacenter-dylan
Copy link

Any estimate on when we can expect this to be merged?

@lorengordon
Copy link
Contributor

lorengordon commented Apr 21, 2021

This PR might also fix the race condition I reported here: #18332

@YakDriver YakDriver self-assigned this Apr 22, 2021
@lorengordon
Copy link
Contributor

@YakDriver I built the aws provider using this branch and can confirm it does appear to also address the race condition I reported in #18332 (and probably #17658 and #15187, as well as the two linked in the PR description #13494 and #16578). At least, I looped over 100 builds without encountering the failure...

@YakDriver YakDriver force-pushed the fix_ram_resource_share_accepter branch from fa70c5e to 559e521 Compare April 27, 2021 18:36
@ghost ghost added the tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. label Apr 28, 2021
@YakDriver YakDriver changed the title resource/aws_ram_resource_share_accepter: Fix eventual consistency problems resource/aws_ram: Fix eventual consistency problems Apr 28, 2021
@YakDriver
Copy link
Member

YakDriver commented Apr 28, 2021

@shuheiktgw My friend, thank you for this excellent PR. Unfortunately, I believe due to account settings changes on our side, I cannot currently test this properly. Rather than wait for us to straighten out our account problems, if you (and @lorengordon) can help test/fix my new changes, that would be very helpful! Make sure to pull my latest changes to your branch. Please let me know if you have any questions.

What I'm currently getting from the acceptance tests (GovCloud):

--- FAIL: TestAccAwsRamResourceAssociation_basic (18.17s)        // failure predates this PR (Hashi test account settings?)
--- FAIL: TestAccAwsRamResourceAssociation_disappears (17.97s)   // failure predates this PR (Hashi test account settings?)
--- FAIL: TestAccAwsRamResourceShareAccepter_basic (14.37s)      // failure predates this PR (Hashi test account settings?)
--- FAIL: TestAccAwsRamResourceShareAccepter_disappears (14.72s) // new test (Hashi test account settings?)
--- PASS: TestAccAwsRamPrincipalAssociation_basic (25.72s)
--- PASS: TestAccAwsRamPrincipalAssociation_disappears (22.62s)
--- PASS: TestAccAwsRamResourceShare_AllowExternalPrincipals (36.17s)
--- PASS: TestAccAwsRamResourceShare_basic (22.94s)
--- PASS: TestAccAwsRamResourceShare_Name (36.05s)
--- PASS: TestAccAwsRamResourceShare_Tags (48.68s)

Output from acceptance tests on commercial (us-west-2):

--- FAIL: TestAccAwsRamResourceAssociation_basic (15.42s)         // failure predates this PR (Hashi test account settings?)
--- FAIL: TestAccAwsRamResourceAssociation_disappears (15.35s)    // failure predates this PR (Hashi test account settings?)
--- FAIL: TestAccAwsRamResourceShareAccepter_basic (11.42s)       // failure predates this PR (Hashi test account settings?)
--- FAIL: TestAccAwsRamResourceShareAccepter_disappears (130.89s) // new test (Hashi test account settings?)
--- PASS: TestAccAwsRamPrincipalAssociation_basic (20.38s)
--- PASS: TestAccAwsRamPrincipalAssociation_disappears (14.36s)   // sometimes fails
--- PASS: TestAccAwsRamResourceShare_AllowExternalPrincipals (26.88s)
--- PASS: TestAccAwsRamResourceShare_basic (17.45s)
--- PASS: TestAccAwsRamResourceShare_Name (27.91s)
--- PASS: TestAccAwsRamResourceShare_Tags (35.73s)

@YakDriver YakDriver removed the needs-triage Waiting for first response or review from a maintainer. label Apr 28, 2021
@lorengordon
Copy link
Contributor

@YakDriver running my test now, the loop takes a long time, so probably will report back tomorrow.

@YakDriver YakDriver added this to the v3.38.0 milestone Apr 29, 2021
@YakDriver YakDriver merged commit 16e9af1 into hashicorp:main Apr 29, 2021
@ghost
Copy link

ghost commented Apr 30, 2021

This has been released in version 3.38.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 for triage. Thanks!

@lorengordon
Copy link
Contributor

fwiw, closing the loop, finally made it through my looped tests for the race condition. didn't encounter it even once in 100 executions of the test config, so 🤞 i'm pretty sure this is solid!

@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 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/ram Issues and PRs that pertain to the ram service. size/XL 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
6 participants