nomad_smartrestart: tidy up
This commit is contained in:
parent
c76a96e395
commit
2964c006e7
1 changed files with 8 additions and 8 deletions
|
@ -3,10 +3,7 @@ set -e;
|
||||||
|
|
||||||
cd "$(dirname "$(readlink -f "$0")")" || { echo "Error: Failed to cd to script directory" >&2; exit 1; };
|
cd "$(dirname "$(readlink -f "$0")")" || { echo "Error: Failed to cd to script directory" >&2; exit 1; };
|
||||||
|
|
||||||
imagename="${1}"
|
imagename="${1}";
|
||||||
|
|
||||||
jobname="${1}";
|
|
||||||
taskname="${2}";
|
|
||||||
|
|
||||||
if [[ -z "${NO_COLOR}" ]]; then
|
if [[ -z "${NO_COLOR}" ]]; then
|
||||||
RS="\033[0m" # reset
|
RS="\033[0m" # reset
|
||||||
|
@ -19,7 +16,7 @@ if [[ -z "${NO_COLOR}" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
help() {
|
help() {
|
||||||
echo -e "nomad_smartrestart, v0.1
|
echo -e "${FGRN}${HC}nomad_smartrestart${RS}, ${HC}v0.1${RS}
|
||||||
By Starbeamrainbowlabs
|
By Starbeamrainbowlabs
|
||||||
|
|
||||||
${FBLE}${HC}USAGE${RS}
|
${FBLE}${HC}USAGE${RS}
|
||||||
|
@ -42,7 +39,9 @@ if [[ -z "${imagename}" ]]; then
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -f "./images/${imagename}/nomad.txt" ]]; then
|
loc_nomad_txt="./images/${imagename}/nomad.txt";
|
||||||
|
|
||||||
|
if [[ ! -f "${loc_nomad_txt}" ]]; then
|
||||||
log_msg "No nomad.txt present for ${HC}${FGRN}${imagename}${RS}, nothing to do";
|
log_msg "No nomad.txt present for ${HC}${FGRN}${imagename}${RS}, nothing to do";
|
||||||
help;
|
help;
|
||||||
exit 0;
|
exit 0;
|
||||||
|
@ -74,6 +73,7 @@ nomad_alloc_restart() {
|
||||||
local alloc_id="${1}"
|
local alloc_id="${1}"
|
||||||
|
|
||||||
curl -sS "${URL_NOMAD}/v1/client/allocation/${alloc_id}/restart";
|
curl -sS "${URL_NOMAD}/v1/client/allocation/${alloc_id}/restart";
|
||||||
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,12 +96,12 @@ while read -r jobname taskname; do
|
||||||
|
|
||||||
while read -r alloc_id jobname taskname; do
|
while read -r alloc_id jobname taskname; do
|
||||||
alloc_id_short="$(echo "${alloc_id}" | head -c7)";
|
alloc_id_short="$(echo "${alloc_id}" | head -c7)";
|
||||||
log_msg "Restarting allocation ${HC}${FBLE}${alloc_id_short}${RC} in-place";
|
log_msg "Restarting allocation ${HC}${FBLE}${alloc_id_short}${RS} in-place";
|
||||||
|
|
||||||
nomad_alloc_restart "${alloc_id}";
|
nomad_alloc_restart "${alloc_id}";
|
||||||
count_restarted="$((count_restarted+1))";
|
count_restarted="$((count_restarted+1))";
|
||||||
done < <(nomad_allocs_find "${jobname}" "${taskname}");
|
done < <(nomad_allocs_find "${jobname}" "${taskname}");
|
||||||
count_tasks="$((count_tasks+1))";
|
count_tasks="$((count_tasks+1))";
|
||||||
done
|
done <"${loc_nomad_txt}"
|
||||||
|
|
||||||
log_msg "Restarted ${HC}${count_restarted}${RS} allocations for ${HC}${count_tasks}${RS} tasks in-place";
|
log_msg "Restarted ${HC}${count_restarted}${RS} allocations for ${HC}${count_tasks}${RS} tasks in-place";
|
||||||
|
|
Loading…
Reference in a new issue