do SCALE_POOL calculation only if necessary

Following an incident where midclt calls were hanging
This commit is contained in:
Lockszmith (@kateryna) 2024-12-24 15:51:48 -05:00
parent c8c218f860
commit f47d0d00ed
1 changed files with 3 additions and 1 deletions

View File

@ -1,6 +1,8 @@
#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"'
if is_cmd midclt; then
if is_cmd midclt && [ -z "$SCALE_POOL" ]; then
export SCALE_POOL=szmedia
export SCALE_POOL="$(midclt call "kubernetes.config" 2>/dev/null | jq -r '.pool')"
[ -n "$SCALE_POOL" ] && [ "$SCALE_POOL" != "null" ] || export SCALE_POOL="$(midclt call "pool.query" 2>/dev/null | jq -r '.[0].name')"
[ -d "/mnt/$SCALE_POOL" ] || unset SCALE_POOL