forked from kubeflow/pipelines
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Testing] Reduce flakiness caused by iam bindings (kubeflow#3008)
* Add retry to iam policy bindings * Add retry for iam policy changes to reduce flakiness
- Loading branch information
Showing
3 changed files
with
36 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Reference: https://unix.stackexchange.com/a/137639 | ||
|
||
function fail { | ||
echo $1 >&2 | ||
exit 1 | ||
} | ||
|
||
function retry { | ||
local n=1 | ||
local max=3 | ||
local delay=2 | ||
while true; do | ||
"$@" && break || { | ||
if [[ $n -lt $max ]]; then | ||
((n++)) | ||
echo "Command failed. Attempt $n/$max:" | ||
sleep $delay; | ||
else | ||
fail "The command has failed after $n attempts." | ||
fi | ||
} | ||
done | ||
} |