forked from mtusi2026/mtusi2026lab6
Реализовать лабораторную 6: OpenTelemetry, Grafana, SLO и burn-rate alerts
- api и worker отдают traces, metrics и logs по OTLP в Collector (memory_limiter, redaction, batch, ограниченная очередь и retry); хранилища: Prometheus (OTLP receiver), Loki, Tempo; Grafana с provisioning datasources и dashboard «Messenger lab6» - W3C trace context через outbox и RabbitMQ: producer/consumer spans связывают upload, публикации и попытки worker в одном trace - SLO доступности API (SLI на HAProxy) и времени до ready, multiwindow burn-rate alerts, ApiHighErrorRate, JobQueueLagGrowing, DbPoolSaturated, TelemetryExportFailing; unit-тесты promtool, runbooks - кампания трека 2 (k6, 6 отказов по расписанию), разбор и графики; проверки сигналов и истории telemetry, evidence и REPORT.md
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
$ make check
|
||||
python3 scripts/check_contract.py
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
$ make validate PYTHON=.venv/bin/python
|
||||
.venv/bin/python scripts/validate_openapi.py
|
||||
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
|
||||
$ make test BASE_URL=http://localhost:8096
|
||||
python3 tests/smoke.py --base-url "http://localhost:8096"
|
||||
PASS: lab6 public API scenario; infrastructure and grading evidence remain separate.
|
||||
@@ -0,0 +1,11 @@
|
||||
# replicas before
|
||||
messenger-lab6-api-1 81757059610d running
|
||||
messenger-lab6-api-2 71ee4d68b6e6 running
|
||||
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh BASE_URL=http://localhost:8096
|
||||
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8096"
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 133, "failed_attempts": 0, "first_recovery_seconds": 2.942}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
# replicas after
|
||||
messenger-lab6-api-1 81757059610d running
|
||||
messenger-lab6-api-2 71ee4d68b6e6 exited
|
||||
@@ -0,0 +1,11 @@
|
||||
# replicas before (restored: docker compose start api)
|
||||
messenger-lab6-api-1 81757059610d running
|
||||
messenger-lab6-api-2 71ee4d68b6e6 running
|
||||
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh BASE_URL=http://localhost:8096
|
||||
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8096"
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 105, "failed_attempts": 0, "first_recovery_seconds": 4.884}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
# replicas after
|
||||
messenger-lab6-api-1 81757059610d exited
|
||||
messenger-lab6-api-2 71ee4d68b6e6 running
|
||||
@@ -0,0 +1,42 @@
|
||||
# before 2026-10-30T22:03:31Z
|
||||
messenger-lab6-api-1 running started=2026-10-30T22:03:13.16572903Z
|
||||
messenger-lab6-api-2 running started=2026-10-30T22:03:13.472982214Z
|
||||
messenger-lab6-grafana-1 running started=2026-10-30T21:27:12.963076303Z
|
||||
messenger-lab6-lb-1 running started=2026-10-30T21:27:49.144940174Z
|
||||
messenger-lab6-loki-1 running started=2026-10-30T21:49:05.434203985Z
|
||||
messenger-lab6-migrate-1 exited started=2026-10-30T22:03:25.18357094Z
|
||||
messenger-lab6-otel-collector-1 running started=2026-10-30T21:49:04.841388966Z
|
||||
messenger-lab6-postgres-1 running started=2026-10-30T21:27:02.601334894Z
|
||||
messenger-lab6-prometheus-1 running started=2026-10-30T21:27:02.373327049Z
|
||||
messenger-lab6-rabbitmq-1 running started=2026-10-30T22:03:17.333799174Z
|
||||
messenger-lab6-reconciler-1 running started=2026-10-30T22:02:04.211864462Z
|
||||
messenger-lab6-s3-1 running started=2026-10-30T21:27:38.005413897Z
|
||||
messenger-lab6-s3-init-1 exited started=2026-10-30T22:03:25.701746746Z
|
||||
messenger-lab6-seaweedfs-1 running started=2026-10-30T21:27:22.289141705Z
|
||||
messenger-lab6-tempo-1 running started=2026-10-30T21:49:05.133731622Z
|
||||
messenger-lab6-worker-1 running started=2026-10-30T22:03:29.390180094Z
|
||||
messenger-lab6-worker-2 running started=2026-10-30T22:03:29.566901411Z
|
||||
|
||||
$ make test-persistence ACTION_SCRIPT=scripts/restart.sh BASE_URL=http://localhost:8096
|
||||
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost:8096"
|
||||
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
|
||||
# after 2026-10-30T22:04:27Z
|
||||
messenger-lab6-api-1 running started=2026-10-30T22:04:21.157055064Z
|
||||
messenger-lab6-api-2 running started=2026-10-30T22:04:20.940382017Z
|
||||
messenger-lab6-grafana-1 running started=2026-10-30T22:03:48.451183698Z
|
||||
messenger-lab6-lb-1 running started=2026-10-30T22:04:26.884395625Z
|
||||
messenger-lab6-loki-1 running started=2026-10-30T22:03:39.035816792Z
|
||||
messenger-lab6-migrate-1 exited started=2026-10-30T22:04:18.354473742Z
|
||||
messenger-lab6-otel-collector-1 running started=2026-10-30T22:03:39.13142939Z
|
||||
messenger-lab6-postgres-1 running started=2026-10-30T22:03:38.38063198Z
|
||||
messenger-lab6-prometheus-1 running started=2026-10-30T22:03:38.109558741Z
|
||||
messenger-lab6-rabbitmq-1 running started=2026-10-30T22:03:39.316004195Z
|
||||
messenger-lab6-reconciler-1 running started=2026-10-30T22:04:20.936750026Z
|
||||
messenger-lab6-s3-1 running started=2026-10-30T22:04:17.090338152Z
|
||||
messenger-lab6-s3-init-1 exited started=2026-10-30T22:04:19.79217583Z
|
||||
messenger-lab6-seaweedfs-1 running started=2026-10-30T22:03:57.426716035Z
|
||||
messenger-lab6-tempo-1 running started=2026-10-30T22:03:38.291222478Z
|
||||
messenger-lab6-worker-1 running started=2026-10-30T22:04:20.931270603Z
|
||||
messenger-lab6-worker-2 running started=2026-10-30T22:04:21.103570215Z
|
||||
@@ -0,0 +1,30 @@
|
||||
$ scripts/check-s3-security.sh
|
||||
PASS анонимный GET объекта: 403
|
||||
PASS анонимный LIST bucket: 403
|
||||
PASS анонимный PUT объекта: 403
|
||||
api GetObject own bucket: allowed
|
||||
api ListObjectsV2 own bucket: denied (403 AccessDenied)
|
||||
api CreateBucket other: denied (403 AccessDenied)
|
||||
api PutObject other bucket: denied (403 AccessDenied)
|
||||
api PutObject own bucket: allowed
|
||||
api DeleteObject own bucket: allowed
|
||||
reconciler GetObject own bucket: allowed
|
||||
reconciler ListObjectsV2 own bucket: allowed
|
||||
reconciler CreateBucket other: denied (403 AccessDenied)
|
||||
reconciler PutObject other bucket: denied (403 AccessDenied)
|
||||
reconciler PutObject own bucket: allowed
|
||||
reconciler DeleteObject own bucket: allowed
|
||||
PASS api GetObject: allowed
|
||||
PASS api ListObjectsV2 (не нужен API): denied
|
||||
PASS api CreateBucket: denied
|
||||
PASS api PutObject в чужой bucket: denied
|
||||
PASS reconciler ListObjectsV2: allowed
|
||||
PASS reconciler CreateBucket: denied
|
||||
PASS seaweedfs:8888 из контейнера api: unreachable
|
||||
PASS seaweedfs:9333 из контейнера api: unreachable
|
||||
PASS seaweedfs:8080 из контейнера api: unreachable
|
||||
PASS filer по IP 192.168.228.2:8888 из контейнера api: unreachable
|
||||
PASS сервисы с опубликованными портами: grafana lb
|
||||
PASS повторный s3-init: bucket messenger-attachments: exists
|
||||
PASS: bucket приватен, права минимальны, внутренние порты закрыты
|
||||
exit=0
|
||||
@@ -0,0 +1,3 @@
|
||||
$ make test BASE_URL=http://localhost:8096
|
||||
python3 tests/smoke.py --base-url "http://localhost:8096"
|
||||
PASS: lab6 public API scenario; infrastructure and grading evidence remain separate.
|
||||
@@ -0,0 +1,2 @@
|
||||
$ python3 student-tests/telemetry_history.py --grafana http://localhost:3096 --trace-id 8fc9d84548b361b4a5bb788aff701bed --before 1793397811 # trace из telemetry-check.txt, записан до restart.sh (2026-10-30T22:03:31Z)
|
||||
PASS история после перезапуска: trace 8fc9d84548b361b4a5bb788aff701bed (7 spans), 1 строк лога, 11 точек метрики API за 10 мин до перезапуска
|
||||
@@ -0,0 +1,14 @@
|
||||
$ python3 student-tests/worker_outage.py --base-url http://localhost:8096
|
||||
0.8 s docker compose stop worker
|
||||
0.9 s upload → 202 queued, attachment 5f65a400-9b2d-4582-be38-793474813edf
|
||||
0.9 s сообщение с queued-вложением → 201, message 5cdc6020-756a-433c-9cb1-63e3068a8d78
|
||||
0.9 s content и content?variant=thumbnail → 409 conflict
|
||||
1.0 s другие сообщения без worker: POST 201, история 200
|
||||
4.7 s job 164346fb-f5a9-41a5-af9e-13039146884a queued attempts=0; outbox опубликован (publisher confirm); очередь (messages, unacked, consumers) = (0, 0, 2)
|
||||
9.2 s docker compose restart api (обе реплики, SIGTERM)
|
||||
19.1 s docker compose restart rabbitmq; после рестарта очередь = (1, 0, 0)
|
||||
19.2 s вложение после рестартов: queued (прежний токен)
|
||||
24.4 s docker compose start worker
|
||||
25.8 s ready через 1.3 s после старта worker; job: done attempts=1
|
||||
25.9 s thumbnail 256x160 JPEG (sha256 = метаданным), оригинал совпадает побайтно; варианты: crop 128x128, optimized 320x200, thumbnail 256x160
|
||||
PASS: job accepted while worker was down survived API + broker restart and reached ready
|
||||
Reference in New Issue
Block a user