Skip to content

Commit f13f1a3

Browse files
Bigtable: Increase timeout in table creation (#6495) (#12468)
* Increase timeout in table creation * Variable name change Signed-off-by: Modular Magician <[email protected]> Signed-off-by: Modular Magician <[email protected]>
1 parent 4832dd9 commit f13f1a3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

.changelog/6495.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
bigtable: increased timeout in table creation.
3+
```

google/resource_bigtable_table.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"log"
7+
"time"
78

89
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
910
)
@@ -19,6 +20,11 @@ func resourceBigtableTable() *schema.Resource {
1920
State: resourceBigtableTableImport,
2021
},
2122

23+
// Set a longer timeout for table creation as adding column families can be slow.
24+
Timeouts: &schema.ResourceTimeout{
25+
Create: schema.DefaultTimeout(45 * time.Minute),
26+
},
27+
2228
// ----------------------------------------------------------------------
2329
// IMPORTANT: Do not add any additional ForceNew fields to this resource.
2430
// Destroying/recreating tables can lead to data loss for users.
@@ -124,7 +130,12 @@ func resourceBigtableTableCreate(d *schema.ResourceData, meta interface{}) error
124130
column := co.(map[string]interface{})
125131

126132
if v, ok := column["family"]; ok {
127-
if err := c.CreateColumnFamily(ctx, name, v.(string)); err != nil {
133+
// Set a longer timeout as adding column family can be slow. The current timeout
134+
// in the Go client is less than one minute. This timeout should not be longer
135+
// than the overall timeout.
136+
ctxWithTimeout, cancel := context.WithTimeout(ctx, 5*time.Minute)
137+
defer cancel() // Always call cancel.
138+
if err := c.CreateColumnFamily(ctxWithTimeout, name, v.(string)); err != nil {
128139
return fmt.Errorf("Error creating column family %s. %s", v, err)
129140
}
130141
}

0 commit comments

Comments
 (0)