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 read after creation for 404 status code #11894

Merged
merged 1 commit into from
Feb 5, 2020

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Feb 4, 2020

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 #11891

Release note for CHANGELOG:

* resource/aws_s3_bucket: Retry read after creation for 404 status code and prevent 2 minute delay for triggering recreation on existing resources deleted outside Terraform

Previously in the acceptance testing (inconsistently across various testing due to eventual consistency):

--- FAIL: TestAccAWSAthenaNamedQuery_basic (3.56s)
    testing.go:640: Step 0 error: errors during apply:

        Error: Provider produced inconsistent result after apply

        When applying changes to aws_s3_bucket.test, provider "aws" produced an
        unexpected new value for was present, but now absent.

        This is a bug in the provider, which should be reported in the provider's own
        issue tracker.

--- FAIL: TestAccAWSCodeBuildProject_Environment_Certificate (7.72s)
    testing.go:640: Step 0 error: errors during apply:

        Error: Provider produced inconsistent result after apply

        When applying changes to aws_s3_bucket.test, provider "aws" produced an
        unexpected new value for was present, but now absent.

        This is a bug in the provider, which should be reported in the provider's own
        issue tracker.

The HeadBucket/HeadObject S3 APIs work differently than other AWS APIs where they can exclusively return only status code information and not a relevant error code. This update accounts for that discrepency by retrying on 404 status codes on the resource read immediately after bucket creation.

Output from acceptance testing (failures from other eventual consistency issues):

--- PASS: TestAccAWSS3Bucket_shouldFailNotFound (18.57s)
--- PASS: TestAccAWSS3Bucket_Cors_Delete (31.55s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithEmptyPrefixes (33.16s)
--- PASS: TestAccAWSS3Bucket_forceDestroy (34.90s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithObjectLockEnabled (36.16s)
--- PASS: TestAccAWSS3Bucket_basic (36.41s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenAES256IsUsed (36.72s)
--- PASS: TestAccAWSS3Bucket_Cors_EmptyOrigin (37.42s)
--- PASS: TestAccAWSS3Bucket_ReplicationExpectVersioningValidationError (39.28s)
--- PASS: TestAccAWSS3Bucket_objectLock (62.84s)
--- FAIL: TestAccAWSS3Bucket_Cors_Update (70.43s)
    testing.go:640: Step 2 error: After applying this step, the plan was not empty:
--- PASS: TestAccAWSS3Bucket_namePrefix (34.06s)
--- PASS: TestAccAWSS3Bucket_ReplicationWithoutStorageClass (74.89s)
--- PASS: TestAccAWSS3Bucket_Logging (75.40s)
--- PASS: TestAccAWSS3Bucket_ReplicationWithoutPrefix (77.09s)
--- PASS: TestAccAWSS3Bucket_disableDefaultEncryption_whenDefaultEncryptionIsEnabled (59.98s)
--- PASS: TestAccAWSS3Bucket_LifecycleExpireMarkerOnly (80.69s)
--- FAIL: TestAccAWSS3Bucket_RequestPayer (50.88s)
    testing.go:640: Step 2 error: Check failed: Check 2/3 error: aws_s3_bucket.bucket: Attribute 'request_payer' expected "Requester", got "BucketOwner"
--- FAIL: TestAccAWSS3Bucket_acceleration (21.28s)
    testing.go:640: Step 0 error: Check failed: Check 2/2 error: aws_s3_bucket.bucket: Attribute 'acceleration_status' expected "Enabled", got ""
--- FAIL: TestAccAWSS3Bucket_LifecycleBasic (86.20s)
    testing.go:640: Step 3 error: After applying this step and refreshing, the plan was not empty:
--- PASS: TestAccAWSS3Bucket_WebsiteRoutingRules (60.54s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenTypical (62.41s)
--- PASS: TestAccAWSS3Bucket_UpdateAcl (61.70s)
--- PASS: TestAccAWSS3Bucket_region (30.65s)
--- PASS: TestAccAWSS3Bucket_Versioning (105.29s)
--- PASS: TestAccAWSS3Bucket_generatedName (35.22s)
--- PASS: TestAccAWSS3Bucket_Bucket_EmptyString (34.39s)
--- PASS: TestAccAWSS3Bucket_Policy (76.26s)
--- PASS: TestAccAWSS3Bucket_WebsiteRedirect (83.43s)
--- PASS: TestAccAWSS3Bucket_Website_Simple (83.85s)
--- PASS: TestAccAWSS3Bucket_ReplicationConfiguration_Rule_Destination_AccessControlTranslation (149.59s)
--- PASS: TestAccAWSS3Bucket_tagsWithNoSystemTags (112.51s)
--- PASS: TestAccAWSS3Bucket_ReplicationSchemaV2 (234.41s)
--- PASS: TestAccAWSS3Bucket_Replication (242.83s)
--- PASS: TestAccAWSS3Bucket_tagsWithSystemTags (182.05s)

Re-run of failed tests:

--- PASS: TestAccAWSS3Bucket_RequestPayer (59.87s)
--- PASS: TestAccAWSS3Bucket_Cors_Update (61.90s)
--- PASS: TestAccAWSS3Bucket_acceleration (62.81s)
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (89.19s)

Reference: #11891

Previously in the acceptance testing (inconsistently across various testing due to eventual consistency):

```
--- FAIL: TestAccAWSAthenaNamedQuery_basic (3.56s)
    testing.go:640: Step 0 error: errors during apply:

        Error: Provider produced inconsistent result after apply

        When applying changes to aws_s3_bucket.test, provider "aws" produced an
        unexpected new value for was present, but now absent.

        This is a bug in the provider, which should be reported in the provider's own
        issue tracker.

--- FAIL: TestAccAWSCodeBuildProject_Environment_Certificate (7.72s)
    testing.go:640: Step 0 error: errors during apply:

        Error: Provider produced inconsistent result after apply

        When applying changes to aws_s3_bucket.test, provider "aws" produced an
        unexpected new value for was present, but now absent.

        This is a bug in the provider, which should be reported in the provider's own
        issue tracker.
```

The HeadBucket/HeadObject S3 APIs work differently than other AWS APIs where they can exclusively return only status code information and not a relevant error code. This update accounts for that discrepency by retrying on 404 status codes on the resource read immediately after bucket creation.

Output from acceptance testing (failures from other eventual consistency issues):

```
--- PASS: TestAccAWSS3Bucket_shouldFailNotFound (18.57s)
--- PASS: TestAccAWSS3Bucket_Cors_Delete (31.55s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithEmptyPrefixes (33.16s)
--- PASS: TestAccAWSS3Bucket_forceDestroy (34.90s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithObjectLockEnabled (36.16s)
--- PASS: TestAccAWSS3Bucket_basic (36.41s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenAES256IsUsed (36.72s)
--- PASS: TestAccAWSS3Bucket_Cors_EmptyOrigin (37.42s)
--- PASS: TestAccAWSS3Bucket_ReplicationExpectVersioningValidationError (39.28s)
--- PASS: TestAccAWSS3Bucket_objectLock (62.84s)
--- FAIL: TestAccAWSS3Bucket_Cors_Update (70.43s)
    testing.go:640: Step 2 error: After applying this step, the plan was not empty:
--- PASS: TestAccAWSS3Bucket_namePrefix (34.06s)
--- PASS: TestAccAWSS3Bucket_ReplicationWithoutStorageClass (74.89s)
--- PASS: TestAccAWSS3Bucket_Logging (75.40s)
--- PASS: TestAccAWSS3Bucket_ReplicationWithoutPrefix (77.09s)
--- PASS: TestAccAWSS3Bucket_disableDefaultEncryption_whenDefaultEncryptionIsEnabled (59.98s)
--- PASS: TestAccAWSS3Bucket_LifecycleExpireMarkerOnly (80.69s)
--- FAIL: TestAccAWSS3Bucket_RequestPayer (50.88s)
    testing.go:640: Step 2 error: Check failed: Check 2/3 error: aws_s3_bucket.bucket: Attribute 'request_payer' expected "Requester", got "BucketOwner"
--- FAIL: TestAccAWSS3Bucket_acceleration (21.28s)
    testing.go:640: Step 0 error: Check failed: Check 2/2 error: aws_s3_bucket.bucket: Attribute 'acceleration_status' expected "Enabled", got ""
--- FAIL: TestAccAWSS3Bucket_LifecycleBasic (86.20s)
    testing.go:640: Step 3 error: After applying this step and refreshing, the plan was not empty:
--- PASS: TestAccAWSS3Bucket_WebsiteRoutingRules (60.54s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenTypical (62.41s)
--- PASS: TestAccAWSS3Bucket_UpdateAcl (61.70s)
--- PASS: TestAccAWSS3Bucket_region (30.65s)
--- PASS: TestAccAWSS3Bucket_Versioning (105.29s)
--- PASS: TestAccAWSS3Bucket_generatedName (35.22s)
--- PASS: TestAccAWSS3Bucket_Bucket_EmptyString (34.39s)
--- PASS: TestAccAWSS3Bucket_Policy (76.26s)
--- PASS: TestAccAWSS3Bucket_WebsiteRedirect (83.43s)
--- PASS: TestAccAWSS3Bucket_Website_Simple (83.85s)
--- PASS: TestAccAWSS3Bucket_ReplicationConfiguration_Rule_Destination_AccessControlTranslation (149.59s)
--- PASS: TestAccAWSS3Bucket_tagsWithNoSystemTags (112.51s)
--- PASS: TestAccAWSS3Bucket_ReplicationSchemaV2 (234.41s)
--- PASS: TestAccAWSS3Bucket_Replication (242.83s)
--- PASS: TestAccAWSS3Bucket_tagsWithSystemTags (182.05s)
```

Re-run of failed tests:

```
--- PASS: TestAccAWSS3Bucket_RequestPayer (59.87s)
--- PASS: TestAccAWSS3Bucket_Cors_Update (61.90s)
--- PASS: TestAccAWSS3Bucket_acceleration (62.81s)
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (89.19s)
```
@bflad bflad added the bug Addresses a defect in current functionality. label Feb 4, 2020
@bflad bflad requested a review from a team February 4, 2020 20:58
@ghost ghost added size/S Managed by automation to categorize the size of a PR. needs-triage Waiting for first response or review from a maintainer. provider Pertains to the provider itself, rather than any interaction with AWS. service/s3 Issues and PRs that pertain to the s3 service. labels Feb 4, 2020
@bflad bflad removed the needs-triage Waiting for first response or review from a maintainer. label Feb 4, 2020
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 🚀

Output from acceptance testing:

--- PASS: TestAccAWSS3BucketObject_noNameNoKey (6.83s)
--- FAIL: TestAccAWSS3BucketNotification_Queue (16.72s)
--- PASS: TestAccAWSS3BucketObject_empty (20.85s)
--- PASS: TestAccAWSS3BucketMetric_WithEmptyFilter (21.29s)
--- PASS: TestAccAWSS3BucketObject_source (21.74s)
--- PASS: TestAccAWSS3BucketObject_content (21.93s)
--- PASS: TestAccAWSS3BucketInventory_basic (22.46s)
--- PASS: TestAccAWSS3BucketMetric_basic (22.48s)
--- PASS: TestAccAWSS3BucketInventory_encryptWithSSES3 (22.48s)
--- PASS: TestAccAWSS3BucketNotification_Topic (23.36s)
--- PASS: TestAccAWSS3BucketObject_etagEncryption (18.10s)
--- PASS: TestAccAWSS3BucketNotification_Topic_Multiple (25.69s)
--- PASS: TestAccAWSS3BucketMetric_WithFilterPrefixAndMultipleTags (32.60s)
--- PASS: TestAccAWSS3BucketMetric_WithFilterPrefix (34.17s)
--- PASS: TestAccAWSS3BucketMetric_WithFilterSingleTag (34.32s)
--- PASS: TestAccAWSS3BucketMetric_WithFilterMultipleTags (34.30s)
--- PASS: TestAccAWSS3BucketMetric_WithFilterPrefixAndSingleTag (34.45s)
--- PASS: TestAccAWSS3BucketNotification_update (36.18s)
--- PASS: TestAccAWSS3BucketObject_contentBase64 (19.60s)
--- PASS: TestAccAWSS3BucketObject_withContentCharacteristics (16.75s)
--- PASS: TestAccAWSS3BucketObject_NonVersioned (18.22s)
--- PASS: TestAccAWSS3BucketInventory_encryptWithSSEKMS (40.49s)
--- PASS: TestAccAWSS3BucketObject_sse (21.18s)
--- PASS: TestAccAWSS3BucketNotification_LambdaFunction (45.33s)
--- PASS: TestAccAWSS3BucketNotification_LambdaFunction_LambdaFunctionArn_Alias (46.17s)
--- PASS: TestAccAWSS3BucketObject_updateSameFile (31.16s)
--- PASS: TestAccAWSS3BucketObject_updates (33.59s)
--- PASS: TestAccAWSS3BucketObject_updatesWithVersioning (33.23s)
--- PASS: TestAccAWSS3BucketPublicAccessBlock_bucketDisappears (16.76s)
--- PASS: TestAccAWSS3BucketObject_kms (39.17s)
--- PASS: TestAccAWSS3BucketPublicAccessBlock_disappears (22.34s)
--- PASS: TestAccAWSS3BucketPolicy_basic (26.47s)
--- PASS: TestAccAWSS3BucketPublicAccessBlock_basic (24.51s)
--- PASS: TestAccAWSS3BucketObject_ObjectLockLegalHoldStartWithOn (33.71s)
--- PASS: TestAccAWSS3BucketObject_acl (46.34s)
--- PASS: TestAccAWSS3BucketObject_metadata (48.04s)
--- PASS: TestAccAWSS3BucketPolicy_policyUpdate (38.40s)
--- PASS: TestAccAWSS3BucketObject_ObjectLockLegalHoldStartWithNone (44.35s)
--- PASS: TestAccAWSS3Bucket_basic (24.09s)
--- PASS: TestAccAWSS3Bucket_Bucket_EmptyString (21.05s)
--- PASS: TestAccAWSS3BucketObject_ObjectLockRetentionStartWithNone (48.40s)
--- PASS: TestAccAWSS3Bucket_namePrefix (22.25s)
--- PASS: TestAccAWSS3BucketObject_tags (59.05s)
--- PASS: TestAccAWSS3Bucket_generatedName (23.51s)
--- PASS: TestAccAWSS3MultiBucket_withTags (28.75s)
--- PASS: TestAccAWSS3BucketObject_storageClass (67.72s)
--- PASS: TestAccAWSS3BucketObject_tagsLeadingSlash (60.87s)
--- PASS: TestAccAWSS3BucketPublicAccessBlock_BlockPublicAcls (50.10s)
--- PASS: TestAccAWSS3BucketPublicAccessBlock_BlockPublicPolicy (49.64s)
--- PASS: TestAccAWSS3BucketObject_ObjectLockRetentionStartWithSet (61.29s)
--- PASS: TestAccAWSS3BucketPublicAccessBlock_IgnorePublicAcls (47.13s)
--- PASS: TestAccAWSS3BucketPublicAccessBlock_RestrictPublicBuckets (48.85s)
--- PASS: TestAccAWSS3Bucket_shouldFailNotFound (16.46s)
--- PASS: TestAccAWSS3Bucket_RequestPayer (33.57s)
--- PASS: TestAccAWSS3Bucket_UpdateAcl (33.56s)
--- PASS: TestAccAWSS3Bucket_acceleration (40.15s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenAES256IsUsed (22.26s)
--- PASS: TestAccAWSS3Bucket_Cors_Delete (19.94s)
--- PASS: TestAccAWSS3Bucket_Cors_EmptyOrigin (23.96s)
--- PASS: TestAccAWSS3Bucket_WebsiteRoutingRules (36.77s)
--- PASS: TestAccAWSS3Bucket_region (54.71s)
--- PASS: TestAccAWSS3Bucket_Policy (45.99s)
--- PASS: TestAccAWSS3Bucket_Logging (25.35s)
--- PASS: TestAccAWSS3Bucket_tagsWithNoSystemTags (64.28s)
--- PASS: TestAWSS3BucketName (0.01s)
--- PASS: TestBucketRegionalDomainName (0.00s)
--- PASS: TestAccAWSS3Bucket_disableDefaultEncryption_whenDefaultEncryptionIsEnabled (35.55s)
--- PASS: TestAccAWSS3Bucket_Cors_Update (34.02s)
--- PASS: TestAccAWSS3Bucket_WebsiteRedirect (48.28s)
--- PASS: TestAccAWSS3Bucket_Website_Simple (49.69s)
--- FAIL: TestAccAWSS3Bucket_LifecycleBasic (29.86s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenTypical (44.14s)
--- PASS: TestAccAWSS3Bucket_forceDestroy (13.86s)
--- PASS: TestAccAWSS3Bucket_Versioning (43.84s)
--- PASS: TestAccAWSS3Bucket_LifecycleExpireMarkerOnly (29.25s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithEmptyPrefixes (14.21s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithObjectLockEnabled (13.78s)
--- PASS: TestAccAWSS3Bucket_objectLock (22.69s)
--- FAIL: TestAccAWSS3Bucket_ReplicationExpectVersioningValidationError (38.06s)
--- PASS: TestAccAWSS3Bucket_tagsWithSystemTags (93.72s)
--- PASS: TestAccAWSS3Bucket_ReplicationWithoutStorageClass (60.15s)
--- PASS: TestAccAWSS3Bucket_ReplicationWithoutPrefix (61.69s)
--- PASS: TestAccAWSS3Bucket_ReplicationConfiguration_Rule_Destination_AccessControlTranslation (122.71s)
--- PASS: TestAccAWSS3Bucket_ReplicationSchemaV2 (154.76s)
--- PASS: TestAccAWSS3Bucket_Replication (181.75s)

Re-run of failed tests:

--- PASS: TestAccAWSS3Bucket_ReplicationExpectVersioningValidationError (54.07s)
--- PASS: TestAccAWSS3BucketNotification_Queue (31.31s)
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (62.55s)

@bflad bflad added this to the v2.48.0 milestone Feb 5, 2020
@bflad bflad merged commit ba169a4 into master Feb 5, 2020
@bflad bflad deleted the b-aws_s3_bucket-HeadBucket-404 branch February 5, 2020 21:13
bflad added a commit that referenced this pull request Feb 5, 2020
@ghost
Copy link

ghost commented Feb 7, 2020

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

@ghost
Copy link

ghost commented Mar 27, 2020

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 Mar 27, 2020
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. provider Pertains to the provider itself, rather than any interaction with AWS. service/s3 Issues and PRs that pertain to the s3 service. size/S Managed by automation to categorize the size of a PR.
Projects
None yet
2 participants