From 8a4cbcb5a28c96b7f2eaba9b2903ffd40cf65572 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Thu, 28 May 2015 17:36:21 -0500 Subject: [PATCH 1/2] provider/aws: Check ElastiCache node status before returning --- .../providers/aws/resource_aws_elasticache_cluster.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_elasticache_cluster.go b/builtin/providers/aws/resource_aws_elasticache_cluster.go index b62df2dec2..ee7848387d 100644 --- a/builtin/providers/aws/resource_aws_elasticache_cluster.go +++ b/builtin/providers/aws/resource_aws_elasticache_cluster.go @@ -308,7 +308,8 @@ func resourceAwsElasticacheClusterDelete(d *schema.ResourceData, meta interface{ func CacheClusterStateRefreshFunc(conn *elasticache.ElastiCache, clusterID, givenState string, pending []string) resource.StateRefreshFunc { return func() (interface{}, string, error) { resp, err := conn.DescribeCacheClusters(&elasticache.DescribeCacheClustersInput{ - CacheClusterID: aws.String(clusterID), + CacheClusterID: aws.String(clusterID), + ShowCacheNodeInfo: aws.Boolean(true), }) if err != nil { apierr := err.(awserr.Error) @@ -336,6 +337,13 @@ func CacheClusterStateRefreshFunc(conn *elasticache.ElastiCache, clusterID, give // return given state if it's not in pending if givenState != "" { + // loop the nodes and check their status as well + for _, n := range c.CacheNodes { + if n.CacheNodeStatus != nil && *n.CacheNodeStatus != "available" { + log.Printf("[DEBUG] Node (%s) is not yet available, status: %s", *n.CacheNodeID, *n.CacheNodeStatus) + return nil, "creating", nil + } + } return c, givenState, nil } log.Printf("[DEBUG] current status: %v", *c.CacheClusterStatus) From c95557af27c03af293b8f1ee3ebfa9de318caf85 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Fri, 29 May 2015 10:09:54 -0500 Subject: [PATCH 2/2] Check node length to match expected node count --- builtin/providers/aws/resource_aws_elasticache_cluster.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/builtin/providers/aws/resource_aws_elasticache_cluster.go b/builtin/providers/aws/resource_aws_elasticache_cluster.go index ee7848387d..1095a93074 100644 --- a/builtin/providers/aws/resource_aws_elasticache_cluster.go +++ b/builtin/providers/aws/resource_aws_elasticache_cluster.go @@ -337,6 +337,11 @@ func CacheClusterStateRefreshFunc(conn *elasticache.ElastiCache, clusterID, give // return given state if it's not in pending if givenState != "" { + // check to make sure we have the node count we're expecting + if int64(len(c.CacheNodes)) != *c.NumCacheNodes { + log.Printf("[DEBUG] Node count is not what is expected: %d found, %d expected", len(c.CacheNodes), *c.NumCacheNodes) + return nil, "creating", nil + } // loop the nodes and check their status as well for _, n := range c.CacheNodes { if n.CacheNodeStatus != nil && *n.CacheNodeStatus != "available" {