From a859f05fc59a6886210b6f412907018bdce295c3 Mon Sep 17 00:00:00 2001 From: Andrew Shinohara Date: Wed, 10 Oct 2018 14:18:08 -0700 Subject: [PATCH] Adding retry to make sure connect server is running --- connect/resource_kafka_connector.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/connect/resource_kafka_connector.go b/connect/resource_kafka_connector.go index bf08450d..ef3f29ed 100644 --- a/connect/resource_kafka_connector.go +++ b/connect/resource_kafka_connector.go @@ -3,6 +3,7 @@ package connect import ( "fmt" "log" + "time" "github.com/hashicorp/terraform/helper/schema" kc "github.com/ricardo-ch/go-kafka-connect/lib/connectors" @@ -38,6 +39,15 @@ func connectorCreate(d *schema.ResourceData, meta interface{}) error { c := meta.(kc.Client) name := nameFromRD(d) config := configFromRD(d) + if !kc.TryUntil( + func() bool { + _, err := c.GetAll() + return err == nil + }, + 5*time.Minute, + ) { + return fmt.Errorf("timed out trying to connect to kafka-connect server at %s", c.URL) + } req := kc.CreateConnectorRequest{ ConnectorRequest: kc.ConnectorRequest{ Name: name,