Skip to content

Commit

Permalink
Fix type assertion when loading stored error
Browse files Browse the repository at this point in the history
Fix a bug where the last error was not retrieved from errVal.Load
due to an incorrect type assertion.
  • Loading branch information
jbardin committed Feb 15, 2018
1 parent e331ae9 commit e06f76b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions communicator/communicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,17 @@ func New(s *terraform.InstanceState) (Communicator, error) {
}
}

// maxBackoffDealy is the maximum delay between retry attempts
var maxBackoffDelay = 10 * time.Second
// maxBackoffDelay is the maximum delay between retry attempts
var maxBackoffDelay = 20 * time.Second
var initialBackoffDelay = time.Second

// Fatal is an interface that error values can return to halt Retry
type Fatal interface {
FatalError() error
}

// Retry retries the function f until it returns a nil error, a Fatal error, or
// the context expires.
func Retry(ctx context.Context, f func() error) error {
// container for atomic error value
type errWrap struct {
Expand Down Expand Up @@ -97,7 +100,7 @@ func Retry(ctx context.Context, f func() error) error {
done = true
}

errVal.Store(&errWrap{err})
errVal.Store(errWrap{err})

if done {
return
Expand Down

0 comments on commit e06f76b

Please sign in to comment.