From 616356fd52ced2f2a620fd1a684d36afa6719f39 Mon Sep 17 00:00:00 2001 From: Arjun Raj Date: Fri, 19 Jun 2020 21:52:38 +1000 Subject: [PATCH 1/4] fix: Fixed infinite loop on vpc peeering with clusters not in "PROVISIONED" status --- instaclustr/resource_vpc_peering.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/instaclustr/resource_vpc_peering.go b/instaclustr/resource_vpc_peering.go index ceaaaf37..f0c420a1 100644 --- a/instaclustr/resource_vpc_peering.go +++ b/instaclustr/resource_vpc_peering.go @@ -64,17 +64,24 @@ func resourceVpcPeeringCreate(d *schema.ResourceData, meta interface{}) error { log.Printf("[INFO] Creating VPC peering request.") client := meta.(*Config).Client + const ClusterReadInterval = 5 + const WaitForClusterTimeout = 60 var cdcID string + timePassed := 0 for { cluster, err := client.ReadCluster(d.Get("cluster_id").(string)) if err != nil { return fmt.Errorf("[Error] Error retrieving cluster info: %s", err) } - if cluster.ClusterStatus == "PROVISIONED" { + if cluster.ClusterStatus == "PROVISIONED" || cluster.ClusterStatus == "RUNNING" { cdcID = cluster.DataCentres[0].ID break } - time.Sleep(5 * time.Second) + if timePassed > WaitForClusterTimeout { + return fmt.Errorf("[Error] Timed out waiting for cluster to have the status 'PROVISIONED' or 'RUNNING'") + } + time.Sleep(ClusterReadInterval * time.Second) + timePassed += ClusterReadInterval } createData := CreateVPCPeeringRequest{ From f1ce001c7d77c2eb9b7ee51a2e7eaa1a5ab47e47 Mon Sep 17 00:00:00 2001 From: Arjun Raj Date: Fri, 19 Jun 2020 21:56:45 +1000 Subject: [PATCH 2/4] chore: Updated version to 1.2.1 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3b3ec616..2c0858e2 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ BIN_NAME="terraform-provider-instaclustr" -VERSION=v1.2.0 +VERSION=v1.2.1 .PHONY: install clean all build test testacc From e2d1dbab74b127d0c3cd1fd96b71139a73780ca8 Mon Sep 17 00:00:00 2001 From: Arjun Raj Date: Fri, 19 Jun 2020 22:02:44 +1000 Subject: [PATCH 3/4] chore: Tweaked timeout error message on vpc peering --- instaclustr/resource_vpc_peering.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/instaclustr/resource_vpc_peering.go b/instaclustr/resource_vpc_peering.go index f0c420a1..c28b4777 100644 --- a/instaclustr/resource_vpc_peering.go +++ b/instaclustr/resource_vpc_peering.go @@ -67,18 +67,20 @@ func resourceVpcPeeringCreate(d *schema.ResourceData, meta interface{}) error { const ClusterReadInterval = 5 const WaitForClusterTimeout = 60 var cdcID string + var latestStatus string timePassed := 0 for { cluster, err := client.ReadCluster(d.Get("cluster_id").(string)) if err != nil { return fmt.Errorf("[Error] Error retrieving cluster info: %s", err) } + latestStatus = cluster.ClusterStatus if cluster.ClusterStatus == "PROVISIONED" || cluster.ClusterStatus == "RUNNING" { cdcID = cluster.DataCentres[0].ID break } if timePassed > WaitForClusterTimeout { - return fmt.Errorf("[Error] Timed out waiting for cluster to have the status 'PROVISIONED' or 'RUNNING'") + return fmt.Errorf("[Error] Timed out waiting for cluster to have the status 'PROVISIONED' or 'RUNNING'. Current cluster status is '%s'", latestStatus) } time.Sleep(ClusterReadInterval * time.Second) timePassed += ClusterReadInterval From d525780a7016a006e86e40f06e72121e06c05298 Mon Sep 17 00:00:00 2001 From: Arjun Raj Date: Mon, 22 Jun 2020 16:47:29 +1000 Subject: [PATCH 4/4] chore: Updated readme to include limitations of creating VPC peering connections --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d6eb3acf..040e2a09 100644 --- a/README.md +++ b/README.md @@ -192,7 +192,9 @@ resource "instaclustr_firewall_rule" "example" { ``` ### Resource: `instaclustr_vpc_peering` -A resource for managing VPC peering connections on Instaclustr Managed Platform. This is only avaliable for clusters hosted with the AWS provider. +A resource for managing VPC peering connections on Instaclustr Managed Platform. This is only avaliable for clusters hosted with the AWS provider. + +When creating this resource, the process will wait for target cluster to be in the `PROVISIONED` or `RUNNING` status. The process will time out after 60 seconds of waiting. #### Properties Property | Description | Default