From ba9c23c04d4dd72a09b44ab14f1308f58a17ddad Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Tue, 16 Jan 2024 22:16:16 +0100 Subject: [PATCH] fix: [compose-core] prevent summoning each services in one go Some requirement might solve other requests, especially the ones that are not clear because more than one provider exist. --- bin/compose-core | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/bin/compose-core b/bin/compose-core index 91a247e..fcf7786 100755 --- a/bin/compose-core +++ b/bin/compose-core @@ -2636,6 +2636,7 @@ get_all_relations () { ## situation is stable if [ "${#summon[@]}" != 0 ]; then + declare -A summon_requeued=() while [ "${#summon[@]}" != 0 ]; do service="${summon[0]}" relation_name="${summon[1]}" @@ -2650,9 +2651,18 @@ get_all_relations () { fi if [ "${#providers[@]}" -gt 1 ]; then - warn "Auto-summon ${DARKYELLOW}$service${NORMAL}" \ - "--${DARKBLUE}$relation_name${NORMAL}--> ($DARKYELLOW""${providers[@]}""$NORMAL)"\ - "(> 1 provider). Choosing first." + if [ -z "${summon_requeued[$service/$relation_name]}" ]; then + debug "Auto-summon ${DARKYELLOW}$service${NORMAL}" \ + "--${DARKBLUE}$relation_name${NORMAL}--> ($DARKYELLOW""${providers[@]}""$NORMAL)"\ + "(> 1 provider). Requeing." + summon+=("$service" "$relation_name" "$relation_def") ## re-queue it + summon_requeued["$service/$relation_name"]=1 + continue + else + warn "Auto-summon ${DARKYELLOW}$service${NORMAL}" \ + "--${DARKBLUE}$relation_name${NORMAL}--> ($DARKYELLOW""${providers[@]}""$NORMAL)"\ + "(> 1 provider). Choosing first." + fi fi ts="${providers[0]}" @@ -2669,6 +2679,7 @@ get_all_relations () { array_read-0 services_uses < <(_get_services_uses "$ts") services[$ts]=1 changed=1 + continue 2 done continue fi