Merge pull request #4700 from hashicorp/phinze/fix-testrace-resource

helper/resource: Fix data race in resource.Retry
This commit is contained in:
Paul Hinze 2016-01-19 17:17:04 -06:00
commit 283d57c031

View File

@ -10,14 +10,13 @@ type RetryFunc func() error
// Retry is a basic wrapper around StateChangeConf that will just retry
// a function until it no longer returns an error.
func Retry(timeout time.Duration, f RetryFunc) error {
var err error
c := &StateChangeConf{
Pending: []string{"error"},
Target: "success",
Timeout: timeout,
MinTimeout: 500 * time.Millisecond,
Refresh: func() (interface{}, string, error) {
err = f()
err := f()
if err == nil {
return 42, "success", nil
}
@ -31,7 +30,7 @@ func Retry(timeout time.Duration, f RetryFunc) error {
},
}
c.WaitForState()
_, err := c.WaitForState()
return err
}