forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds workflow retry if it fails (#411)
- Loading branch information
1 parent
1a4b26f
commit 86717d0
Showing
3 changed files
with
58 additions
and
16 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,26 @@ | ||
#!/bin/bash | ||
|
||
# Function to retry an operation a number of times | ||
# Arguments: | ||
# $1: Name of the operation | ||
# $2: Number of attempts | ||
# $3: Delay between attempts | ||
# $4+: Command to execute | ||
retry_operation() { | ||
local operation_name=$1 | ||
local max_attempts=$2 | ||
local sleep_time=$3 | ||
shift 3 # Delete the first 3 arguments | ||
|
||
for i in $(seq 1 $max_attempts); do | ||
if eval "$@"; then | ||
return 0 | ||
else | ||
if [ $i -eq $max_attempts ]; then | ||
echo "Failed to $operation_name after $max_attempts attempts" | ||
return 1 | ||
fi | ||
sleep $sleep_time | ||
fi | ||
done | ||
} |