Skip to content

Commit

Permalink
Bigtable: Increase timeout in table creation (#6495)
Browse files Browse the repository at this point in the history
* Increase timeout in table creation

* Variable name change
  • Loading branch information
kevinsi4508 authored Sep 2, 2022
1 parent 9dbf6c0 commit ea34ac2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion mmv1/third_party/terraform/resources/resource_bigtable_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"time"

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

// Set a longer timeout for table creation as adding column families can be slow.
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(45 * time.Minute),
},

// ----------------------------------------------------------------------
// IMPORTANT: Do not add any additional ForceNew fields to this resource.
// Destroying/recreating tables can lead to data loss for users.
Expand Down Expand Up @@ -124,7 +130,12 @@ func resourceBigtableTableCreate(d *schema.ResourceData, meta interface{}) error
column := co.(map[string]interface{})

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

0 comments on commit ea34ac2

Please sign in to comment.