mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-16 11:42:58 -06:00
Merge pull request #4700 from hashicorp/phinze/fix-testrace-resource
helper/resource: Fix data race in resource.Retry
This commit is contained in:
commit
283d57c031
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user