truestuff/stop-all-chrats.sh

36 lines
752 B
Bash
Raw Normal View History

2023-05-09 03:08:59 +00:00
#! /usr/bin/env bash
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