Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARTESCA-9658 retry for ETCd backup #4168

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/backup.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ replicate_archives() {

run "Backing up MetalK8s configurations" backup_metalk8s_conf
run "Backing up CAs certificates and keys" backup_cas
run "Backing up etcd data" backup_etcd
run_with_retry 12 5 "Backing up etcd data" backup_etcd
run "Creating backup archive '$BACKUP_ARCHIVE'" create_archive

if (( REPLICATION )); then
Expand Down
26 changes: 23 additions & 3 deletions scripts/common.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ stop_salt_minion_service() {
${SYSTEMCTL} stop salt-minion.service 2>/dev/null || true
}

die() {
echo 1>&2 "$@"
return 1
}

run_quiet() {
local name=$1
shift 1
Expand Down Expand Up @@ -213,9 +218,24 @@ run() {
fi
}

die() {
echo 1>&2 "$@"
return 1
run_with_retry() {
local retries=$1
local delay=$2
shift 2

local -i i=0
while true; do
if [[ $(( ++i )) -gt $retries ]]; then
die "Failed to run '$*' after ${retries} retries."
fi

echo -n "> ${i}/${retries} "
aprucolimartins marked this conversation as resolved.
Show resolved Hide resolved
if run "${@}"; then
break
fi

sleep "${delay}"
done
}

check_package_manager_yum() {
Expand Down
Loading