fix(infra): fix sequential phase gap + add phase 7 guards

1. last_completed_phase now stops at first gap — prevents --resume from
   skipping phases when --phase=N created non-sequential markers
2. Phase 7 fails early if .env.ecosystem is missing (points to --phase=6)
3. Warns if compose config JSON cache fails — graceful degradation
This commit is contained in:
saravanakumardb1 2026-03-24 12:17:45 -07:00
parent a9414218ba
commit a3f4c6facf

View File

@ -99,7 +99,8 @@ is_phase_done() {
last_completed_phase() {
local last=0
for i in 1 2 3 4 5 6 7 8; do
is_phase_done "$i" && last=$i
# Stop at first gap — phases must be sequential
is_phase_done "$i" && last=$i || break
done
echo "$last"
}
@ -564,6 +565,11 @@ phase7_deploy() {
setup_compose_env
local plat_dir="${INSTALL_DIR}/learning_ai_common_plat"
# Guard: .env.ecosystem must exist (created by phase 6)
if [ ! -f "${plat_dir}/.env.ecosystem" ]; then
fail "Missing ${plat_dir}/.env.ecosystem — run phase 6 first: sudo ./setup.sh --phase=6"
fi
local build_ok=() build_fail=() build_skip=()
mkdir -p "${STATE_DIR}/builds"
@ -580,6 +586,11 @@ phase7_deploy() {
compose_json=$(docker compose -f "${plat_dir}/${COMPOSE_FILE}" \
--env-file "${plat_dir}/.env.ecosystem" config --format json 2>/dev/null || true)
if [ -z "$compose_json" ]; then
warn " Could not parse compose config (docker compose config --format json failed)."
warn " Per-service build detection disabled — all services will attempt to build."
fi
for svc in "${all_services[@]}"; do
idx=$((idx + 1))