From e331ae9842eebc09cfedf7ba828fd288c7d5f3ee Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 14 Feb 2018 18:32:29 -0500 Subject: [PATCH] remove retryFunc it's now in the communicator package --- .../habitat/resource_provisioner.go | 29 ++++--------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/builtin/provisioners/habitat/resource_provisioner.go b/builtin/provisioners/habitat/resource_provisioner.go index f9d47ff07..aa404dae1 100644 --- a/builtin/provisioners/habitat/resource_provisioner.go +++ b/builtin/provisioners/habitat/resource_provisioner.go @@ -6,12 +6,10 @@ import ( "errors" "fmt" "io" - "log" "net/url" "path" "strings" "text/template" - "time" "github.com/hashicorp/terraform/communicator" "github.com/hashicorp/terraform/communicator/remote" @@ -233,10 +231,13 @@ func applyFn(ctx context.Context) error { return err } - err = retryFunc(comm.Timeout(), func() error { - err = comm.Connect(o) - return err + ctx, cancel := context.WithTimeout(ctx, comm.Timeout()) + defer cancel() + + err = communicator.Retry(ctx, func() error { + return comm.Connect(o) }) + if err != nil { return err } @@ -728,24 +729,6 @@ func (p *provisioner) uploadUserTOML(o terraform.UIOutput, comm communicator.Com } -func retryFunc(timeout time.Duration, f func() error) error { - finish := time.After(timeout) - - for { - err := f() - if err == nil { - return nil - } - log.Printf("Retryable error: %v", err) - - select { - case <-finish: - return err - case <-time.After(3 * time.Second): - } - } -} - func (p *provisioner) copyOutput(o terraform.UIOutput, r io.Reader, doneCh chan<- struct{}) { defer close(doneCh) lr := linereader.New(r)