Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

increasing timeout for delete and update #1345

Merged
merged 2 commits into from
Aug 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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