Skip to content

Commit

Permalink
Bigtable: Retry GC policy operations with a longer poll interval (#6627
Browse files Browse the repository at this point in the history
…) (#12717)

Co-authored-by: Riley Karson <rileykarson@google.com>
Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
Co-authored-by: Riley Karson <rileykarson@google.com>
  • Loading branch information
modular-magician and rileykarson committed Oct 4, 2022
1 parent c06396c commit 67afa96
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .changelog/6627.txt
@@ -0,0 +1,3 @@
```release-note:enhancement
bigtable: retry GC policy operations with a longer poll interval
```
23 changes: 17 additions & 6 deletions google/resource_bigtable_gc_policy.go
Expand Up @@ -202,10 +202,17 @@ func resourceBigtableGCPolicyUpsert(d *schema.ResourceData, meta interface{}) er
tableName := d.Get("table").(string)
columnFamily := d.Get("column_family").(string)

err = retryTimeDuration(func() error {
retryFunc := func() (interface{}, error) {
reqErr := c.SetGCPolicy(ctx, tableName, columnFamily, gcPolicy)
return reqErr
}, d.Timeout(schema.TimeoutCreate), isBigTableRetryableError)
return "", reqErr
}
// The default create timeout is 20 minutes.
timeout := d.Timeout(schema.TimeoutCreate)
pollInterval := time.Duration(30) * time.Second
// Mutations to gc policies can only happen one-at-a-time and take some amount of time.
// Use a fixed polling rate of 30s based on the RetryInfo returned by the server rather than
// the standard up-to-10s exponential backoff for those operations.
_, err = retryWithPolling(retryFunc, timeout, pollInterval, isBigTableRetryableError)
if err != nil {
return err
}
Expand Down Expand Up @@ -376,10 +383,14 @@ func resourceBigtableGCPolicyDestroy(d *schema.ResourceData, meta interface{}) e

defer c.Close()

err = retryTimeDuration(func() error {
retryFunc := func() (interface{}, error) {
reqErr := c.SetGCPolicy(ctx, d.Get("table").(string), d.Get("column_family").(string), bigtable.NoGcPolicy())
return reqErr
}, d.Timeout(schema.TimeoutDelete), isBigTableRetryableError)
return "", reqErr
}
// The default delete timeout is 20 minutes.
timeout := d.Timeout(schema.TimeoutDelete)
pollInterval := time.Duration(30) * time.Second
_, err = retryWithPolling(retryFunc, timeout, pollInterval, isBigTableRetryableError)
if err != nil {
return err
}
Expand Down

0 comments on commit 67afa96

Please sign in to comment.