feat(lab3): HAProxy LB, stateless API replicas, X-Instance-Id, Idempotency-Key, Grade 5 Track 1

This commit is contained in:
2026-11-17 02:34:05 +03:00
parent 0ab3a341aa
commit 40fa0fe23f
29 changed files with 6835 additions and 21 deletions
+25
View File
@@ -0,0 +1,25 @@
#!/bin/sh
set -eu
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
ROOT_DIR=$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)
cd "$ROOT_DIR"
TARGET_CID=""
for cid in $(docker compose --env-file .env ps -q api); do
short_id=$(printf '%s' "$cid" | cut -c1-12)
hostname_val=$(docker inspect -f '{{.Config.Hostname}}' "$cid" 2>/dev/null || true)
if [ "$short_id" = "$TARGET_INSTANCE_ID" ] || [ "$cid" = "$TARGET_INSTANCE_ID" ] || [ "$hostname_val" = "$TARGET_INSTANCE_ID" ]; then
TARGET_CID="$cid"
break
fi
done
if [ -z "$TARGET_CID" ]; then
printf 'API container matching X-Instance-Id=%s not found\n' "$TARGET_INSTANCE_ID" >&2
exit 1
fi
docker stop -t 5 "$TARGET_CID" >/dev/null