From a16e34e07c73803d9d82ddc4d7f223560b28d80b Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Tue, 22 Oct 2024 16:53:52 +0200 Subject: [PATCH] chg: [cron] update for compatibility with new ``$GLOBAL_ALL_RELATION`` var --- cron/lib/common | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/cron/lib/common b/cron/lib/common index 43e0c0c..7f37f87 100644 --- a/cron/lib/common +++ b/cron/lib/common @@ -201,27 +201,36 @@ cron:lock_opts() { cron:entries() { - local cache_file="$CACHEDIR/$FUNCNAME.cache.$(H "$SERVICE_NAME" "$ALL_RELATIONS")" \ - s rn ts rc td + if [ -z "$SUBSET_ALL_RELATIONS_HASH" ]; then + err "Expected \$SUBSET_ALL_RELATIONS_HASH to be set." + return 1 + fi + + local cache_file="$CACHEDIR/$FUNCNAME.cache.$(H "$SERVICE_NAME" "$SUBSET_ALL_RELATIONS_HASH")" + local s rn ts rc td E if [ -e "$cache_file" ]; then #debug "$FUNCNAME: SESSION cache hit $1" cat "$cache_file" return 0 fi - if [ -z "$ALL_RELATIONS" ]; then - err "Expected \$ALL_RELATIONS to be set." - return 1 - fi export TARGET_SERVICE_NAME="$SERVICE_NAME" - while read-0 service relation_cfg; do + while read-0-err E service relation_cfg; do debug "service: '$service' relation_cfg:" >&2 e "$relation_cfg" | prefix " | " >&2 echo "" >&2 - cron:entries_from_service "$service" "$relation_cfg" || return 1 - done < <(get_service_incoming_relations "$SERVICE_NAME" "schedule-command") > "$cache_file.tmp" - mv "$cache_file.tmp" "$cache_file" >&2 + cron:entries_from_service "$service" "$relation_cfg" || { + err-d "Failed to get entries from service '$service'." + return 1 + } + done < <(p-err get_service_incoming_relations "$SERVICE_NAME" "schedule-command") > "$cache_file.tmp" + if [ "$E" != 0 ]; then + rm -f "$cache_file.tmp" + err "Failed to get ${DARKYELLOW}*${NORMAL}--${DARKBLUE}schedule-command${NORMAL}-->${DARKYELLOW}$SERVICE_NAME${NORMAL}'s relations." + return 1 + fi + mv "$cache_file"{.tmp,} >&2 cat "$cache_file" } export -f cron:entries \ No newline at end of file