From e06f76b90f2b47db63f732d36f523450a3b4d19f Mon Sep 17 00:00:00 2001 From: James Bardin Date: Thu, 15 Feb 2018 14:04:17 -0500 Subject: [PATCH] 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. --- communicator/communicator.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/communicator/communicator.go b/communicator/communicator.go index 3749a9f98120..440c1c727e9a 100644 --- a/communicator/communicator.go +++ b/communicator/communicator.go @@ -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