Files
computer-playbook/scripts/tests/deploy/swarm/11_assert_state.sh
T
kevinveenbirkenbachandClaude Opus 4.8 9994918f94 fix(swarm-test): make the in-container reachability probe curl-less
11_assert_state.sh and 09_seed_content.sh probed the rescheduled app with 'docker exec <ctr> curl', but images without curl (e.g. the official ollama/ollama, which still listens on :11434) made the probe fail though the server was up ('ollama not reachable after reschedule'). Fall back curl -> wget -> bash /dev/tcp connect, treating any HTTP response or open port as reachable; the curl path runs first and is unchanged for images that have it, so no regression.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 14:59:57 +02:00

59 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# shellcheck disable=SC1091
source "${SCRIPT_DIR}/_context.sh"
skip_if_no_swarm_service
skip_chaos_if_manager_pinned
REPL=""
for i in $(seq 1 60); do
REPL=$(docker exec "${MGR}" docker service ls \
--filter "name=${SERVICE_NAME}" --format '{{.Replicas}}')
echo "[${i}] ${ENTITY} replicas: ${REPL}"
if echo "${REPL}" | grep -qE '^([0-9]+)/\1$'; then
break
fi
sleep 2
done
echo "${REPL}" | grep -qE '^([0-9]+)/\1$' || {
echo "Replicas not fully converged: ${REPL}"
exit 1
}
if [ -n "${PRIMARY_NFS_VOLUME}" ]; then
docker exec "${NEW_NODE}" sh -c "
mkdir -p /mnt/nfs-check
mount -t nfs -o vers=3,nolock ${NFS_IP}:${NFS_EXPORT_BASE} /mnt/nfs-check
grep -q 'pre-drain marker' /mnt/nfs-check/${PRIMARY_NFS_VOLUME}/.pre-drain
umount /mnt/nfs-check
" || {
echo "FAILURE: marker missing on NFS volume '${PRIMARY_NFS_VOLUME}'"
exit 1
}
else
echo "No NFS-flagged volume for '${APP_ID}' — skipping NFS marker assertion"
fi
APP_CTR=$(docker exec "${NEW_NODE}" docker ps \
--filter "name=${SERVICE_NAME}" \
--format '{{.ID}}' | head -1)
if [ -z "${APP_CTR}" ]; then
echo "FAILURE: cannot locate ${ENTITY} container on ${NEW_NODE}"
exit 1
fi
for i in $(seq 1 30); do
# No -f: many app roots legitimately 404 (UI/API live elsewhere); we only
# assert the rescheduled HTTP server responds, not that '/' is 2xx.
if docker exec "${NEW_NODE}" docker exec "${APP_CTR}" sh -c \
"curl -sS http://localhost:${PROBE_PORT}/ || wget -qO- http://localhost:${PROBE_PORT}/ || bash -c 'exec 3<>/dev/tcp/localhost/${PROBE_PORT}'" >/dev/null 2>&1; then
echo "${ENTITY} reachable after reschedule"
exit 0
fi
sleep 2
done
echo "FAILURE: ${ENTITY} not reachable after reschedule"
exit 1