Skip to content

Commit

Permalink
Adding retry to make sure connect server is running
Browse files Browse the repository at this point in the history
  • Loading branch information
ashinohara authored and Mongey committed Oct 17, 2018
1 parent dbc66e8 commit a859f05
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions connect/resource_kafka_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a859f05

Please sign in to comment.