Browse Source

new: [compose-core] prevent sub compose command to try to solve again relation constraints

This is because sub-compose command are often in a subset of the
services and as a consequence they do not share the same environment
and might solve the constraints differently.
cache-relation
Valentin Lab 11 months ago
parent
commit
78d3cb4da1
  1. 19
      bin/compose
  2. 10
      bin/compose-core

19
bin/compose

@ -1006,6 +1006,22 @@ load_env() {
fi
done < "$COMPOSE_LAUNCHER_OPTS"
fi
if [ -n "$ALL_RELATIONS" ]; then
if ! [ -e "$ALL_RELATIONS" ]; then
err "Variable \$ALL_RELATION provided but it doesn't point on an existing file."
return 1
fi
if ! [ -r "$ALL_RELATIONS" ]; then
err "Variable \$ALL_RELATION provided but it doesn't point on a readable file."
return 1
fi
NEW_ALL_RELATIONS="$COMPOSE_CACHE/${ALL_RELATIONS##*/}"
if [ "$NEW_ALL_RELATIONS" != "$ALL_RELATIONS" ]; then
cp "$ALL_RELATIONS" "$NEW_ALL_RELATIONS" || return 1
fi
docker_run_opts+=("-e" "ALL_RELATIONS=$NEW_ALL_RELATIONS")
fi
}
show_env() {
@ -1019,6 +1035,9 @@ show_env() {
echo " COMPOSE_LAUNCHER_CACHE: $COMPOSE_LAUNCHER_CACHE"
echo " SESSION_DIR: $SESSION_DIR"
echo " TZ_PATH: $TZ_PATH"
if [ -n "$ALL_RELATIONS" ]; then
echo " ALL_RELATIONS: $ALL_RELATIONS"
fi
}

10
bin/compose-core

@ -2548,6 +2548,11 @@ get_all_relations () {
local cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$@" "$(declare -p without_relations)")" \
services
if [ -n "$ALL_RELATIONS" ]; then
cat "$ALL_RELATIONS" || return 1
return 0
fi
if [ -e "${cache_file}" ]; then
#debug "$FUNCNAME: SESSION cache hit $1"
export ALL_RELATIONS="$cache_file"
@ -2899,6 +2904,11 @@ run_service_relations () {
# debug " Relations of ${DARKYELLOW}$subservice${NORMAL}:"
while read-0 relation_name target_service relation_config tech_dep; do
[ "${without_relations[$service:$relation_name]}" ] && {
debug "Skipping $DARKYELLOW$service$NORMAL --$DARKBLUE$relation_name$NORMAL--> $DARKYELLOW*$NORMAL"
continue
}
export relation_config
export TARGET_SERVICE_NAME=$target_service
MASTER_TARGET_SERVICE_NAME=$(get_top_master_service_for_service "$target_service") || return 1

Loading…
Cancel
Save