Skip to content

Commit

Permalink
Merge pull request #1345 from nevins-b/kinesis_timeout
Browse files Browse the repository at this point in the history
increasing timeout for delete and update
  • Loading branch information
grubernaut authored Aug 7, 2017
2 parents 041990f + 9f80143 commit 31b3521
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
3 changes: 2 additions & 1 deletion aws/data_source_aws_kinesis_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package aws
import (
"fmt"
"testing"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/kinesis"
Expand All @@ -26,7 +27,7 @@ func TestAccAWSKinesisStreamDataSource(t *testing.T) {
if err != nil {
t.Fatalf("Error calling UpdateShardCount: %s", err)
}
if err := waitForKinesisToBeActive(conn, sn); err != nil {
if err := waitForKinesisToBeActive(conn, 5*time.Minute, sn); err != nil {
t.Fatal(err)
}
}
Expand Down
22 changes: 14 additions & 8 deletions aws/resource_aws_kinesis_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ func resourceAwsKinesisStream() *schema.Resource {
State: resourceAwsKinesisStreamImport,
},

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(5 * time.Minute),
Update: schema.DefaultTimeout(120 * time.Minute),
Delete: schema.DefaultTimeout(120 * time.Minute),
},

Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Expand Down Expand Up @@ -91,7 +97,7 @@ func resourceAwsKinesisStreamCreate(d *schema.ResourceData, meta interface{}) er
Pending: []string{"CREATING"},
Target: []string{"ACTIVE"},
Refresh: streamStateRefreshFunc(conn, sn),
Timeout: 5 * time.Minute,
Timeout: d.Timeout(schema.TimeoutCreate),
Delay: 10 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -189,7 +195,7 @@ func resourceAwsKinesisStreamDelete(d *schema.ResourceData, meta interface{}) er
Pending: []string{"DELETING"},
Target: []string{"DESTROYED"},
Refresh: streamStateRefreshFunc(conn, sn),
Timeout: 5 * time.Minute,
Timeout: d.Timeout(schema.TimeoutDelete),
Delay: 10 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -238,7 +244,7 @@ func setKinesisRetentionPeriod(conn *kinesis.Kinesis, d *schema.ResourceData) er
}
}

if err := waitForKinesisToBeActive(conn, sn); err != nil {
if err := waitForKinesisToBeActive(conn, d.Timeout(schema.TimeoutUpdate), sn); err != nil {
return err
}

Expand Down Expand Up @@ -267,7 +273,7 @@ func updateKinesisShardCount(conn *kinesis.Kinesis, d *schema.ResourceData) erro
return err
}

if err := waitForKinesisToBeActive(conn, sn); err != nil {
if err := waitForKinesisToBeActive(conn, d.Timeout(schema.TimeoutUpdate), sn); err != nil {
return err
}

Expand Down Expand Up @@ -302,7 +308,7 @@ func updateKinesisShardLevelMetrics(conn *kinesis.Kinesis, d *schema.ResourceDat
if err != nil {
return fmt.Errorf("Failure to disable shard level metrics for stream %s: %s", sn, err)
}
if err := waitForKinesisToBeActive(conn, sn); err != nil {
if err := waitForKinesisToBeActive(conn, d.Timeout(schema.TimeoutUpdate), sn); err != nil {
return err
}
}
Expand All @@ -321,7 +327,7 @@ func updateKinesisShardLevelMetrics(conn *kinesis.Kinesis, d *schema.ResourceDat
if err != nil {
return fmt.Errorf("Failure to enable shard level metrics for stream %s: %s", sn, err)
}
if err := waitForKinesisToBeActive(conn, sn); err != nil {
if err := waitForKinesisToBeActive(conn, d.Timeout(schema.TimeoutUpdate), sn); err != nil {
return err
}
}
Expand Down Expand Up @@ -375,12 +381,12 @@ func streamStateRefreshFunc(conn *kinesis.Kinesis, sn string) resource.StateRefr
}
}

func waitForKinesisToBeActive(conn *kinesis.Kinesis, sn string) error {
func waitForKinesisToBeActive(conn *kinesis.Kinesis, timeout time.Duration, sn string) error {
stateConf := &resource.StateChangeConf{
Pending: []string{"UPDATING"},
Target: []string{"ACTIVE"},
Refresh: streamStateRefreshFunc(conn, sn),
Timeout: 5 * time.Minute,
Timeout: timeout,
Delay: 10 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down

0 comments on commit 31b3521

Please sign in to comment.