mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-12 17:30:19 +00:00
e2e: add retryKubectlArgs helper for kubectl retry
added helper function retryKubectlArgs to perform action if its a known error. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
dd9fabf747
commit
9f0af30735
30
e2e/utils.go
30
e2e/utils.go
@ -1296,3 +1296,33 @@ func retryKubectlFile(namespace string, action kubectlAction, filename string, t
|
|||||||
return true, nil
|
return true, nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// retryKubectlArgs takes a namespace and action telling kubectl what to do
|
||||||
|
// with the passed arguments. This function retries until no error occurred, or
|
||||||
|
// the timeout passed.
|
||||||
|
func retryKubectlArgs(namespace string, action kubectlAction, t int, args ...string) error {
|
||||||
|
timeout := time.Duration(t) * time.Minute
|
||||||
|
args = append([]string{string(action)}, args...)
|
||||||
|
e2elog.Logf("waiting for kubectl (%s args) to finish", args)
|
||||||
|
start := time.Now()
|
||||||
|
|
||||||
|
return wait.PollImmediate(poll, timeout, func() (bool, error) {
|
||||||
|
_, err := framework.RunKubectl(namespace, args...)
|
||||||
|
if err != nil {
|
||||||
|
if isRetryableAPIError(err) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
if isAlreadyExistsCLIError(err) {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
e2elog.Logf(
|
||||||
|
"will run kubectl (%s) again (%d seconds elapsed)",
|
||||||
|
args,
|
||||||
|
int(time.Since(start).Seconds()))
|
||||||
|
|
||||||
|
return false, fmt.Errorf("failed to run kubectl: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user