136 lines
6.2 KiB
Plaintext
136 lines
6.2 KiB
Plaintext
# Отказы зависимостей, ошибки LB, expiry
|
|
# date: 2026-11-01T14:57:16Z
|
|
# commit: 252ebd0
|
|
|
|
## 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:57:17.123Z
|
|
GET /api/v1/users/me -> 200
|
|
DELETE /api/v1/auth/sessions/current -> 503 {"error": {"code": "unavailable", "message": "session cache unavailable", "request_id": "98fedb58-4eb5-4e13-a7cb-e6469a78d258"}}
|
|
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:57:21.659Z
|
|
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": "0ff1f01f-8cd5-40f7-b590-02e64814442f"}}
|
|
|
|
$ 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": "3bbc22fc-5459-4c57-af1f-d63e72844729"}}
|
|
|
|
$ 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-13 Stopping
|
|
Container messenger-lab3-api-14 Stopping
|
|
Container messenger-lab3-api-14 Stopped
|
|
Container messenger-lab3-api-13 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": "1f889229-367b-4fa7-8ca1-2c1cda2dce86"}}
|
|
|
|
$ 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-14 Starting
|
|
Container messenger-lab3-api-14 Started
|
|
Container messenger-lab3-api-13 Starting
|
|
Container messenger-lab3-api-13 Started
|
|
|
|
$ python3 scripts/probe.py ready
|
|
ready
|
|
|
|
## 5. Живая, но неготовая реплика: PostgreSQL отклоняет подключения только от одной API (pg_hba reject)
|
|
target=dfa1f6b6a59a ip=172.25.0.6
|
|
$ docker exec dfa1f6b6a59a 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:57:47.146Z
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 358dc1d93af4
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 358dc1d93af4
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 358dc1d93af4
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 358dc1d93af4
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 358dc1d93af4
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 358dc1d93af4
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 358dc1d93af4
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 358dc1d93af4
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 358dc1d93af4
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 358dc1d93af4
|
|
|
|
Server api/api1 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: 6ms. 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:57:52.149Z
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 358dc1d93af4
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: dfa1f6b6a59a
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 358dc1d93af4
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: dfa1f6b6a59a
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: 358dc1d93af4
|
|
GET /api/v1/users/me -> 200 X-Instance-Id: dfa1f6b6a59a
|
|
|
|
## 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:58:04.884Z
|
|
GET /api/v1/users/me (fresh) -> 200
|
|
GET /api/v1/users/me (after 3s) -> 401
|
|
|
|
$ python3 scripts/probe.py ready
|
|
ready
|
|
|