2023-05-09 03:08:59 +00:00
|
|
|
#! /usr/bin/env bash
|
2023-05-09 04:31:22 +00:00
|
|
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|
|
|
USER_HOME=$HOME
|
|
|
|
[[ -n "${SUDO_USER}" ]] && USER_HOME="$(eval "echo ~${SUDO_USER}")"
|
|
|
|
. ${SHRC_D:-$USER_HOME/.pqb.shrc.d}/01_util.functions
|
|
|
|
|
2023-05-09 03:08:59 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
get_charts() {
|
|
|
|
midclt call chart.release.query | jq -r '.[] | select( .status != "STOPPED" ) | .id'
|
|
|
|
}
|
|
|
|
|
|
|
|
stop_chart() {
|
|
|
|
local CHART="${1}"
|
|
|
|
printf 'Stopping charts: %s... ' "$CHART"
|
|
|
|
midclt call chart.release.scale "$CHART" '{"replica_count": 0}'
|
|
|
|
printf '\n'
|
|
|
|
}
|
|
|
|
|
|
|
|
stop_all_charts() {
|
|
|
|
get_charts | while read chart; do
|
|
|
|
[[ -n "$chart" ]] || continue
|
|
|
|
stop_chart "$chart"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
count_unfinished_jobs() {
|
|
|
|
midclt call core.get_jobs | jq -r '.[] | select( .time_finished == null )' | wc -l
|
|
|
|
}
|
|
|
|
|
|
|
|
while [[ "$( get_charts | wc -l )" -gt 0 ]]; do
|
|
|
|
stop_all_charts
|
|
|
|
|
|
|
|
while [[ "$( count_unfinished_jobs )" -gt 0 ]]; do
|
|
|
|
printf '.'
|
|
|
|
sleep 2
|
|
|
|
done
|
|
|
|
printf '\n'
|
|
|
|
done
|
|
|
|
|