Skip to content

Commit 115a7a1

Browse files
Added read timeout to bigtable instance (#8948) (#15856)
Signed-off-by: Modular Magician <[email protected]>
1 parent b5a291f commit 115a7a1

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

.changelog/8948.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
bigtable: added a read timeout to `google_bigtable_instance`
3+
```

google/services/bigtable/resource_bigtable_instance.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func ResourceBigtableInstance() *schema.Resource {
3333
Timeouts: &schema.ResourceTimeout{
3434
Create: schema.DefaultTimeout(60 * time.Minute),
3535
Update: schema.DefaultTimeout(60 * time.Minute),
36+
Read: schema.DefaultTimeout(60 * time.Minute),
3637
},
3738

3839
CustomizeDiff: customdiff.All(
@@ -257,7 +258,9 @@ func resourceBigtableInstanceRead(d *schema.ResourceData, meta interface{}) erro
257258

258259
instanceName := d.Get("name").(string)
259260

260-
instance, err := c.InstanceInfo(ctx, instanceName)
261+
ctxWithTimeout, cancel := context.WithTimeout(ctx, d.Timeout(schema.TimeoutRead))
262+
defer cancel()
263+
instance, err := c.InstanceInfo(ctxWithTimeout, instanceName)
261264
if err != nil {
262265
if tpgresource.IsNotFoundGrpcError(err) {
263266
log.Printf("[WARN] Removing %s because it's gone", instanceName)
@@ -271,7 +274,7 @@ func resourceBigtableInstanceRead(d *schema.ResourceData, meta interface{}) erro
271274
return fmt.Errorf("Error setting project: %s", err)
272275
}
273276

274-
clusters, err := c.Clusters(ctx, instance.Name)
277+
clusters, err := c.Clusters(ctxWithTimeout, instance.Name)
275278
if err != nil {
276279
partiallyUnavailableErr, ok := err.(bigtable.ErrPartiallyUnavailable)
277280

website/docs/r/bigtable_instance.html.markdown

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ This resource provides the following
150150

151151
- `create` - Default is 60 minutes.
152152
- `update` - Default is 60 minutes.
153+
- `read` - Default is 60 minutes.
153154

154155
Adding clusters to existing instances can take a long time. Consider setting a higher value to timeouts if you plan on doing that.
155156

0 commit comments

Comments
 (0)