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:
parent
e331ae9842
commit
e06f76b90f
|
@ -55,14 +55,17 @@ func New(s *terraform.InstanceState) (Communicator, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// maxBackoffDealy is the maximum delay between retry attempts
|
// maxBackoffDelay is the maximum delay between retry attempts
|
||||||
var maxBackoffDelay = 10 * time.Second
|
var maxBackoffDelay = 20 * time.Second
|
||||||
var initialBackoffDelay = time.Second
|
var initialBackoffDelay = time.Second
|
||||||
|
|
||||||
|
// Fatal is an interface that error values can return to halt Retry
|
||||||
type Fatal interface {
|
type Fatal interface {
|
||||||
FatalError() error
|
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 {
|
func Retry(ctx context.Context, f func() error) error {
|
||||||
// container for atomic error value
|
// container for atomic error value
|
||||||
type errWrap struct {
|
type errWrap struct {
|
||||||
|
@ -97,7 +100,7 @@ func Retry(ctx context.Context, f func() error) error {
|
||||||
done = true
|
done = true
|
||||||
}
|
}
|
||||||
|
|
||||||
errVal.Store(&errWrap{err})
|
errVal.Store(errWrap{err})
|
||||||
|
|
||||||
if done {
|
if done {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue