forked from mtusi2026/mtusi2026lab3
136 lines
6.2 KiB
Plaintext
136 lines
6.2 KiB
Plaintext
# Отказы зависимостей, ошибки LB, expiry
|
|
# date: 2026-11-01T14:27:40Z
|
|
# commit: 210ff67 (dirty)
|
|
|
|
## 1. Redis остановлен: вход и Bearer через PostgreSQL; logout — 503 без отзыва (токен остаётся действующим)
|
|
$ docker compose stop redis
|
|
Container messenger-lab3-redis-1 Stopping
|
|
Container messenger-lab3-redis-1 Stopped
|
|
|
|
$ python3 scripts/probe.py logout
|
|
register -> 201
|
|
login -> 201 expires_at: 2026-11-01T15:27:41.083Z
|
|
GET /api/v1/users/me -> 200
|
|
DELETE /api/v1/auth/sessions/current -> 503 {"error": {"code": "unavailable", "message": "session cache unavailable", "request_id": "7aff0b0d-d263-4bad-ae24-534ed11e5885"}}
|
|
GET /api/v1/users/me -> 200
|
|
|
|
$ docker compose start redis
|
|
Container messenger-lab3-secrets-init-1 Starting
|
|
Container messenger-lab3-secrets-init-1 Started
|
|
Container messenger-lab3-secrets-init-1 Waiting
|
|
Container messenger-lab3-secrets-init-1 Exited
|
|
Container messenger-lab3-redis-1 Starting
|
|
Container messenger-lab3-redis-1 Started
|
|
|
|
## 2. Redis снова доступен: logout отзывает токен на всех репликах
|
|
$ python3 scripts/probe.py logout
|
|
register -> 201
|
|
login -> 201 expires_at: 2026-11-01T15:27:46.084Z
|
|
GET /api/v1/users/me -> 200
|
|
DELETE /api/v1/auth/sessions/current -> 204
|
|
GET /api/v1/users/me -> 401
|
|
|
|
## 3. PostgreSQL остановлен: live 200, запрос с токеном — 503 без внутренних деталей, аноним — 401
|
|
$ docker compose stop postgres
|
|
Container messenger-lab3-postgres-1 Stopping
|
|
Container messenger-lab3-postgres-1 Stopped
|
|
|
|
$ python3 scripts/probe.py status GET /health/live
|
|
GET /health/live (anonymous) -> 200 {"status": "ok"}
|
|
|
|
$ python3 scripts/probe.py status GET /api/v1/chats Bearer unknown-token
|
|
GET /api/v1/chats (Bearer unknown-token) -> 503 {"error": {"code": "unavailable", "message": "database unavailable", "request_id": "084e5aa0-f8c4-44c2-91a6-5672ab0fe7f9"}}
|
|
|
|
$ python3 scripts/probe.py status GET /api/v1/users/me
|
|
GET /api/v1/users/me (anonymous) -> 503 {"error": {"code": "unavailable", "message": "no API replica available", "request_id": "f041cada-528c-4d13-bf1e-fefc33ec422e"}}
|
|
|
|
$ docker compose start postgres
|
|
Container messenger-lab3-secrets-init-1 Starting
|
|
Container messenger-lab3-secrets-init-1 Started
|
|
Container messenger-lab3-secrets-init-1 Waiting
|
|
Container messenger-lab3-secrets-init-1 Exited
|
|
Container messenger-lab3-postgres-1 Starting
|
|
Container messenger-lab3-postgres-1 Started
|
|
|
|
$ python3 scripts/probe.py ready
|
|
ready
|
|
|
|
## 4. Все реплики API остановлены: LB отвечает 503 в формате ошибки контракта
|
|
$ docker compose stop api
|
|
Container messenger-lab3-api-11 Stopping
|
|
Container messenger-lab3-api-12 Stopping
|
|
Container messenger-lab3-api-12 Stopped
|
|
Container messenger-lab3-api-11 Stopped
|
|
|
|
$ python3 scripts/probe.py status GET /api/v1/users/me
|
|
GET /api/v1/users/me (anonymous) -> 503 {"error": {"code": "unavailable", "message": "no API replica available", "request_id": "4e1d1184-174b-47c6-9406-6d5e3e7457de"}}
|
|
|
|
$ docker compose start api
|
|
Container messenger-lab3-secrets-init-1 Starting
|
|
Container messenger-lab3-secrets-init-1 Started
|
|
Container messenger-lab3-secrets-init-1 Waiting
|
|
Container messenger-lab3-secrets-init-1 Waiting
|
|
Container messenger-lab3-secrets-init-1 Exited
|
|
Container messenger-lab3-secrets-init-1 Exited
|
|
Container messenger-lab3-postgres-1 Waiting
|
|
Container messenger-lab3-postgres-1 Healthy
|
|
Container messenger-lab3-migrate-1 Starting
|
|
Container messenger-lab3-migrate-1 Started
|
|
Container messenger-lab3-migrate-1 Waiting
|
|
Container messenger-lab3-migrate-1 Exited
|
|
Container messenger-lab3-api-12 Starting
|
|
Container messenger-lab3-api-12 Started
|
|
Container messenger-lab3-api-11 Starting
|
|
Container messenger-lab3-api-11 Started
|
|
|
|
$ python3 scripts/probe.py ready
|
|
ready
|
|
|
|
## 5. Живая, но неготовая реплика: PostgreSQL отклоняет подключения только от одной API (pg_hba reject)
|
|
target=b446d5242566 ip=172.25.0.6
|
|
$ docker exec b446d5242566 node -e let n=0;const g=p=>require('http').get('http://127.0.0.1:8080'+p,r=>{console.log(p,r.statusCode);r.resume();if(++n===2)process.exit(0)});g('/health/live');g('/health/ready')
|
|
/health/live 200
|
|
/health/ready 503
|
|
|
|
$ python3 scripts/probe.py instances 10
|
|
register -> 201
|
|
login -> 201 expires_at: 2026-11-01T15:28:12.845Z
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 18dde5d7e3c7
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 18dde5d7e3c7
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 18dde5d7e3c7
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 18dde5d7e3c7
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 18dde5d7e3c7
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 18dde5d7e3c7
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 18dde5d7e3c7
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 18dde5d7e3c7
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 18dde5d7e3c7
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 18dde5d7e3c7
|
|
|
|
Server api/api2 is UP, reason: Layer7 check passed, code: 200, check duration: 2ms. 2 active and 0 backup servers online. 0 sessions requeued, 0 total in queue.
|
|
Server api/api2 is DOWN, reason: Layer7 wrong status, code: 503, info: "Service Unavailable", check duration: 4ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
|
|
|
|
### доступ возвращён: реплика снова готова и получает запросы
|
|
$ python3 scripts/probe.py instances 6
|
|
register -> 201
|
|
login -> 201 expires_at: 2026-11-01T15:28:17.742Z
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 18dde5d7e3c7
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: b446d5242566
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 18dde5d7e3c7
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: b446d5242566
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 18dde5d7e3c7
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: b446d5242566
|
|
|
|
## 6. Expiry: реплики пересозданы с SESSION_TTL_SECONDS=2
|
|
$ sh -c docker exec $(docker compose ps -q api | head -1) printenv SESSION_TTL_SECONDS
|
|
2
|
|
|
|
$ python3 scripts/probe.py expiry 2
|
|
register -> 201
|
|
login -> 201 expires_at: 2026-11-01T14:28:30.603Z
|
|
GET /api/v1/users/me (fresh) -> 200
|
|
GET /api/v1/users/me (after 3s) -> 401
|
|
|
|
$ python3 scripts/probe.py ready
|
|
ready
|
|
|