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_s3_bucket: Retry GetBucketTagging API calls on NoSuchBucket errors due to eventual consistency #10863

Merged
merged 1 commit into from
Nov 14, 2019

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Nov 14, 2019

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" comments, they generate extra noise for pull request followers and do not help prioritize the request

Closes #10068

Release note for CHANGELOG:

* resource/aws_s3_bucket: Retry `GetBucketTagging` API calls on `NoSuchBucket` errors due to eventual consistency

Previously, our acceptance testing would report eventual consistency issues such as:

--- FAIL: TestAccAWSS3Bucket_tagsWithSystemTags (11.28s)
    testing.go:615: Step 0 error: errors during apply:

        Error: error getting S3 bucket tags: NoSuchBucket: The specified bucket does not exist

--- FAIL: TestAccAWSCodeBuildProject_Artifacts_ArtifactIdentifier (7.39s)
    testing.go:615: Step 0 error: errors during apply:

        Error: error getting S3 bucket tags: NoSuchBucket: The specified bucket does not exist

The aws_s3_bucket resource tends to call our retryOnAwsCode() helper function to deal with this type of eventual consistency issue so we also add that handling to this API call as well.

Output from acceptance testing (after retrying any failing tests due to other read-after-write eventual consistency issues):

--- PASS: TestAccAWSS3Bucket_acceleration (57.29s)
--- PASS: TestAccAWSS3Bucket_basic (32.63s)
--- PASS: TestAccAWSS3Bucket_Bucket_EmptyString (30.76s)
--- PASS: TestAccAWSS3Bucket_Cors_Delete (29.45s)
--- PASS: TestAccAWSS3Bucket_Cors_EmptyOrigin (32.09s)
--- PASS: TestAccAWSS3Bucket_Cors_Update (55.25s)
--- PASS: TestAccAWSS3Bucket_disableDefaultEncryption_whenDefaultEncryptionIsEnabled (52.43s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenAES256IsUsed (30.94s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenTypical (61.25s)
--- PASS: TestAccAWSS3Bucket_forceDestroy (26.03s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithEmptyPrefixes (26.81s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithObjectLockEnabled (33.29s)
--- PASS: TestAccAWSS3Bucket_generatedName (31.31s)
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (78.75s)
--- PASS: TestAccAWSS3Bucket_LifecycleExpireMarkerOnly (52.02s)
--- PASS: TestAccAWSS3Bucket_Logging (49.71s)
--- PASS: TestAccAWSS3Bucket_namePrefix (30.67s)
--- PASS: TestAccAWSS3Bucket_objectLock (52.31s)
--- PASS: TestAccAWSS3Bucket_Policy (70.45s)
--- PASS: TestAccAWSS3Bucket_region (29.50s)
--- PASS: TestAccAWSS3Bucket_Replication (223.64s)
--- PASS: TestAccAWSS3Bucket_ReplicationConfiguration_Rule_Destination_AccessControlTranslation (141.38s)
--- PASS: TestAccAWSS3Bucket_ReplicationExpectVersioningValidationError (35.00s)
--- PASS: TestAccAWSS3Bucket_ReplicationSchemaV2 (231.22s)
--- PASS: TestAccAWSS3Bucket_ReplicationWithoutPrefix (67.87s)
--- PASS: TestAccAWSS3Bucket_RequestPayer (53.47s)
--- PASS: TestAccAWSS3Bucket_shouldFailNotFound (13.40s)
--- PASS: TestAccAWSS3Bucket_tagsWithNoSystemTags (94.76s)
--- PASS: TestAccAWSS3Bucket_tagsWithSystemTags (144.59s)
--- PASS: TestAccAWSS3Bucket_UpdateAcl (53.37s)
--- PASS: TestAccAWSS3Bucket_WebsiteRedirect (77.20s)
--- PASS: TestAccAWSS3Bucket_WebsiteRoutingRules (57.40s)

…ket errors due to eventual consistency

Reference: #10068

Previously, our acceptance testing would report eventual consistency issues such as:

```
--- FAIL: TestAccAWSS3Bucket_tagsWithSystemTags (11.28s)
    testing.go:615: Step 0 error: errors during apply:

        Error: error getting S3 bucket tags: NoSuchBucket: The specified bucket does not exist

--- FAIL: TestAccAWSCodeBuildProject_Artifacts_ArtifactIdentifier (7.39s)
    testing.go:615: Step 0 error: errors during apply:

        Error: error getting S3 bucket tags: NoSuchBucket: The specified bucket does not exist
```

The `aws_s3_bucket` resource tends to call our `retryOnAwsCode()` helper function to deal with this type of eventual consistency issue so we also add that handling to this API call as well.

Output from acceptance testing (after retrying any failing tests due to other read-after-write eventual consistency issues):

```
--- PASS: TestAccAWSS3Bucket_acceleration (57.29s)
--- PASS: TestAccAWSS3Bucket_basic (32.63s)
--- PASS: TestAccAWSS3Bucket_Bucket_EmptyString (30.76s)
--- PASS: TestAccAWSS3Bucket_Cors_Delete (29.45s)
--- PASS: TestAccAWSS3Bucket_Cors_EmptyOrigin (32.09s)
--- PASS: TestAccAWSS3Bucket_Cors_Update (55.25s)
--- PASS: TestAccAWSS3Bucket_disableDefaultEncryption_whenDefaultEncryptionIsEnabled (52.43s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenAES256IsUsed (30.94s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenTypical (61.25s)
--- PASS: TestAccAWSS3Bucket_forceDestroy (26.03s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithEmptyPrefixes (26.81s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithObjectLockEnabled (33.29s)
--- PASS: TestAccAWSS3Bucket_generatedName (31.31s)
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (78.75s)
--- PASS: TestAccAWSS3Bucket_LifecycleExpireMarkerOnly (52.02s)
--- PASS: TestAccAWSS3Bucket_Logging (49.71s)
--- PASS: TestAccAWSS3Bucket_namePrefix (30.67s)
--- PASS: TestAccAWSS3Bucket_objectLock (52.31s)
--- PASS: TestAccAWSS3Bucket_Policy (70.45s)
--- PASS: TestAccAWSS3Bucket_region (29.50s)
--- PASS: TestAccAWSS3Bucket_Replication (223.64s)
--- PASS: TestAccAWSS3Bucket_ReplicationConfiguration_Rule_Destination_AccessControlTranslation (141.38s)
--- PASS: TestAccAWSS3Bucket_ReplicationExpectVersioningValidationError (35.00s)
--- PASS: TestAccAWSS3Bucket_ReplicationSchemaV2 (231.22s)
--- PASS: TestAccAWSS3Bucket_ReplicationWithoutPrefix (67.87s)
--- PASS: TestAccAWSS3Bucket_RequestPayer (53.47s)
--- PASS: TestAccAWSS3Bucket_shouldFailNotFound (13.40s)
--- PASS: TestAccAWSS3Bucket_tagsWithNoSystemTags (94.76s)
--- PASS: TestAccAWSS3Bucket_tagsWithSystemTags (144.59s)
--- PASS: TestAccAWSS3Bucket_UpdateAcl (53.37s)
--- PASS: TestAccAWSS3Bucket_WebsiteRedirect (77.20s)
--- PASS: TestAccAWSS3Bucket_WebsiteRoutingRules (57.40s)
```
@bflad bflad added the bug Addresses a defect in current functionality. label Nov 14, 2019
@bflad bflad requested a review from a team November 14, 2019 00:34
@ghost ghost added needs-triage Waiting for first response or review from a maintainer. size/XS Managed by automation to categorize the size of a PR. labels Nov 14, 2019
@bflad bflad added service/s3 Issues and PRs that pertain to the s3 service. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 14, 2019
Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@gdavison gdavison merged commit 476cf77 into master Nov 14, 2019
@bflad bflad added this to the v2.36.0 milestone Nov 14, 2019
@gdavison gdavison deleted the b-aws_s3_bucket-retry-GetBucketTagging branch November 14, 2019 01:27
gdavison added a commit that referenced this pull request Nov 14, 2019
@ghost
Copy link

ghost commented Nov 14, 2019

This has been released in version 2.36.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!

wking added a commit to wking/openshift-installer that referenced this pull request Nov 15, 2019
Also bump the AWS SDK to the latest 1.25.35.  Changelogs in [1,2].
Among other things, this brings in a fix for the eventual-consistency
race [3,4]:

  level=error msg="Error: \"terraform-20191008145747927600000001\": NoSuchBucket: The specified bucket does not exist"
  level=error msg="\tstatus code: 404, request id: BCC3822AF0933B5C, host id: QVhV5kSr/ztRk3204PNQoVKN6jT7LY0Pk2vJHEKBdG5W4Eok9T+JmZXj8M/1XtBDP5fYEC4HcOI="
  level=error
  level=error msg="  on ../tmp/openshift-install-302978166/bootstrap/main.tf line 1, in resource \"aws_s3_bucket\" \"ignition\":"
  level=error msg="   1: resource \"aws_s3_bucket\" \"ignition\" {"

Generated with:

  $ cd pkg/terraform/exec/plugins
  $ emacs Gopkg.toml  # terraform-provider-aws -> =2.36.0
  $ dep ensure
  Solving failure: No versions of github.com/aws/aws-sdk-go met constraints:
    v1.19.26: Could not introduce github.com/aws/aws-sdk-go@v1.19.26 due to multiple problematic subpackages:
    Subpackage github.com/aws/aws-sdk-go/service/applicationinsights is missing. (Package is required by github.com/terraform-providers/terraform-provider-aws@v2.36.0.)Subpackage github.com/aws/aws-sdk-go/service/forecastservice is missing. (Package is required by github.com/terraform-providers/terraform-provider-aws@v2.36.0.)Subpackage github.com/aws/aws-sdk-go/service/iotevents is missing. (Package is required by github.com/terraform-providers/terraform-provider-aws@v2.36.0.)Subpackage github.com/aws/aws-sdk-go/service/lakeformation is missing. (Package is required by github.com/terraform-providers/terraform-provider-aws@v2.36.0.)Subpackage github.com/aws/aws-sdk-go/service/personalize is missing. (Package is required by github.com/terraform-providers/terraform-provider-aws@v2.36.0.)Subpackage github.com/aws/aws-sdk-go/service/qldb is missing. (Package is required by github.com/terraform-providers/terraform-provider-aws@v2.36.0.)Subpackage github.com/aws/aws-sdk-go/service/servicequotas is missing. (Package is required by github.com/terraform-providers/terraform-provider-aws@v2.36.0.)
    ...
  $ emacs Gopkg.toml  # aws-sdk-go -> =1.25.35, the latest per https://github.com/aws/aws-sdk-go/tags https://github.com/aws/aws-sdk-go/blob/v1.25.35/CHANGELOG.md
  $ dep ensure

[1]: https://github.com/terraform-providers/terraform-provider-aws/blob/v2.36.0/CHANGELOG.md#2360-november-14-2019
[2]: https://github.com/aws/aws-sdk-go/blob/v1.25.35/CHANGELOG.md
[3]: https://bugzilla.redhat.com/show_bug.cgi?id=1759617#c10
[4]: hashicorp/terraform-provider-aws#10863 (comment)
wking added a commit to wking/openshift-installer that referenced this pull request Nov 15, 2019
Also bump the AWS SDK to the latest 1.25.35.  Changelogs in [1,2].
Among other things, this brings in a fix for the eventual-consistency
race [3,4]:

  level=error msg="Error: \"terraform-20191008145747927600000001\": NoSuchBucket: The specified bucket does not exist"
  level=error msg="\tstatus code: 404, request id: BCC3822AF0933B5C, host id: QVhV5kSr/ztRk3204PNQoVKN6jT7LY0Pk2vJHEKBdG5W4Eok9T+JmZXj8M/1XtBDP5fYEC4HcOI="
  level=error
  level=error msg="  on ../tmp/openshift-install-302978166/bootstrap/main.tf line 1, in resource \"aws_s3_bucket\" \"ignition\":"
  level=error msg="   1: resource \"aws_s3_bucket\" \"ignition\" {"

Generated with:

  $ cd pkg/terraform/exec/plugins
  $ emacs Gopkg.toml  # terraform-provider-aws -> =2.36.0
  $ dep ensure
  Solving failure: No versions of github.com/aws/aws-sdk-go met constraints:
    v1.19.26: Could not introduce github.com/aws/aws-sdk-go@v1.19.26 due to multiple problematic subpackages:
    Subpackage github.com/aws/aws-sdk-go/service/applicationinsights is missing. (Package is required by github.com/terraform-providers/terraform-provider-aws@v2.36.0.)Subpackage github.com/aws/aws-sdk-go/service/forecastservice is missing. (Package is required by github.com/terraform-providers/terraform-provider-aws@v2.36.0.)Subpackage github.com/aws/aws-sdk-go/service/iotevents is missing. (Package is required by github.com/terraform-providers/terraform-provider-aws@v2.36.0.)Subpackage github.com/aws/aws-sdk-go/service/lakeformation is missing. (Package is required by github.com/terraform-providers/terraform-provider-aws@v2.36.0.)Subpackage github.com/aws/aws-sdk-go/service/personalize is missing. (Package is required by github.com/terraform-providers/terraform-provider-aws@v2.36.0.)Subpackage github.com/aws/aws-sdk-go/service/qldb is missing. (Package is required by github.com/terraform-providers/terraform-provider-aws@v2.36.0.)Subpackage github.com/aws/aws-sdk-go/service/servicequotas is missing. (Package is required by github.com/terraform-providers/terraform-provider-aws@v2.36.0.)
    ...
  $ emacs Gopkg.toml  # aws-sdk-go -> =1.25.35, the latest per https://github.com/aws/aws-sdk-go/tags https://github.com/aws/aws-sdk-go/blob/v1.25.35/CHANGELOG.md
  $ dep ensure

using:

  $ dep version
  dep:
   version     : v0.5.1
   build date  : 2019-03-20
   git hash    : faa61893
   go version  : go1.10.3
   go compiler : gc
   platform    : linux/amd64
   features    : ImportDuringSolve=false

[1]: https://github.com/terraform-providers/terraform-provider-aws/blob/v2.36.0/CHANGELOG.md#2360-november-14-2019
[2]: https://github.com/aws/aws-sdk-go/blob/v1.25.35/CHANGELOG.md
[3]: https://bugzilla.redhat.com/show_bug.cgi?id=1759617#c10
[4]: hashicorp/terraform-provider-aws#10863 (comment)
@ghost
Copy link

ghost commented Dec 14, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Dec 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/s3 Issues and PRs that pertain to the s3 service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
2 participants