-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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 on GetBucketTagging 404 Errors #13009
resource/aws_s3_bucket: Retry on GetBucketTagging 404 Errors #13009
Conversation
@camlow325 Thanks for addressing this. @bflad What do you think? |
I would suggest hoisting the |
Looks like this may also close #12907 |
@camlow325 Changing to if err != nil {
var awsErr awserr.Error
if errors.As(err, &awsErr) && awsErr.Code() == code {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err) should do the trick. |
I think you can also remove |
c71ed14
to
d4d2d85
Compare
Thanks, @bflad and @ewbankkit. I updated the PR to use the |
This is to address the "NoSuchBucket: The specified bucket does not exist" error as explained in https://bugzilla.redhat.com/show_bug.cgi?id=1759617 and many other similar bugs. This bug has been "fixed" several times over the years, yet it continues to rear its ugly self. The ultimate problem is a race condition with S3 eventual consistency. As described in the bug above, the bucket does not yet exist when trying to reference tags. The openshift fork that this commit references, contains an upstream patch as described in hashicorp/terraform-provider-aws#13009 that should address this issue.
This is to address the "NoSuchBucket: The specified bucket does not exist" error as explained in https://bugzilla.redhat.com/show_bug.cgi?id=1759617 and many other similar bugs. This bug has been "fixed" several times over the years, yet it continues to rear its ugly self. The ultimate problem is a race condition with S3 eventual consistency. As described in the bug above, the bucket does not yet exist when trying to reference tags. The openshift fork that this commit references, contains an upstream patch as described in hashicorp/terraform-provider-aws#13009 that should address this issue.
Just curious if there's anything stopping this PR from being approved/merged? Since it's been sitting inactive for several months and may fix a couple of very annoying issues. |
References: * hashicorp#13008 The AWS S3 service has eventual consistency considerations. If a GetBucketTagging call is made to obtain tags just after an S3 bucket is first created, AWS may return an HTTP 404 (NotFound) error with a NoSuchBucket error code. A fix was added for this in hashicorp#12418. It appears that the NoSuchBucket errors are not retried with this fix, however. This commit adds some extra logic which ensures that the code from the awserr.Error instance is evaluated for retry. Output for acceptance testing: ``` > make testacc TEST=./aws TESTARGS='-run=TestAccAWSS3Bucket_' ... --- PASS: TestAccAWSS3Bucket_shouldFailNotFound (22.93s) --- PASS: TestAccAWSS3Bucket_LifecycleRule_Expiration_EmptyConfigurationBlock (38.71s) --- PASS: TestAccAWSS3Bucket_forceDestroyWithEmptyPrefixes (40.46s) --- PASS: TestAccAWSS3Bucket_forceDestroy (40.47s) --- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenAES256IsUsed (45.72s) --- PASS: TestAccAWSS3Bucket_basic (45.79s) --- PASS: TestAccAWSS3Bucket_forceDestroyWithObjectLockEnabled (47.59s) --- PASS: TestAccAWSS3Bucket_ReplicationExpectVersioningValidationError (51.85s) --- PASS: TestAccAWSS3Bucket_LifecycleBasic (95.95s) --- PASS: TestAccAWSS3Bucket_LifecycleExpireMarkerOnly (69.16s) --- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenTypical (71.63s) --- PASS: TestAccAWSS3Bucket_objectLock (74.52s) --- PASS: TestAccAWSS3Bucket_disableDefaultEncryption_whenDefaultEncryptionIsEnabled (75.75s) --- PASS: TestAccAWSS3Bucket_region (42.47s) --- PASS: TestAccAWSS3Bucket_ReplicationWithoutPrefix (96.80s) --- PASS: TestAccAWSS3Bucket_WebsiteRoutingRules (77.87s) --- PASS: TestAccAWSS3Bucket_Versioning (106.51s) --- PASS: TestAccAWSS3Bucket_UpdateGrant (110.50s) --- PASS: TestAccAWSS3Bucket_GrantToAcl (71.89s) --- PASS: TestAccAWSS3Bucket_AclToGrant (72.06s) --- PASS: TestAccAWSS3Bucket_generatedName (47.42s) --- PASS: TestAccAWSS3Bucket_UpdateAcl (74.86s) --- PASS: TestAccAWSS3Bucket_namePrefix (44.58s) --- PASS: TestAccAWSS3Bucket_RequestPayer (75.62s) --- PASS: TestAccAWSS3Bucket_ReplicationWithoutStorageClass (97.00s) --- PASS: TestAccAWSS3Bucket_Cors_EmptyOrigin (47.36s) --- PASS: TestAccAWSS3Bucket_WebsiteRedirect (109.43s) --- PASS: TestAccAWSS3Bucket_Website_Simple (109.41s) --- PASS: TestAccAWSS3Bucket_ReplicationConfiguration_Rule_Destination_AddAccessControlTranslation (152.76s) --- PASS: TestAccAWSS3Bucket_acceleration (81.59s) --- PASS: TestAccAWSS3Bucket_Cors_Delete (36.58s) --- PASS: TestAccAWSS3Bucket_Bucket_EmptyString (44.94s) --- PASS: TestAccAWSS3Bucket_Logging (66.26s) --- PASS: TestAccAWSS3Bucket_Policy (104.79s) --- PASS: TestAccAWSS3Bucket_ReplicationConfiguration_Rule_Destination_AccessControlTranslation (176.75s) --- PASS: TestAccAWSS3Bucket_Cors_Update (71.71s) --- PASS: TestAccAWSS3Bucket_tagsWithNoSystemTags (135.94s) --- PASS: TestAccAWSS3Bucket_tagsWithSystemTags (168.39s) --- PASS: TestAccAWSS3Bucket_Replication (270.65s) --- PASS: TestAccAWSS3Bucket_ReplicationSchemaV2 (273.25s) ```
d4d2d85
to
2c34a42
Compare
This functionality has been released in v3.57.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! |
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. |
Community Note
Closes #13008
Release note for CHANGELOG:
The AWS S3 service has eventual consistency considerations. If a
GetBucketTagging call is made to obtain tags just after an S3 bucket is
first created, AWS may return an HTTP 404 (NotFound) error with a
NoSuchBucket error code.
A fix was added for this in #12418. It appears that the NoSuchBucket
errors are not retried with this fix, however. This commit adds some
extra logic which ensures that the code from the awserr.Error instance
is evaluated for retry.
Output for acceptance testing: