forked from mtusi2026/mtusi2026lab3
Лаба 3: Nginx LB, 2 реплики API и общая идемпотентность (оценка 4)
Переиспользован стек lab2 (Postgres/Redis/Argon2id). Добавлены: Nginx балансировщик перед api1/api2, общая идемпотентность POST-сообщений (idempotency_keys + advisory-lock сериализация в Postgres), explicit stop-one/restart hooks. make test/test-persistence/test-failover/validate зелёные для обеих реплик; найдены и исправлены гонка миграций и гонка рестарта Nginx/DNS — см. REPORT.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
# Restarts the whole stack (LB, both API replicas, PostgreSQL, Redis) without touching volumes.
|
||||
cd "$(dirname "$0")/.."
|
||||
# Sequenced on purpose: nginx resolves upstream hostnames only at startup, so it
|
||||
# must come back strictly after api1/api2 are reachable again, not in parallel.
|
||||
docker compose restart postgres redis
|
||||
docker compose restart api1 api2
|
||||
docker compose restart lb
|
||||
exit 0
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
# Stops exactly the API replica identified by TARGET_INSTANCE_ID (api1 or api2),
|
||||
# leaving it stopped. The other replica keeps serving traffic through the LB.
|
||||
cd "$(dirname "$0")/.."
|
||||
: "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID must be set by the test harness}"
|
||||
case "$TARGET_INSTANCE_ID" in
|
||||
api1|api2) ;;
|
||||
*) echo "unknown instance id: $TARGET_INSTANCE_ID" >&2; exit 1 ;;
|
||||
esac
|
||||
docker compose stop "$TARGET_INSTANCE_ID"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user