Retry is a wrapper around a RetryFunc that will retry a function n times or until it succeeds.
(n int, f RetryFunc)
| 128 | // Retry is a wrapper around a RetryFunc that will retry a function |
| 129 | // n times or until it succeeds. |
| 130 | func Retry(n int, f RetryFunc) (interface{}, error) { |
| 131 | var lastErr error |
| 132 | |
| 133 | for i := 0; i < n; i++ { |
| 134 | r, err := f() |
| 135 | if err == nil || err == cloudstack.AsyncTimeoutErr { |
| 136 | return r, err |
| 137 | } |
| 138 | |
| 139 | lastErr = err |
| 140 | time.Sleep(30 * time.Second) |
| 141 | } |
| 142 | |
| 143 | return nil, lastErr |
| 144 | } |
| 145 | |
| 146 | // If there is a project supplied, we retrieve and set the project id |
| 147 | func setProjectid(p cloudstack.ProjectIDSetter, cs *cloudstack.CloudStackClient, d *schema.ResourceData) error { |
no outgoing calls
no test coverage detected