Fix type assertion when loading stored error

Fix a bug where the last error was not retrieved from errVal.Load
due to an incorrect type assertion.
This commit is contained in:
James Bardin 2018-02-15 14:04:17 -05:00
parent e331ae9842
commit e06f76b90f
1 changed files with 6 additions and 3 deletions

View File

@ -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 {
@ -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