Source: immutable lab5 snapshot f88e9ba43cdfd7eb6a5a7ae5feb4247b4e820071; forward the allowed diff from 64d5c67. Carry SQLAlchemy, Alembic, reliability fixes, versioned jobs, infrastructure and student tests without changing protected coursework files. Validation: make check, validate, lint; 515 student tests passed with one Linux-only skip; public smoke with telemetry enabled and repeat migration passed. Stop the owned stack and retain volumes. Preserve the existing OTel work in progress; grade implementation remains a separate phase.
34 lines
1.4 KiB
Bash
Executable File
34 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
out=${EVIDENCE_DIR:-evidence}
|
|
mkdir -p "$out"
|
|
replicas() {
|
|
docker inspect -f '{{.Config.Hostname}} {{.State.Status}} started={{.State.StartedAt}} finished={{.State.FinishedAt}}' $(docker compose ps -aq "${API_SERVICE:-api}")
|
|
}
|
|
url=${1:-http://localhost:8080}
|
|
shift=0
|
|
while [ "$shift" -lt "${2:-0}" ]; do curl -fsS -o /dev/null "$url/health/live"; shift=$((shift + 1)); done
|
|
tmp="$out"/failover.tmp
|
|
since=$(date -u +%FT%TZ)
|
|
{
|
|
echo "date: $(date -u +%FT%TZ) commit: $(git rev-parse HEAD)"
|
|
echo "== before: api replicas (hostname = X-Instance-Id), state, StartedAt, FinishedAt"
|
|
replicas
|
|
echo "\$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh"
|
|
make --no-print-directory test-failover ACTION_SCRIPT=scripts/stop-one.sh BASE_URL="$url"
|
|
echo "== after: api replicas"
|
|
replicas
|
|
} > "$tmp" 2>&1
|
|
stopped=$(replicas | awk '$2 == "exited" {print $1}')
|
|
{
|
|
echo "== stopped replica: $stopped; shutdown: signal, drain window with readiness 503, close, exit"
|
|
docker logs --since "$since" "$stopped" 2>&1 | grep -E 'Handling signal|service.draining|"status":503|Shutting down|Waiting for conn|Finished server|service.stopped|SIGTERM' | tail -16
|
|
echo "\$ scripts/restore.sh"
|
|
scripts/restore.sh
|
|
echo "== after restore"
|
|
replicas
|
|
} >> "$tmp" 2>&1
|
|
mv "$tmp" "$out/failover-$stopped.txt"
|
|
cat "$out/failover-$stopped.txt"
|