Skip to content

Commit

Permalink
resource_aws_s3_bucket.go: retry NoSuchBucket when updating tags for …
Browse files Browse the repository at this point in the history
…s3 bucket

The original retry was added in [1] but, in later refactor the retry was dropped [2]

the causes failures like

```
level=error msg="Error: error updating S3 Bucket (terraform-20200316104552904700000001) tags: error listing resource tags (terraform-20200316104552904700000001): NoSuchBucket: The specified bucket does not exist"
level=error msg="\tstatus code: 404, request id: <REDACTED>, host id: <REDACTED>"
level=error
level=error msg="  on ../tmp/openshift-install-019032273/bootstrap/main.tf line 7, in resource \"aws_s3_bucket\" \"ignition\":"
level=error msg="   7: resource \"aws_s3_bucket\" \"ignition\" {"
level=error
level=error
```

debug error:
```
time="2020-03-16T10:45:53Z" level=debug msg="2020-03-16T10:45:53.413Z [DEBUG] plugin.terraform-provider-aws: [DEBUG] [aws-sdk-go] DEBUG: Validate Response s3/GetBucketTagging failed, attempt 0/25, error NoSuchBucket: The specified bucket does not exist"
time="2020-03-16T10:45:53Z" level=debug msg="2020-03-16T10:45:53.413Z [DEBUG] plugin.terraform-provider-aws: \tstatus code: 404, request id: <REDACTED>, host id: <REDACTED>"
time="2020-03-16T10:45:53Z" level=debug msg="[DEBUG] module.bootstrap.aws_s3_bucket.ignition: apply errored, but we're indicating that via the Error pointer rather than returning it: error updating S3 Bucket (terraform-20200316104552904700000001) tags: error listing resource tags (terraform-20200316104552904700000001): NoSuchBucket: The specified bucket does not exist"
```

[1]: hashicorp#10863
[2]: hashicorp#11916
  • Loading branch information
abhinavdahiya committed Mar 17, 2020
1 parent 3d80107 commit b51938a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion aws/resource_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,12 @@ func resourceAwsS3BucketUpdate(d *schema.ResourceData, meta interface{}) error {
if d.HasChange("tags") {
o, n := d.GetChange("tags")

if err := keyvaluetags.S3BucketUpdateTags(s3conn, d.Id(), o, n); err != nil {
// Retry due to S3 eventual consistency
_, err := retryOnAwsCode(s3.ErrCodeNoSuchBucket, func() (interface{}, error) {
terr := keyvaluetags.S3BucketUpdateTags(s3conn, d.Id(), o, n)
return nil, terr
})
if err != nil {
return fmt.Errorf("error updating S3 Bucket (%s) tags: %s", d.Id(), err)
}
}
Expand Down

0 comments on commit b51938a

Please sign in to comment.