Verify and archive lab4 grade three on SQLAlchemy

This commit is contained in:
Artyom
2026-11-06 02:00:43 +03:00
parent 763b025557
commit 02f385866f
39 changed files with 1719 additions and 5 deletions
@@ -0,0 +1,26 @@
# Уровень 3: SQLAlchemy, 2026-11-06
Код приложения/стенда: 8e4532f6f5c05d902b6e2c310f54320d95585904; перенос из immutable
f591fa64e525679a31c9db7f942d36c789e1a12f. Обвязка: 1aec062aba4560b51a6d9155571c9610bc777d7e
и 763b0255575366082c4c6731b54611af717685a5. Полные команды, UTC и SHA — в raw *.txt.
UTC 5 ноября соответствует 6 ноября MSK. Проект hlpipe-lab4-grades-20261106 создан
со свежими volumes; API 18084, stats 24844; NO_PROXY указан в каждом захвате.
| Критерий README | Команда / файл | Наблюдение |
| --- | --- | --- |
| Минимум ЛР3 | make test, smoke.txt; probe.py check/retry, lb-check-rerun.txt/retry.txt | PASS; один токен на двух репликах; 20×8 записей с одним ключом, одна копия; потеря ответа и kill сохраняют идемпотентность |
| PostgreSQL metadata, приватный RustFS, без состояния API | evidence-attachments.sh, storage-layout.txt; evidence-stack.sh, stack.txt; limits.py, limits.txt | metadata без байтов изображения; внешняя сверка SHA и размера; API read-only без data volumes, только LB публикует порты |
| 201 ready, download, attachment_ids, чужому 404 | make test; negative-files.txt | checksum совпал, сообщения с вложениями читаются участником; чужие id/чаты 404 |
| PNG/JPEG, 10 MiB, 40 MP, MIME, filename | pytest -k user_errors, negative-files.txt | 1 passed; 53 ответа, 0 ответов 5xx; граничные и опасные файлы отклонены |
| upload → stop обслужившей реплики → download | lab4_scenarios.py failover-upload, failover-upload.json | SHA совпал, target f2e1260f6803 exited, сосед cff4a17e0883 running |
| Restart с volumes | persistence-evidence.sh, persistence.txt | PASS; StartedAt изменился у API/LB/PG/Valkey/S3, данные и сессия сохранены |
| Failover | failover-evidence.sh, failover.txt | 133 успешные записи, 0 failed_attempts; target exited, drain и readiness 503 в логах |
| S3 outage | lab4_scenarios.py s3-outage ×3, s3-outage-{1,2,3}.json | upload 503: 0,828–5,039 с; download 503: 0,510–1,397 с; все <6 с; тексты 201; восстановленные байты совпали |
| Bucket private и bootstrap | s3-check.sh, s3-security.txt | 31 PASS, RESULT PASS; anonymous HTTP GET 403; API ListBucket запрещён; повторный bootstrap неизменен |
| Проверки исходников | checks.txt, student-tests.txt | check/validate/lint PASS, 404 passed / 19 deselected |
lb-check.txt сохраняет неуспешную попытку запуска: неподдерживаемый --base-url, exit 2.
Исправлена только команда (BASE_URL в окружении), успешный повтор — lb-check-rerun.txt.
Сценарий S3 первого повтора запущен до усиления exit-code проверки; все его фактические
статусы и времена также удовлетворяют проверке. Изменялся проверяющий скрипт, не API.
Старые данные evidence/ не используются как доказательство перенесённого кода.
@@ -0,0 +1,14 @@
date: 2026-11-05T22:54:42Z commit: 1aec062aba4560b51a6d9155571c9610bc777d7e
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ make check validate lint
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
.venv/bin/python scripts/validate_openapi.py
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
.venv/bin/ruff check src student-tests scripts/capture_evidence.py alembic scripts/scaling.py tools scripts/probe.py scripts/limits.py scripts/lab4_scenarios.py scripts/lab4_seed.py scripts/upload_memory.py scripts/reconcile_check.py scripts/reconcile_track.py
All checks passed!
.venv/bin/ruff format --check src student-tests scripts/capture_evidence.py alembic scripts/scaling.py tools scripts/probe.py scripts/limits.py scripts/lab4_scenarios.py scripts/lab4_seed.py scripts/upload_memory.py scripts/reconcile_check.py scripts/reconcile_track.py
153 files already formatted
.venv/bin/ty check src student-tests alembic
All checks passed!
exit_code: 0 elapsed_seconds: 0.540
@@ -0,0 +1,43 @@
date: 2026-11-05T22:59:49Z commit: 763b0255575366082c4c6731b54611af717685a5
host: Apple M4 Max, 16 CPU, 48 GiB RAM, macOS 15.1
docker: 28.3.2, VM: 16 CPU, 8217190400 bytes
compose: 2.38.2-desktop.1
images:
image: ${API_IMAGE:-mtusi-messenger:${COMPOSE_PROJECT_NAME}}
image: rustfs/rc:v0.1.36@sha256:ab024bfebee49a750ce886b4c70963ccd9ddaa03f491704a90710641d7a26699
image: haproxy:3.2.26-alpine@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b
image: postgres:17.11-alpine@sha256:266d3c257594e195b309ae9d1805e54c788f1d7b375f56bf6c367aac6c917e7b
image: valkey/valkey:8.1.11-alpine@sha256:2602ace2be6569bc2bbb06f873776516ab9089821525be34f4305c67eb9db02a
image: rustfs/rustfs:1.0.4@sha256:ed9210d6411d77ffceb70d94b964a3cb7d225983368bc25bebe01e995293dcc2
image: grafana/k6:2.3.0@sha256:2dd4756ec6e14e62778916e1eb850108e4b499304c02df56760fa0bdb0fba0b8
FROM python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d AS builder
COPY --from=ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142 /uv /usr/local/bin/uv
FROM python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d AS runtime
python in image: Python 3.14.7
haproxy: HAProxy version 3.2.26-3e0f11a 2026/10/14 - https://haproxy.org/
rustfs: rustfs 1.0.4
packages (uv.lock):
fastapi 0.141.1
uvicorn 0.54.0
uvicorn-worker 0.4.0
gunicorn 26.2.0
sqlalchemy 2.0.45
alembic 1.16.5
asyncpg 0.32.0
argon2-cffi 25.1.0
pydantic 2.13.5
pydantic-settings 2.15.0
dishka 1.10.1
structlog 26.1.0
redis 8.1.0
aiobotocore 3.10.0
botocore 1.43.117
aiohttp 3.14.5
pillow 13.0.0
process users (service uid command):
api 10001 python
lb 99 haproxy
postgres 70 postgres
s3 10001 rustfs
valkey 999 tini
valkey 999 valkey-server
@@ -0,0 +1,39 @@
date: 2026-11-05T22:58:34Z commit: 1aec062aba4560b51a6d9155571c9610bc777d7e
== before: api replicas (hostname = X-Instance-Id), state, StartedAt, FinishedAt
cff4a17e0883 running started=2026-11-05T22:58:30.83452755Z finished=2026-11-05T22:58:24.503577672Z
f2e1260f6803 running started=2026-11-05T22:58:30.769256883Z finished=2026-11-05T22:58:24.505784755Z
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://127.0.0.1:18084"
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.826}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
== after: api replicas
cff4a17e0883 running started=2026-11-05T22:58:30.83452755Z finished=2026-11-05T22:58:24.503577672Z
f2e1260f6803 exited started=2026-11-05T22:58:30.769256883Z finished=2026-11-05T22:58:37.544193511Z
== stopped replica: f2e1260f6803; shutdown: signal, drain window with readiness 503, close, exit
{"event":"Handling signal: term","level":"info","ts":"2026-11-05T22:58:35.049678Z"}
{"limit":2.0,"event":"service.draining","level":"info","ts":"2026-11-05T22:58:35.051721Z"}
{"limit":2.0,"event":"service.draining","level":"info","ts":"2026-11-05T22:58:35.108386Z"}
{"method":"GET","route":"/health/ready","status":503,"request_id":"187f845e94a643fcb766377e2e260da0","duration_ms":0.62,"event":"request.handled","level":"info","ts":"2026-11-05T22:58:36.012021Z"}
{"method":"GET","route":"/health/ready","status":503,"request_id":"9e0cd8cdc6184fce8f9af5735cffb8f3","duration_ms":1.317,"event":"request.handled","level":"info","ts":"2026-11-05T22:58:36.521518Z"}
{"method":"GET","route":"/health/ready","status":503,"request_id":"55e0a45cd1e9478cb8203bb6cbfe0da1","duration_ms":49.175,"event":"request.handled","level":"info","ts":"2026-11-05T22:58:37.045066Z"}
{"event":"Shutting down","level":"info","ts":"2026-11-05T22:58:37.055403Z"}
{"event":"Shutting down","level":"info","ts":"2026-11-05T22:58:37.110223Z"}
{"event":"service.stopped","level":"info","ts":"2026-11-05T22:58:37.157015Z"}
{"event":"Finished server process [19]","level":"info","ts":"2026-11-05T22:58:37.157139Z"}
{"event":"Worker (pid:19) was sent SIGTERM!","level":"info","ts":"2026-11-05T22:58:37.207794Z"}
{"event":"service.stopped","level":"info","ts":"2026-11-05T22:58:37.213602Z"}
{"event":"Finished server process [20]","level":"info","ts":"2026-11-05T22:58:37.213742Z"}
{"event":"Worker (pid:20) was sent SIGTERM!","level":"info","ts":"2026-11-05T22:58:37.308719Z"}
{"event":"Shutting down: Master","level":"info","ts":"2026-11-05T22:58:37.414643Z"}
$ scripts/restore.sh
Container hlpipe-lab4-grades-20261106-api-1 Running
Container hlpipe-lab4-grades-20261106-api-2 Starting
Container hlpipe-lab4-grades-20261106-api-2 Started
Container hlpipe-lab4-grades-20261106-api-2 Waiting
Container hlpipe-lab4-grades-20261106-api-1 Waiting
Container hlpipe-lab4-grades-20261106-api-2 Healthy
Container hlpipe-lab4-grades-20261106-api-1 Healthy
== after restore
cff4a17e0883 running started=2026-11-05T22:58:30.83452755Z finished=2026-11-05T22:58:24.503577672Z
f2e1260f6803 running started=2026-11-05T22:58:50.474934128Z finished=2026-11-05T22:58:37.544193511Z
@@ -0,0 +1,44 @@
{
"ok": true,
"date": "2026-11-05T22:58:52Z",
"commit": "1aec062aba4560b51a6d9155571c9610bc777d7e",
"scenario": "failover-upload",
"upload_instance": "f2e1260f6803",
"download_instance": "cff4a17e0883",
"sha256_equal": true,
"hook_seconds": 2.746,
"download_ok_after_seconds": 2.796,
"replicas_at_download": [
{
"hostname": "cff4a17e0883",
"status": "running",
"exit_code": "0",
"started_at": "2026-11-05T22:58:30.83452755Z",
"finished_at": "2026-11-05T22:58:24.503577672Z"
},
{
"hostname": "f2e1260f6803",
"status": "exited",
"exit_code": "0",
"started_at": "2026-11-05T22:58:50.474934128Z",
"finished_at": "2026-11-05T22:58:55.457412714Z"
}
],
"restored": true,
"replicas_after_restore": [
{
"hostname": "cff4a17e0883",
"status": "running",
"exit_code": "0",
"started_at": "2026-11-05T22:58:30.83452755Z",
"finished_at": "2026-11-05T22:58:24.503577672Z"
},
{
"hostname": "f2e1260f6803",
"status": "running",
"exit_code": "0",
"started_at": "2026-11-05T22:58:55.870420297Z",
"finished_at": "2026-11-05T22:58:55.457412714Z"
}
]
}
@@ -0,0 +1,48 @@
date: 2026-11-05T22:58:52Z commit: 1aec062aba4560b51a6d9155571c9610bc777d7e
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ python3 scripts/lab4_scenarios.py failover-upload --base-url http://127.0.0.1:18084 --restore --output evidence/sqlalchemy-2026-11-06/grade3/failover-upload.json
{
"ok": true,
"date": "2026-11-05T22:58:52Z",
"commit": "1aec062aba4560b51a6d9155571c9610bc777d7e",
"scenario": "failover-upload",
"upload_instance": "f2e1260f6803",
"download_instance": "cff4a17e0883",
"sha256_equal": true,
"hook_seconds": 2.746,
"download_ok_after_seconds": 2.796,
"replicas_at_download": [
{
"hostname": "cff4a17e0883",
"status": "running",
"exit_code": "0",
"started_at": "2026-11-05T22:58:30.83452755Z",
"finished_at": "2026-11-05T22:58:24.503577672Z"
},
{
"hostname": "f2e1260f6803",
"status": "exited",
"exit_code": "0",
"started_at": "2026-11-05T22:58:50.474934128Z",
"finished_at": "2026-11-05T22:58:55.457412714Z"
}
],
"restored": true,
"replicas_after_restore": [
{
"hostname": "cff4a17e0883",
"status": "running",
"exit_code": "0",
"started_at": "2026-11-05T22:58:30.83452755Z",
"finished_at": "2026-11-05T22:58:24.503577672Z"
},
{
"hostname": "f2e1260f6803",
"status": "running",
"exit_code": "0",
"started_at": "2026-11-05T22:58:55.870420297Z",
"finished_at": "2026-11-05T22:58:55.457412714Z"
}
]
}
exit_code: 0 elapsed_seconds: 4.574
@@ -0,0 +1,43 @@
date: 2026-11-05T22:58:34Z commit: 1aec062aba4560b51a6d9155571c9610bc777d7e
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ sh scripts/failover-evidence.sh http://127.0.0.1:18084 0
date: 2026-11-05T22:58:34Z commit: 1aec062aba4560b51a6d9155571c9610bc777d7e
== before: api replicas (hostname = X-Instance-Id), state, StartedAt, FinishedAt
cff4a17e0883 running started=2026-11-05T22:58:30.83452755Z finished=2026-11-05T22:58:24.503577672Z
f2e1260f6803 running started=2026-11-05T22:58:30.769256883Z finished=2026-11-05T22:58:24.505784755Z
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://127.0.0.1:18084"
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.826}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
== after: api replicas
cff4a17e0883 running started=2026-11-05T22:58:30.83452755Z finished=2026-11-05T22:58:24.503577672Z
f2e1260f6803 exited started=2026-11-05T22:58:30.769256883Z finished=2026-11-05T22:58:37.544193511Z
== stopped replica: f2e1260f6803; shutdown: signal, drain window with readiness 503, close, exit
{"event":"Handling signal: term","level":"info","ts":"2026-11-05T22:58:35.049678Z"}
{"limit":2.0,"event":"service.draining","level":"info","ts":"2026-11-05T22:58:35.051721Z"}
{"limit":2.0,"event":"service.draining","level":"info","ts":"2026-11-05T22:58:35.108386Z"}
{"method":"GET","route":"/health/ready","status":503,"request_id":"187f845e94a643fcb766377e2e260da0","duration_ms":0.62,"event":"request.handled","level":"info","ts":"2026-11-05T22:58:36.012021Z"}
{"method":"GET","route":"/health/ready","status":503,"request_id":"9e0cd8cdc6184fce8f9af5735cffb8f3","duration_ms":1.317,"event":"request.handled","level":"info","ts":"2026-11-05T22:58:36.521518Z"}
{"method":"GET","route":"/health/ready","status":503,"request_id":"55e0a45cd1e9478cb8203bb6cbfe0da1","duration_ms":49.175,"event":"request.handled","level":"info","ts":"2026-11-05T22:58:37.045066Z"}
{"event":"Shutting down","level":"info","ts":"2026-11-05T22:58:37.055403Z"}
{"event":"Shutting down","level":"info","ts":"2026-11-05T22:58:37.110223Z"}
{"event":"service.stopped","level":"info","ts":"2026-11-05T22:58:37.157015Z"}
{"event":"Finished server process [19]","level":"info","ts":"2026-11-05T22:58:37.157139Z"}
{"event":"Worker (pid:19) was sent SIGTERM!","level":"info","ts":"2026-11-05T22:58:37.207794Z"}
{"event":"service.stopped","level":"info","ts":"2026-11-05T22:58:37.213602Z"}
{"event":"Finished server process [20]","level":"info","ts":"2026-11-05T22:58:37.213742Z"}
{"event":"Worker (pid:20) was sent SIGTERM!","level":"info","ts":"2026-11-05T22:58:37.308719Z"}
{"event":"Shutting down: Master","level":"info","ts":"2026-11-05T22:58:37.414643Z"}
$ scripts/restore.sh
Container hlpipe-lab4-grades-20261106-api-1 Running
Container hlpipe-lab4-grades-20261106-api-2 Starting
Container hlpipe-lab4-grades-20261106-api-2 Started
Container hlpipe-lab4-grades-20261106-api-2 Waiting
Container hlpipe-lab4-grades-20261106-api-1 Waiting
Container hlpipe-lab4-grades-20261106-api-2 Healthy
Container hlpipe-lab4-grades-20261106-api-1 Healthy
== after restore
cff4a17e0883 running started=2026-11-05T22:58:30.83452755Z finished=2026-11-05T22:58:24.503577672Z
f2e1260f6803 running started=2026-11-05T22:58:50.474934128Z finished=2026-11-05T22:58:37.544193511Z
exit_code: 0 elapsed_seconds: 18.126
@@ -0,0 +1,13 @@
date: 2026-11-05T22:59:53Z commit: 763b0255575366082c4c6731b54611af717685a5
$ psql -c "SELECT substring(password_hash from '^[$]argon2id[$]v=[0-9]+[$]m=[0-9]+,t=[0-9]+,p=[0-9]+[$]') AS kdf_prefix, username = 'seed_author' AS seed_stub, count(*) AS users, min(length(password_hash)) AS min_length, max(length(password_hash)) AS max_length FROM users GROUP BY 1, 2 ORDER BY 2"
kdf_prefix | seed_stub | users | min_length | max_length
---------------------------------+-----------+-------+------------+------------
$argon2id$v=19$m=19456,t=2,p=1$ | f | 24 | 97 | 97
(1 row)
$ psql -c "SELECT octet_length(token_hash) AS stored_bytes, count(*) AS sessions FROM sessions GROUP BY 1"
stored_bytes | sessions
--------------+----------
32 | 23
(1 row)
@@ -0,0 +1,107 @@
date: 2026-11-05T22:59:45Z commit: 763b0255575366082c4c6731b54611af717685a5
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ sh scripts/evidence-attachments.sh
date: 2026-11-05T22:59:45Z commit: 763b0255575366082c4c6731b54611af717685a5
$ docker compose ps --format '{{.Service}} {{.Status}} {{.Ports}}'
api Up About a minute (healthy)
api Up 50 seconds (healthy)
lb Up About a minute (healthy) 127.0.0.1:18084->8080/tcp, 127.0.0.1:24844->8404/tcp
migrate Exited (0) About a minute ago
postgres Up About a minute (healthy)
s3 Up 23 seconds (healthy)
s3-init Exited (0) About a minute ago
valkey Up About a minute (healthy)
$ psql -c '\d attachments'
Table "public.attachments"
Column | Type | Collation | Nullable | Default
-------------------+--------------------------+-----------+----------+---------
id | uuid | | not null |
chat_id | uuid | | not null |
owner_id | uuid | | not null |
filename | text | | not null |
content_type | text | | not null |
size_bytes | bigint | | not null |
sha256 | text | | not null |
width | integer | | not null |
height | integer | | not null |
object_key | text | C | not null |
status | text | | not null |
created_at | timestamp with time zone | | not null |
updated_at | timestamp with time zone | | not null |
quarantine_reason | text | | |
quarantined_at | timestamp with time zone | | |
Indexes:
"attachments_pkey" PRIMARY KEY, btree (id)
"attachments_chat_key" UNIQUE CONSTRAINT, btree (id, chat_id)
"attachments_object_key_key" UNIQUE CONSTRAINT, btree (object_key)
"attachments_pending_idx" btree (created_at) WHERE status = 'pending'::text
Check constraints:
"attachments_content_type_check" CHECK (content_type = ANY (ARRAY['image/png'::text, 'image/jpeg'::text]))
"attachments_filename_check" CHECK (char_length(filename) >= 1 AND char_length(filename) <= 255)
"attachments_height_check" CHECK (height > 0)
"attachments_quarantine_check" CHECK ((quarantine_reason IS NULL) = (quarantined_at IS NULL))
"attachments_quarantine_reason_check" CHECK (quarantine_reason = ANY (ARRAY['missing'::text, 'size_mismatch'::text, 'sha_mismatch'::text]))
"attachments_sha256_check" CHECK (sha256 ~ '^[0-9a-f]{64}$'::text)
"attachments_size_bytes_check" CHECK (size_bytes >= 1 AND size_bytes <= 10485760)
"attachments_status_check" CHECK (status = ANY (ARRAY['pending'::text, 'ready'::text]))
"attachments_width_check" CHECK (width > 0)
Foreign-key constraints:
"attachments_owner_fkey" FOREIGN KEY (chat_id, owner_id) REFERENCES chat_members(chat_id, user_id)
Referenced by:
TABLE "message_attachments" CONSTRAINT "message_attachments_attachment_fkey" FOREIGN KEY (attachment_id, chat_id) REFERENCES attachments(id, chat_id) ON DELETE RESTRICT
$ psql -c '\d message_attachments'
Table "public.message_attachments"
Column | Type | Collation | Nullable | Default
---------------+----------+-----------+----------+---------
message_id | uuid | | not null |
position | smallint | | not null |
chat_id | uuid | | not null |
attachment_id | uuid | | not null |
Indexes:
"message_attachments_pkey" PRIMARY KEY, btree (message_id, "position")
"message_attachments_attachment_idx" btree (attachment_id)
"message_attachments_message_id_attachment_id_key" UNIQUE CONSTRAINT, btree (message_id, attachment_id)
Check constraints:
"message_attachments_position_check" CHECK ("position" >= 0 AND "position" <= 9)
Foreign-key constraints:
"message_attachments_attachment_fkey" FOREIGN KEY (attachment_id, chat_id) REFERENCES attachments(id, chat_id) ON DELETE RESTRICT
"message_attachments_message_id_fkey" FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE CASCADE
$ psql: столбцы bytea во всей схеме (хеши токенов и отпечатки, не файлы)
table_name | column_name
------------------+-------------
idempotency_keys | fingerprint
sessions | token_hash
(2 rows)
$ psql: вложения по статусу и максимальный размер строки attachments
status | count | max_row_bytes
---------+-------+---------------
ready | 10 | 264
pending | 3 | 264
(2 rows)
$ rc object list --recursive root/messenger-attachments/attachments/ | count
10
$ rc object list root/messenger-attachments/ (первые 3 объекта, ключи назначены сервером)
[2026-11-05 22:58:21] 109.20 KiB attachments/01a1adef-432f-74b3-9212-2983a33641cd
[2026-11-05 22:58:21] 109.20 KiB attachments/01a1adef-45b4-753d-a583-15cfdd598dd2
[2026-11-05 22:58:34] 109.20 KiB attachments/01a1adef-788a-7696-bc0a-77207d3a287a
$ сверка вне API: sha256 и размер последнего ready-вложения в PostgreSQL против байтов объекта в bucket
postgres: 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75 111817
s3: 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75 111817
$ docker inspect api: ReadonlyRootfs, tmpfs, volumes/bind mounts
cff4a17e0883 ro=true tmpfs={"/tmp":""} mounts=bind:/run/secrets/cache_url bind:/run/secrets/cursor_secret bind:/run/secrets/s3_access_key_id bind:/run/secrets/s3_secret_access_key bind:/run/secrets/database_url
f2e1260f6803 ro=true tmpfs={"/tmp":""} mounts=bind:/run/secrets/s3_secret_access_key bind:/run/secrets/database_url bind:/run/secrets/cache_url bind:/run/secrets/cursor_secret bind:/run/secrets/s3_access_key_id
$ docker inspect s3: volume данных
volume:hlpipe-lab4-grades-20261106_s3data:/data bind::/run/secrets/s3_root_password bind::/run/secrets/s3_root_user
$ секреты сервисов: root-ключи S3 только у s3/s3-init/s3-cli
api ['cache_url', 'cursor_secret', 'database_url', 's3_access_key_id', 's3_secret_access_key']
lb []
migrate ['database_url']
postgres ['postgres_password']
s3 ['s3_root_password', 's3_root_user']
s3-init ['s3_access_key_id', 's3_reconciler_access_key_id', 's3_reconciler_secret_access_key', 's3_root_password', 's3_root_user', 's3_secret_access_key']
valkey ['valkey.conf']
exit_code: 0 elapsed_seconds: 2.432
@@ -0,0 +1,25 @@
date: 2026-11-05T23:00:01Z commit: 763b0255575366082c4c6731b54611af717685a5
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ python3 scripts/probe.py check --rounds 20 --out evidence/sqlalchemy-2026-11-06/grade3/lb-check.json
{
"instances_one_token": {
"f2e1260f6803": 20,
"cff4a17e0883": 20
},
"same_key": {
"rounds": 20,
"parallel": 8,
"statuses": {
"201": 160
},
"instances": {
"f2e1260f6803": 80,
"cff4a17e0883": 80
},
"identical_bodies_rounds": 20,
"single_copy_rounds": 20,
"conflict_rounds": 20
},
"pass": true
}
exit_code: 0 elapsed_seconds: 0.569
@@ -0,0 +1,21 @@
{
"instances_one_token": {
"f2e1260f6803": 20,
"cff4a17e0883": 20
},
"same_key": {
"rounds": 20,
"parallel": 8,
"statuses": {
"201": 160
},
"instances": {
"f2e1260f6803": 80,
"cff4a17e0883": 80
},
"identical_bodies_rounds": 20,
"single_copy_rounds": 20,
"conflict_rounds": 20
},
"pass": true
}
@@ -0,0 +1,6 @@
date: 2026-11-05T22:59:54Z commit: 763b0255575366082c4c6731b54611af717685a5
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ python3 scripts/probe.py check --base-url http://127.0.0.1:18084 --rounds 20 --out evidence/sqlalchemy-2026-11-06/grade3/lb-check.json
usage: probe.py [-h] {check,load,retry,detect} ...
probe.py: error: unrecognized arguments: --base-url http://127.0.0.1:18084
exit_code: 2 elapsed_seconds: 0.053
@@ -0,0 +1,30 @@
date: 2026-11-05T22:59:54Z commit: 763b0255575366082c4c6731b54611af717685a5
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ python3 scripts/limits.py --out evidence/sqlalchemy-2026-11-06/grade3/limits.txt
date: 2026-11-05T22:59:54Z commit: 763b025
$ docker compose --profile bench --profile tools --profile reconcile config --format json (declared)
service cpus/mem ports secrets volumes networks ro user
---------- ---------- ------------------------------- ------------------------------------------------------------------------------------------------------------------------------- ---------- ---------------------- ----- -----------
api 1/512MiB - cache_url,cursor_secret,database_url,s3_access_key_id,s3_secret_access_key - backend(internal) true image
k6 2/512MiB - - - edge false image
lb 1/128MiB 127.0.0.1:18084,127.0.0.1:24844 - - backend(internal),edge true image
migrate 0.5/256MiB - database_url - backend(internal) false image
postgres 2/1024MiB - postgres_password pgdata backend(internal) false 70:70
reconciler 1/256MiB - database_url,s3_reconciler_access_key_id,s3_reconciler_secret_access_key - backend(internal) true image
s3 1/512MiB - s3_root_password,s3_root_user s3data backend(internal) true image
s3-cli 0.5/64MiB - s3_access_key_id,s3_reconciler_access_key_id,s3_reconciler_secret_access_key,s3_root_password,s3_root_user,s3_secret_access_key - backend(internal) true 65534:65534
s3-init 0.5/64MiB - s3_access_key_id,s3_reconciler_access_key_id,s3_reconciler_secret_access_key,s3_root_password,s3_root_user,s3_secret_access_key - backend(internal) true 65534:65534
valkey 0.5/128MiB - valkey.conf valkeydata backend(internal) false 999:1000
$ docker inspect (running containers: hostname = X-Instance-Id, applied limits)
service hostname cpus memory published
-------- ------------ ---- ------- ---------------------------------------------------
api cff4a17e0883 1 512MiB
api f2e1260f6803 1 512MiB
lb 5f001dc38f7f 1 128MiB 127.0.0.1:18084->8080/tcp,127.0.0.1:24844->8404/tcp
postgres d390978734bf 2 1024MiB
s3 a1dccc133510 1 512MiB
valkey e17243696dd9 0.5 128MiB
PASS: limits, ports, secrets, volumes and networks match the policy
exit_code: 0 elapsed_seconds: 0.258
@@ -0,0 +1,26 @@
date: 2026-11-05T22:59:54Z commit: 763b025
$ docker compose --profile bench --profile tools --profile reconcile config --format json (declared)
service cpus/mem ports secrets volumes networks ro user
---------- ---------- ------------------------------- ------------------------------------------------------------------------------------------------------------------------------- ---------- ---------------------- ----- -----------
api 1/512MiB - cache_url,cursor_secret,database_url,s3_access_key_id,s3_secret_access_key - backend(internal) true image
k6 2/512MiB - - - edge false image
lb 1/128MiB 127.0.0.1:18084,127.0.0.1:24844 - - backend(internal),edge true image
migrate 0.5/256MiB - database_url - backend(internal) false image
postgres 2/1024MiB - postgres_password pgdata backend(internal) false 70:70
reconciler 1/256MiB - database_url,s3_reconciler_access_key_id,s3_reconciler_secret_access_key - backend(internal) true image
s3 1/512MiB - s3_root_password,s3_root_user s3data backend(internal) true image
s3-cli 0.5/64MiB - s3_access_key_id,s3_reconciler_access_key_id,s3_reconciler_secret_access_key,s3_root_password,s3_root_user,s3_secret_access_key - backend(internal) true 65534:65534
s3-init 0.5/64MiB - s3_access_key_id,s3_reconciler_access_key_id,s3_reconciler_secret_access_key,s3_root_password,s3_root_user,s3_secret_access_key - backend(internal) true 65534:65534
valkey 0.5/128MiB - valkey.conf valkeydata backend(internal) false 999:1000
$ docker inspect (running containers: hostname = X-Instance-Id, applied limits)
service hostname cpus memory published
-------- ------------ ---- ------- ---------------------------------------------------
api cff4a17e0883 1 512MiB
api f2e1260f6803 1 512MiB
lb 5f001dc38f7f 1 128MiB 127.0.0.1:18084->8080/tcp,127.0.0.1:24844->8404/tcp
postgres d390978734bf 2 1024MiB
s3 a1dccc133510 1 512MiB
valkey e17243696dd9 0.5 128MiB
PASS: limits, ports, secrets, volumes and networks match the policy
@@ -0,0 +1,14 @@
date: 2026-11-05T22:59:51Z commit: 763b0255575366082c4c6731b54611af717685a5
$ psql -c "SELECT (SELECT count(*) FROM users) users, (SELECT count(*) FROM sessions) sessions, (SELECT count(*) FROM chats) chats, (SELECT count(*) FROM chat_members) members, (SELECT count(*) FROM messages) messages, (SELECT count(*) FROM idempotency_keys) keys, (SELECT count(*) FROM attachments) attachments, (SELECT count(*) FROM message_attachments) links, (SELECT count(*) FROM alembic_version) versions"
users | sessions | chats | members | messages | keys | attachments | links | versions
-------+----------+-------+---------+----------+------+-------------+-------+----------
24 | 23 | 10 | 18 | 141 | 141 | 13 | 1 | 1
(1 row)
$ make migrate
$ psql -c "SELECT (SELECT count(*) FROM users) users, (SELECT count(*) FROM sessions) sessions, (SELECT count(*) FROM chats) chats, (SELECT count(*) FROM chat_members) members, (SELECT count(*) FROM messages) messages, (SELECT count(*) FROM idempotency_keys) keys, (SELECT count(*) FROM attachments) attachments, (SELECT count(*) FROM message_attachments) links, (SELECT count(*) FROM alembic_version) versions"
users | sessions | chats | members | messages | keys | attachments | links | versions
-------+----------+-------+---------+----------+------+-------------+-------+----------
24 | 23 | 10 | 18 | 141 | 141 | 13 | 1 | 1
(1 row)
@@ -0,0 +1,47 @@
date: 2026-11-05T22:59:41Z commit: 763b0255575366082c4c6731b54611af717685a5
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ .venv/bin/pytest -m stack -v -s --no-header --tb=short -p no:cacheprovider student-tests/stack/test_attachment_faults.py -k user_errors
============================= test session starts ==============================
collecting ... collected 7 items / 6 deselected / 1 selected
student-tests/stack/test_attachment_faults.py::test_user_errors_never_become_500 10 MiB + 1 с Content-Length, тело не отправлено: 413
10 MiB + 1 chunked: 413
PNG 100000×100000 (бомба): 413
PNG 8001×5000: 413
обрезанный PNG: 415
обрезанный JPEG: 415
JPEG как image/png: 415
GIF как image/png: 415
WebP как image/png: 415
текст как image/png: 415
PNG как image/jpeg: 415
пустое тело: 415
application/octet-stream: 415
без Content-Type: 415
filename='../a.png': 400
filename='a/b.png': 400
filename='a\\b.png': 400
filename='a\x00.png': 400
filename='a\x01.png': 400
filename='a\x7f.png': 400
filename='': 400
filename=' ': 400
filename='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: 400
filename=None: 400
посторонний: upload в чужой чат: 404
посторонний: метаданные: 404
посторонний: /content: 404
посторонний: ссылка на чужое вложение: 404
вложение другого чата: 404
неизвестное вложение: 404
11 вложений: 400
повтор вложения: 400
невалидный UUID: 400
пустой текст без вложений: 400
невалидный id вложения: 400
variant=thumbnail: 400
строк вложений в чате: 2 (= ответов 201); ответов в журнале реплик: 53, из них 5xx: 0
PASSED
======================= 1 passed, 6 deselected in 0.97s ========================
exit_code: 0 elapsed_seconds: 1.718
@@ -0,0 +1,26 @@
date: 2026-11-05T22:58:21Z commit: 1aec062aba4560b51a6d9155571c9610bc777d7e
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ sh scripts/persistence-evidence.sh http://127.0.0.1:18084
date: 2026-11-05T22:58:21Z commit: 1aec062aba4560b51a6d9155571c9610bc777d7e
== before: service hostname StartedAt status
api cff4a17e0883 2026-11-05T22:58:06.663700594Z running
api f2e1260f6803 2026-11-05T22:58:06.586246427Z running
lb 5f001dc38f7f 2026-11-05T22:58:00.407765133Z running
migrate 6d469d0032ef 2026-11-05T22:58:01.481951008Z exited
postgres d390978734bf 2026-11-05T22:58:00.411066466Z running
s3 a1dccc133510 2026-11-05T22:58:00.411809508Z running
s3-init a054e4df27d2 2026-11-05T22:58:05.999056052Z exited
valkey e17243696dd9 2026-11-05T22:58:00.411557383Z running
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://127.0.0.1:18084"
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: service hostname StartedAt status
api cff4a17e0883 2026-11-05T22:58:30.83452755Z running
api f2e1260f6803 2026-11-05T22:58:30.769256883Z running
lb 5f001dc38f7f 2026-11-05T22:58:25.164843547Z running
migrate 6d469d0032ef 2026-11-05T22:58:25.669550089Z exited
postgres d390978734bf 2026-11-05T22:58:24.879048838Z running
s3 a1dccc133510 2026-11-05T22:58:24.85172213Z running
s3-init a054e4df27d2 2026-11-05T22:58:30.190186674Z exited
valkey e17243696dd9 2026-11-05T22:58:24.914383838Z running
exit_code: 0 elapsed_seconds: 13.055
@@ -0,0 +1,47 @@
{
"variants": [
{
"variant": "timeout",
"lost_attempt": {
"status": 0,
"client_timeout_s": 0.5,
"chat_lock_held_s": 1.5,
"replica": "f2e1260f6803",
"replica_killed": false,
"replica_answered": 201
},
"retry": {
"after_s": 1.542,
"status": 201,
"attempts": 1,
"replica": "cff4a17e0883"
},
"copies_in_history": 1,
"same_message": true,
"written_by": "lost attempt",
"pass": true
},
{
"variant": "kill",
"lost_attempt": {
"status": 0,
"client_timeout_s": 0.5,
"chat_lock_held_s": 1.5,
"replica": "cff4a17e0883",
"replica_killed": true,
"replica_answered": null
},
"retry": {
"after_s": 1.525,
"status": 201,
"attempts": 1,
"replica": "f2e1260f6803"
},
"copies_in_history": 1,
"same_message": true,
"written_by": "lost attempt",
"pass": true
}
],
"pass": true
}
@@ -0,0 +1,51 @@
date: 2026-11-05T23:00:02Z commit: 763b0255575366082c4c6731b54611af717685a5
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ python3 scripts/probe.py retry --out evidence/sqlalchemy-2026-11-06/grade3/retry.json
{
"variants": [
{
"variant": "timeout",
"lost_attempt": {
"status": 0,
"client_timeout_s": 0.5,
"chat_lock_held_s": 1.5,
"replica": "f2e1260f6803",
"replica_killed": false,
"replica_answered": 201
},
"retry": {
"after_s": 1.542,
"status": 201,
"attempts": 1,
"replica": "cff4a17e0883"
},
"copies_in_history": 1,
"same_message": true,
"written_by": "lost attempt",
"pass": true
},
{
"variant": "kill",
"lost_attempt": {
"status": 0,
"client_timeout_s": 0.5,
"chat_lock_held_s": 1.5,
"replica": "cff4a17e0883",
"replica_killed": true,
"replica_answered": null
},
"retry": {
"after_s": 1.525,
"status": 201,
"attempts": 1,
"replica": "f2e1260f6803"
},
"copies_in_history": 1,
"same_message": true,
"written_by": "lost attempt",
"pass": true
}
],
"pass": true
}
exit_code: 0 elapsed_seconds: 6.639
@@ -0,0 +1,50 @@
{
"ok": true,
"date": "2026-11-05T22:58:59Z",
"commit": "1aec062aba4560b51a6d9155571c9610bc777d7e",
"scenario": "s3-outage",
"s3_container_during_outage": [
{
"hostname": "a1dccc133510",
"status": "exited",
"exit_code": "0",
"started_at": "2026-11-05T22:58:24.85172213Z",
"finished_at": "2026-11-05T22:58:59.485949382Z"
}
],
"during_outage": {
"upload": {
"status": 503,
"seconds": 5.039,
"instance": "cff4a17e0883"
},
"metadata": {
"status": 200,
"seconds": 0.034,
"instance": "f2e1260f6803"
},
"download": {
"status": 503,
"seconds": 0.51,
"instance": "cff4a17e0883"
},
"text_message": {
"status": 201,
"seconds": 0.02,
"instance": "f2e1260f6803"
},
"health_ready": {
"status": 200,
"seconds": 0.004,
"instance": "cff4a17e0883"
}
},
"expected": {
"upload": 503,
"download": 503,
"text_message": 201
},
"as_expected": true,
"s3_back_healthy_seconds": 5.75,
"download_after_recovery": "sha256 equal"
}
@@ -0,0 +1,54 @@
date: 2026-11-05T22:58:59Z commit: 1aec062aba4560b51a6d9155571c9610bc777d7e
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ python3 scripts/lab4_scenarios.py s3-outage --base-url http://127.0.0.1:18084 --output evidence/sqlalchemy-2026-11-06/grade3/s3-outage-1.json
{
"ok": true,
"date": "2026-11-05T22:58:59Z",
"commit": "1aec062aba4560b51a6d9155571c9610bc777d7e",
"scenario": "s3-outage",
"s3_container_during_outage": [
{
"hostname": "a1dccc133510",
"status": "exited",
"exit_code": "0",
"started_at": "2026-11-05T22:58:24.85172213Z",
"finished_at": "2026-11-05T22:58:59.485949382Z"
}
],
"during_outage": {
"upload": {
"status": 503,
"seconds": 5.039,
"instance": "cff4a17e0883"
},
"metadata": {
"status": 200,
"seconds": 0.034,
"instance": "f2e1260f6803"
},
"download": {
"status": 503,
"seconds": 0.51,
"instance": "cff4a17e0883"
},
"text_message": {
"status": 201,
"seconds": 0.02,
"instance": "f2e1260f6803"
},
"health_ready": {
"status": 200,
"seconds": 0.004,
"instance": "cff4a17e0883"
}
},
"expected": {
"upload": 503,
"download": 503,
"text_message": 201
},
"as_expected": true,
"s3_back_healthy_seconds": 5.75,
"download_after_recovery": "sha256 equal"
}
exit_code: 0 elapsed_seconds: 12.157
@@ -0,0 +1,50 @@
{
"ok": true,
"date": "2026-11-05T22:59:11Z",
"commit": "763b0255575366082c4c6731b54611af717685a5",
"scenario": "s3-outage",
"s3_container_during_outage": [
{
"hostname": "a1dccc133510",
"status": "exited",
"exit_code": "0",
"started_at": "2026-11-05T22:59:05.497402468Z",
"finished_at": "2026-11-05T22:59:11.537673846Z"
}
],
"during_outage": {
"upload": {
"status": 503,
"seconds": 1.464,
"instance": "cff4a17e0883"
},
"metadata": {
"status": 200,
"seconds": 0.01,
"instance": "f2e1260f6803"
},
"download": {
"status": 503,
"seconds": 0.912,
"instance": "cff4a17e0883"
},
"text_message": {
"status": 201,
"seconds": 0.008,
"instance": "f2e1260f6803"
},
"health_ready": {
"status": 200,
"seconds": 0.003,
"instance": "cff4a17e0883"
}
},
"expected": {
"upload": 503,
"download": 503,
"text_message": 201
},
"as_expected": true,
"s3_back_healthy_seconds": 5.752,
"download_after_recovery": "sha256 equal"
}
@@ -0,0 +1,54 @@
date: 2026-11-05T22:59:11Z commit: 763b0255575366082c4c6731b54611af717685a5
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ python3 scripts/lab4_scenarios.py s3-outage --base-url http://127.0.0.1:18084 --output evidence/sqlalchemy-2026-11-06/grade3/s3-outage-2.json
{
"ok": true,
"date": "2026-11-05T22:59:11Z",
"commit": "763b0255575366082c4c6731b54611af717685a5",
"scenario": "s3-outage",
"s3_container_during_outage": [
{
"hostname": "a1dccc133510",
"status": "exited",
"exit_code": "0",
"started_at": "2026-11-05T22:59:05.497402468Z",
"finished_at": "2026-11-05T22:59:11.537673846Z"
}
],
"during_outage": {
"upload": {
"status": 503,
"seconds": 1.464,
"instance": "cff4a17e0883"
},
"metadata": {
"status": 200,
"seconds": 0.01,
"instance": "f2e1260f6803"
},
"download": {
"status": 503,
"seconds": 0.912,
"instance": "cff4a17e0883"
},
"text_message": {
"status": 201,
"seconds": 0.008,
"instance": "f2e1260f6803"
},
"health_ready": {
"status": 200,
"seconds": 0.003,
"instance": "cff4a17e0883"
}
},
"expected": {
"upload": 503,
"download": 503,
"text_message": 201
},
"as_expected": true,
"s3_back_healthy_seconds": 5.752,
"download_after_recovery": "sha256 equal"
}
exit_code: 0 elapsed_seconds: 8.689
@@ -0,0 +1,50 @@
{
"ok": true,
"date": "2026-11-05T22:59:20Z",
"commit": "763b0255575366082c4c6731b54611af717685a5",
"scenario": "s3-outage",
"s3_container_during_outage": [
{
"hostname": "a1dccc133510",
"status": "exited",
"exit_code": "0",
"started_at": "2026-11-05T22:59:14.304967958Z",
"finished_at": "2026-11-05T22:59:20.289378253Z"
}
],
"during_outage": {
"upload": {
"status": 503,
"seconds": 0.828,
"instance": "cff4a17e0883"
},
"metadata": {
"status": 200,
"seconds": 0.014,
"instance": "f2e1260f6803"
},
"download": {
"status": 503,
"seconds": 1.397,
"instance": "cff4a17e0883"
},
"text_message": {
"status": 201,
"seconds": 0.004,
"instance": "f2e1260f6803"
},
"health_ready": {
"status": 200,
"seconds": 0.003,
"instance": "cff4a17e0883"
}
},
"expected": {
"upload": 503,
"download": 503,
"text_message": 201
},
"as_expected": true,
"s3_back_healthy_seconds": 5.718,
"download_after_recovery": "sha256 equal"
}
@@ -0,0 +1,54 @@
date: 2026-11-05T22:59:20Z commit: 763b0255575366082c4c6731b54611af717685a5
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ python3 scripts/lab4_scenarios.py s3-outage --base-url http://127.0.0.1:18084 --output evidence/sqlalchemy-2026-11-06/grade3/s3-outage-3.json
{
"ok": true,
"date": "2026-11-05T22:59:20Z",
"commit": "763b0255575366082c4c6731b54611af717685a5",
"scenario": "s3-outage",
"s3_container_during_outage": [
{
"hostname": "a1dccc133510",
"status": "exited",
"exit_code": "0",
"started_at": "2026-11-05T22:59:14.304967958Z",
"finished_at": "2026-11-05T22:59:20.289378253Z"
}
],
"during_outage": {
"upload": {
"status": 503,
"seconds": 0.828,
"instance": "cff4a17e0883"
},
"metadata": {
"status": 200,
"seconds": 0.014,
"instance": "f2e1260f6803"
},
"download": {
"status": 503,
"seconds": 1.397,
"instance": "cff4a17e0883"
},
"text_message": {
"status": 201,
"seconds": 0.004,
"instance": "f2e1260f6803"
},
"health_ready": {
"status": 200,
"seconds": 0.003,
"instance": "cff4a17e0883"
}
},
"expected": {
"upload": 503,
"download": 503,
"text_message": 201
},
"as_expected": true,
"s3_back_healthy_seconds": 5.718,
"download_after_recovery": "sha256 equal"
}
exit_code: 0 elapsed_seconds: 8.481
@@ -0,0 +1,133 @@
date: 2026-11-05T22:59:42Z commit: 763b0255575366082c4c6731b54611af717685a5
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ sh scripts/s3-check.sh
date: 2026-11-05T22:59:42Z commit: 763b0255575366082c4c6731b54611af717685a5 == S3 privacy and bootstrap checks
PASS s3: опубликованные host-порты: нет
PASS s3: консоль :9001 внутри контейнера: 000
PASS s3-init: повторный запуск 1: 0
PASS s3-init: повторный запуск 2: 0
PASS s3-init: состояние IAM/bucket не изменилось: same
PASS api: PutObject: allow
PASS api: HeadObject: allow
PASS api: GetObject: allow
PASS api: ListBucket: deny
PASS reconciler: ListBucket: allow
PASS reconciler: HeadObject: allow
PASS reconciler: GetObject: allow
PASS reconciler: PutObject: deny
PASS reconciler: DeleteObject: allow
PASS reconciler: CreateBucket: deny
PASS reconciler: PutBucketPolicy (public): deny
PASS reconciler: admin ListUsers: deny
PASS api: CreateBucket: deny
PASS api: DeleteBucket: deny
PASS api: PutBucketPolicy (public): deny
PASS api: PutBucketLifecycle (HeadBucket уже 403): deny
PASS api: admin ListUsers: deny
PASS api: PutObject в чужой bucket: deny
PASS api: ListBucket чужого bucket: deny
PASS anonymous: HeadObject: deny
PASS anonymous: ListBucket: deny
PASS anonymous: PutObject: deny
PASS anonymous: прямой HTTP GET объекта из отдельного контейнера: 403
PASS bucket: anonymous policy: private
PASS api: DeleteObject: allow
PASS s3: консоль :9001 из отдельного контейнера сети стенда: connection refused
== IAM/bucket snapshot (без секретов)
{
"items": [
{
"key": "messenger-attachments",
"last_modified": "2026-11-05T22:58:06Z",
"is_dir": true
}
],
"truncated": false
}
{
"path": "root/messenger-attachments",
"permission": "private"
}
{
"name": "messenger-api",
"policy": {
"policy": {
"Statement": [
{
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::messenger-attachments/*"
],
"Sid": "MessengerApiObjects"
}
],
"Version": "2012-10-17"
},
"policy_name": "messenger-api"
}
}
{
"name": "messenger-reconciler",
"policy": {
"policy": {
"Statement": [
{
"Action": [
"s3:GetObject",
"s3:DeleteObject"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::messenger-attachments/*"
],
"Sid": "MessengerReconcilerObjects"
},
{
"Action": [
"s3:ListBucket"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::messenger-attachments"
],
"Sid": "MessengerReconcilerListing"
}
],
"Version": "2012-10-17"
},
"policy_name": "messenger-reconciler"
}
}
{
"accessKey": "<api-key>",
"status": "enabled",
"policies": [
"messenger-api"
],
"memberOf": []
}
{
"accessKey": "<reconciler-key>",
"status": "enabled",
"policies": [
"messenger-reconciler"
],
"memberOf": []
}
{
"rules": [
{
"id": "abort-incomplete-uploads",
"status": "Enabled",
"prefix": "",
"abortIncompleteMultipartUploadDays": 1
}
]
}
RESULT: PASS
exit_code: 0 elapsed_seconds: 2.895
@@ -0,0 +1,193 @@
date: 2026-11-05T22:59:50Z commit: 763b0255575366082c4c6731b54611af717685a5
$ psql -c '\d+ users'
Table "public.users"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
---------------+--------------------------+-----------+----------+---------+----------+-------------+--------------+-------------
id | uuid | | not null | | plain | | |
username | text | | not null | | extended | | |
display_name | text | | not null | | extended | | |
password_hash | text | | not null | | extended | | |
created_at | timestamp with time zone | | not null | | plain | | |
Indexes:
"users_pkey" PRIMARY KEY, btree (id)
"users_username_key" UNIQUE CONSTRAINT, btree (username)
Check constraints:
"users_display_name_check" CHECK (char_length(display_name) >= 1 AND char_length(display_name) <= 100)
"users_password_hash_check" CHECK (password_hash ~~ '$argon2id$%'::text)
"users_username_format" CHECK (username ~ '^[a-z0-9_]{3,32}$'::text)
Referenced by:
TABLE "chat_members" CONSTRAINT "chat_members_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id)
TABLE "sessions" CONSTRAINT "sessions_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
Access method: heap
$ psql -c '\d+ sessions'
Table "public.sessions"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
------------+--------------------------+-----------+----------+---------+----------+-------------+--------------+-------------
token_hash | bytea | | not null | | extended | | |
user_id | uuid | | not null | | plain | | |
created_at | timestamp with time zone | | not null | | plain | | |
expires_at | timestamp with time zone | | not null | | plain | | |
Indexes:
"sessions_pkey" PRIMARY KEY, btree (token_hash)
"sessions_user_idx" btree (user_id)
Check constraints:
"sessions_check" CHECK (expires_at > created_at)
"sessions_token_hash_check" CHECK (octet_length(token_hash) = 32)
Foreign-key constraints:
"sessions_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
Access method: heap
$ psql -c '\d+ chats'
Table "public.chats"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
-----------------+--------------------------+-----------+----------+---------+----------+-------------+--------------+-------------
id | uuid | | not null | | plain | | |
title | text | | not null | | extended | | |
created_at | timestamp with time zone | | not null | | plain | | |
last_message_at | timestamp with time zone | | | | plain | | |
Indexes:
"chats_pkey" PRIMARY KEY, btree (id)
Check constraints:
"chats_title_check" CHECK (char_length(title) >= 1 AND char_length(title) <= 100)
Referenced by:
TABLE "chat_members" CONSTRAINT "chat_members_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE
Access method: heap
$ psql -c '\d+ chat_members'
Table "public.chat_members"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
-----------------+--------------------------+-----------+----------+---------+---------+-------------+--------------+-------------
chat_id | uuid | | not null | | plain | | |
user_id | uuid | | not null | | plain | | |
position | smallint | | not null | | plain | | |
chat_created_at | timestamp with time zone | | not null | | plain | | |
Indexes:
"chat_members_pkey" PRIMARY KEY, btree (chat_id, user_id)
"chat_members_user_idx" btree (user_id, chat_created_at, chat_id)
Check constraints:
"chat_members_position_check" CHECK ("position" >= 1 AND "position" <= 100)
Foreign-key constraints:
"chat_members_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE
"chat_members_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id)
Referenced by:
TABLE "attachments" CONSTRAINT "attachments_owner_fkey" FOREIGN KEY (chat_id, owner_id) REFERENCES chat_members(chat_id, user_id)
TABLE "idempotency_keys" CONSTRAINT "idempotency_keys_chat_id_user_id_fkey" FOREIGN KEY (chat_id, user_id) REFERENCES chat_members(chat_id, user_id)
TABLE "messages" CONSTRAINT "messages_chat_id_sender_id_fkey" FOREIGN KEY (chat_id, sender_id) REFERENCES chat_members(chat_id, user_id)
Access method: heap
$ psql -c '\d+ messages'
Table "public.messages"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
------------+--------------------------+-----------+----------+---------+----------+-------------+--------------+-------------
id | uuid | | not null | | plain | | |
chat_id | uuid | | not null | | plain | | |
sender_id | uuid | | not null | | plain | | |
text | text | | not null | | extended | | |
created_at | timestamp with time zone | | not null | | plain | | |
Indexes:
"messages_pkey" PRIMARY KEY, btree (id)
"messages_history_idx" btree (chat_id, created_at, id)
Check constraints:
"messages_text_check" CHECK (char_length(text) <= 4000)
Foreign-key constraints:
"messages_chat_id_sender_id_fkey" FOREIGN KEY (chat_id, sender_id) REFERENCES chat_members(chat_id, user_id)
Referenced by:
TABLE "idempotency_keys" CONSTRAINT "idempotency_keys_message_id_fkey" FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE CASCADE
TABLE "message_attachments" CONSTRAINT "message_attachments_message_id_fkey" FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE CASCADE
Access method: heap
$ psql -c '\d+ idempotency_keys'
Table "public.idempotency_keys"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
-------------+--------------------------+-----------+----------+---------+----------+-------------+--------------+-------------
chat_id | uuid | | not null | | plain | | |
user_id | uuid | | not null | | plain | | |
key | text | | not null | | extended | | |
fingerprint | bytea | | not null | | extended | | |
message_id | uuid | | not null | | plain | | |
created_at | timestamp with time zone | | not null | | plain | | |
Indexes:
"idempotency_keys_pkey" PRIMARY KEY, btree (chat_id, user_id, key)
Check constraints:
"idempotency_keys_fingerprint_check" CHECK (octet_length(fingerprint) = 32)
"idempotency_keys_key_check" CHECK (key ~ '^[A-Za-z0-9._:-]{1,128}$'::text)
Foreign-key constraints:
"idempotency_keys_chat_id_user_id_fkey" FOREIGN KEY (chat_id, user_id) REFERENCES chat_members(chat_id, user_id)
"idempotency_keys_message_id_fkey" FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE CASCADE
Access method: heap
$ psql -c '\d+ attachments'
Table "public.attachments"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
-------------------+--------------------------+-----------+----------+---------+----------+-------------+--------------+-------------
id | uuid | | not null | | plain | | |
chat_id | uuid | | not null | | plain | | |
owner_id | uuid | | not null | | plain | | |
filename | text | | not null | | extended | | |
content_type | text | | not null | | extended | | |
size_bytes | bigint | | not null | | plain | | |
sha256 | text | | not null | | extended | | |
width | integer | | not null | | plain | | |
height | integer | | not null | | plain | | |
object_key | text | C | not null | | extended | | |
status | text | | not null | | extended | | |
created_at | timestamp with time zone | | not null | | plain | | |
updated_at | timestamp with time zone | | not null | | plain | | |
quarantine_reason | text | | | | extended | | |
quarantined_at | timestamp with time zone | | | | plain | | |
Indexes:
"attachments_pkey" PRIMARY KEY, btree (id)
"attachments_chat_key" UNIQUE CONSTRAINT, btree (id, chat_id)
"attachments_object_key_key" UNIQUE CONSTRAINT, btree (object_key)
"attachments_pending_idx" btree (created_at) WHERE status = 'pending'::text
Check constraints:
"attachments_content_type_check" CHECK (content_type = ANY (ARRAY['image/png'::text, 'image/jpeg'::text]))
"attachments_filename_check" CHECK (char_length(filename) >= 1 AND char_length(filename) <= 255)
"attachments_height_check" CHECK (height > 0)
"attachments_quarantine_check" CHECK ((quarantine_reason IS NULL) = (quarantined_at IS NULL))
"attachments_quarantine_reason_check" CHECK (quarantine_reason = ANY (ARRAY['missing'::text, 'size_mismatch'::text, 'sha_mismatch'::text]))
"attachments_sha256_check" CHECK (sha256 ~ '^[0-9a-f]{64}$'::text)
"attachments_size_bytes_check" CHECK (size_bytes >= 1 AND size_bytes <= 10485760)
"attachments_status_check" CHECK (status = ANY (ARRAY['pending'::text, 'ready'::text]))
"attachments_width_check" CHECK (width > 0)
Foreign-key constraints:
"attachments_owner_fkey" FOREIGN KEY (chat_id, owner_id) REFERENCES chat_members(chat_id, user_id)
Referenced by:
TABLE "message_attachments" CONSTRAINT "message_attachments_attachment_fkey" FOREIGN KEY (attachment_id, chat_id) REFERENCES attachments(id, chat_id) ON DELETE RESTRICT
Access method: heap
$ psql -c '\d+ message_attachments'
Table "public.message_attachments"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
---------------+----------+-----------+----------+---------+---------+-------------+--------------+-------------
message_id | uuid | | not null | | plain | | |
position | smallint | | not null | | plain | | |
chat_id | uuid | | not null | | plain | | |
attachment_id | uuid | | not null | | plain | | |
Indexes:
"message_attachments_pkey" PRIMARY KEY, btree (message_id, "position")
"message_attachments_attachment_idx" btree (attachment_id)
"message_attachments_message_id_attachment_id_key" UNIQUE CONSTRAINT, btree (message_id, attachment_id)
Check constraints:
"message_attachments_position_check" CHECK ("position" >= 0 AND "position" <= 9)
Foreign-key constraints:
"message_attachments_attachment_fkey" FOREIGN KEY (attachment_id, chat_id) REFERENCES attachments(id, chat_id) ON DELETE RESTRICT
"message_attachments_message_id_fkey" FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE CASCADE
Access method: heap
$ psql -c '\d+ alembic_version'
Table "public.alembic_version"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
-------------+-----------------------+-----------+----------+---------+----------+-------------+--------------+-------------
version_num | character varying(32) | | not null | | extended | | |
Indexes:
"alembic_version_pkc" PRIMARY KEY, btree (version_num)
Access method: heap
$ psql -c 'SELECT version_num FROM alembic_version'
version_num
----------------------------
0004_attachment_quarantine
(1 row)
@@ -0,0 +1,15 @@
date: 2026-11-05T22:59:54Z commit: 763b0255575366082c4c6731b54611af717685a5
$ git ls-files secrets .env backups volumes
(пусто: секретов, .env, дампов и volumes в Git нет)
$ git check-ignore -v secrets/database_url secrets/postgres_password secrets/s3_root_password secrets/s3_secret_access_key .env backups/
.gitignore:5:secrets/ secrets/database_url
.gitignore:5:secrets/ secrets/postgres_password
.gitignore:5:secrets/ secrets/s3_root_password
.gitignore:5:secrets/ secrets/s3_secret_access_key
.gitignore:2:.env .env
.gitignore:15:backups/ backups/
$ docker volume ls --filter label=com.docker.compose.project=hlpipe-lab4-grades-20261106
DRIVER VOLUME NAME
local hlpipe-lab4-grades-20261106_pgdata
local hlpipe-lab4-grades-20261106_s3data
local hlpipe-lab4-grades-20261106_valkeydata
@@ -0,0 +1,6 @@
date: 2026-11-05T22:58:20Z commit: 1aec062aba4560b51a6d9155571c9610bc777d7e
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ make test
python3 tests/smoke.py --base-url "http://127.0.0.1:18084"
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
exit_code: 0 elapsed_seconds: 0.537
@@ -0,0 +1,80 @@
date: 2026-11-05T22:59:48Z commit: 763b0255575366082c4c6731b54611af717685a5
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ sh scripts/evidence-stack.sh http://127.0.0.1:18084
date: 2026-11-05T22:59:48Z commit: 763b0255575366082c4c6731b54611af717685a5
$ docker compose --env-file .env config --quiet && echo valid
valid
$ docker compose ps --format '{{.Service}} {{.Name}} {{.Status}} {{.Ports}}'
api hlpipe-lab4-grades-20261106-api-1 Up About a minute (healthy)
api hlpipe-lab4-grades-20261106-api-2 Up 52 seconds (healthy)
lb hlpipe-lab4-grades-20261106-lb-1 Up About a minute (healthy) 127.0.0.1:18084->8080/tcp, 127.0.0.1:24844->8404/tcp
postgres hlpipe-lab4-grades-20261106-postgres-1 Up About a minute (healthy)
s3 hlpipe-lab4-grades-20261106-s3-1 Up 25 seconds (healthy)
valkey hlpipe-lab4-grades-20261106-valkey-1 Up About a minute (healthy)
$ docker compose config | grep -c container_name
0
$ docker port <каждая реплика api> # реплики не публикуют порт
cff4a17e0883: []
f2e1260f6803: []
$ docker inspect: hostname = X-Instance-Id, сети, лимиты CPU (nano) и памяти
api cff4a17e0883 /hlpipe-lab4-grades-20261106-api-1 nets=hlpipe-lab4-grades-20261106_backend, cpus=1000000000 mem=536870912 user=10001:10001 ro=true
api f2e1260f6803 /hlpipe-lab4-grades-20261106-api-2 nets=hlpipe-lab4-grades-20261106_backend, cpus=1000000000 mem=536870912 user=10001:10001 ro=true
lb 5f001dc38f7f /hlpipe-lab4-grades-20261106-lb-1 nets=hlpipe-lab4-grades-20261106_backend,hlpipe-lab4-grades-20261106_edge, cpus=1000000000 mem=134217728 user=haproxy ro=true
postgres d390978734bf /hlpipe-lab4-grades-20261106-postgres-1 nets=hlpipe-lab4-grades-20261106_backend, cpus=2000000000 mem=1073741824 user=70:70 ro=false
s3 a1dccc133510 /hlpipe-lab4-grades-20261106-s3-1 nets=hlpipe-lab4-grades-20261106_backend, cpus=1000000000 mem=536870912 user=rustfs ro=true
valkey e17243696dd9 /hlpipe-lab4-grades-20261106-valkey-1 nets=hlpipe-lab4-grades-20261106_backend, cpus=500000000 mem=134217728 user=999:1000 ro=false
$ curl LB stats: backend api, server status check
api1 UP L7OK 200
api2 UP L7OK 200
BACKEND UP
$ for i in 1..6: curl -D - http://127.0.0.1:18084/health/live | X-Instance-Id
x-instance-id: cff4a17e0883
x-instance-id: f2e1260f6803
x-instance-id: cff4a17e0883
x-instance-id: f2e1260f6803
x-instance-id: cff4a17e0883
x-instance-id: f2e1260f6803
date: 2026-11-05T22:59:49Z commit: 763b0255575366082c4c6731b54611af717685a5
host: Apple M4 Max, 16 CPU, 48 GiB RAM, macOS 15.1
docker: 28.3.2, VM: 16 CPU, 8217190400 bytes
compose: 2.38.2-desktop.1
images:
image: ${API_IMAGE:-mtusi-messenger:${COMPOSE_PROJECT_NAME}}
image: rustfs/rc:v0.1.36@sha256:ab024bfebee49a750ce886b4c70963ccd9ddaa03f491704a90710641d7a26699
image: haproxy:3.2.26-alpine@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b
image: postgres:17.11-alpine@sha256:266d3c257594e195b309ae9d1805e54c788f1d7b375f56bf6c367aac6c917e7b
image: valkey/valkey:8.1.11-alpine@sha256:2602ace2be6569bc2bbb06f873776516ab9089821525be34f4305c67eb9db02a
image: rustfs/rustfs:1.0.4@sha256:ed9210d6411d77ffceb70d94b964a3cb7d225983368bc25bebe01e995293dcc2
image: grafana/k6:2.3.0@sha256:2dd4756ec6e14e62778916e1eb850108e4b499304c02df56760fa0bdb0fba0b8
FROM python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d AS builder
COPY --from=ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142 /uv /usr/local/bin/uv
FROM python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d AS runtime
python in image: Python 3.14.7
haproxy: HAProxy version 3.2.26-3e0f11a 2026/10/14 - https://haproxy.org/
rustfs: rustfs 1.0.4
packages (uv.lock):
fastapi 0.141.1
uvicorn 0.54.0
uvicorn-worker 0.4.0
gunicorn 26.2.0
sqlalchemy 2.0.45
alembic 1.16.5
asyncpg 0.32.0
argon2-cffi 25.1.0
pydantic 2.13.5
pydantic-settings 2.15.0
dishka 1.10.1
structlog 26.1.0
redis 8.1.0
aiobotocore 3.10.0
botocore 1.43.117
aiohttp 3.14.5
pillow 13.0.0
process users (service uid command):
api 10001 python
lb 99 haproxy
postgres 70 postgres
s3 10001 rustfs
valkey 999 tini
valkey 999 valkey-server
exit_code: 0 elapsed_seconds: 2.258
@@ -0,0 +1,33 @@
date: 2026-11-05T22:59:48Z commit: 763b0255575366082c4c6731b54611af717685a5
$ docker compose --env-file .env config --quiet && echo valid
valid
$ docker compose ps --format '{{.Service}} {{.Name}} {{.Status}} {{.Ports}}'
api hlpipe-lab4-grades-20261106-api-1 Up About a minute (healthy)
api hlpipe-lab4-grades-20261106-api-2 Up 52 seconds (healthy)
lb hlpipe-lab4-grades-20261106-lb-1 Up About a minute (healthy) 127.0.0.1:18084->8080/tcp, 127.0.0.1:24844->8404/tcp
postgres hlpipe-lab4-grades-20261106-postgres-1 Up About a minute (healthy)
s3 hlpipe-lab4-grades-20261106-s3-1 Up 25 seconds (healthy)
valkey hlpipe-lab4-grades-20261106-valkey-1 Up About a minute (healthy)
$ docker compose config | grep -c container_name
0
$ docker port <каждая реплика api> # реплики не публикуют порт
cff4a17e0883: []
f2e1260f6803: []
$ docker inspect: hostname = X-Instance-Id, сети, лимиты CPU (nano) и памяти
api cff4a17e0883 /hlpipe-lab4-grades-20261106-api-1 nets=hlpipe-lab4-grades-20261106_backend, cpus=1000000000 mem=536870912 user=10001:10001 ro=true
api f2e1260f6803 /hlpipe-lab4-grades-20261106-api-2 nets=hlpipe-lab4-grades-20261106_backend, cpus=1000000000 mem=536870912 user=10001:10001 ro=true
lb 5f001dc38f7f /hlpipe-lab4-grades-20261106-lb-1 nets=hlpipe-lab4-grades-20261106_backend,hlpipe-lab4-grades-20261106_edge, cpus=1000000000 mem=134217728 user=haproxy ro=true
postgres d390978734bf /hlpipe-lab4-grades-20261106-postgres-1 nets=hlpipe-lab4-grades-20261106_backend, cpus=2000000000 mem=1073741824 user=70:70 ro=false
s3 a1dccc133510 /hlpipe-lab4-grades-20261106-s3-1 nets=hlpipe-lab4-grades-20261106_backend, cpus=1000000000 mem=536870912 user=rustfs ro=true
valkey e17243696dd9 /hlpipe-lab4-grades-20261106-valkey-1 nets=hlpipe-lab4-grades-20261106_backend, cpus=500000000 mem=134217728 user=999:1000 ro=false
$ curl LB stats: backend api, server status check
api1 UP L7OK 200
api2 UP L7OK 200
BACKEND UP
$ for i in 1..6: curl -D - http://127.0.0.1:18084/health/live | X-Instance-Id
x-instance-id: cff4a17e0883
x-instance-id: f2e1260f6803
x-instance-id: cff4a17e0883
x-instance-id: f2e1260f6803
x-instance-id: cff4a17e0883
x-instance-id: f2e1260f6803
@@ -0,0 +1,5 @@
date: 2026-11-05T22:59:50Z commit: 763b0255575366082c4c6731b54611af717685a5
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ sh scripts/evidence-storage.sh
evidence/sqlalchemy-2026-11-06/grade3/{schema,migrations,kdf,secrets}.txt обновлены
exit_code: 0 elapsed_seconds: 3.825
@@ -0,0 +1,103 @@
date: 2026-11-05T22:59:45Z commit: 763b0255575366082c4c6731b54611af717685a5
$ docker compose ps --format '{{.Service}} {{.Status}} {{.Ports}}'
api Up About a minute (healthy)
api Up 50 seconds (healthy)
lb Up About a minute (healthy) 127.0.0.1:18084->8080/tcp, 127.0.0.1:24844->8404/tcp
migrate Exited (0) About a minute ago
postgres Up About a minute (healthy)
s3 Up 23 seconds (healthy)
s3-init Exited (0) About a minute ago
valkey Up About a minute (healthy)
$ psql -c '\d attachments'
Table "public.attachments"
Column | Type | Collation | Nullable | Default
-------------------+--------------------------+-----------+----------+---------
id | uuid | | not null |
chat_id | uuid | | not null |
owner_id | uuid | | not null |
filename | text | | not null |
content_type | text | | not null |
size_bytes | bigint | | not null |
sha256 | text | | not null |
width | integer | | not null |
height | integer | | not null |
object_key | text | C | not null |
status | text | | not null |
created_at | timestamp with time zone | | not null |
updated_at | timestamp with time zone | | not null |
quarantine_reason | text | | |
quarantined_at | timestamp with time zone | | |
Indexes:
"attachments_pkey" PRIMARY KEY, btree (id)
"attachments_chat_key" UNIQUE CONSTRAINT, btree (id, chat_id)
"attachments_object_key_key" UNIQUE CONSTRAINT, btree (object_key)
"attachments_pending_idx" btree (created_at) WHERE status = 'pending'::text
Check constraints:
"attachments_content_type_check" CHECK (content_type = ANY (ARRAY['image/png'::text, 'image/jpeg'::text]))
"attachments_filename_check" CHECK (char_length(filename) >= 1 AND char_length(filename) <= 255)
"attachments_height_check" CHECK (height > 0)
"attachments_quarantine_check" CHECK ((quarantine_reason IS NULL) = (quarantined_at IS NULL))
"attachments_quarantine_reason_check" CHECK (quarantine_reason = ANY (ARRAY['missing'::text, 'size_mismatch'::text, 'sha_mismatch'::text]))
"attachments_sha256_check" CHECK (sha256 ~ '^[0-9a-f]{64}$'::text)
"attachments_size_bytes_check" CHECK (size_bytes >= 1 AND size_bytes <= 10485760)
"attachments_status_check" CHECK (status = ANY (ARRAY['pending'::text, 'ready'::text]))
"attachments_width_check" CHECK (width > 0)
Foreign-key constraints:
"attachments_owner_fkey" FOREIGN KEY (chat_id, owner_id) REFERENCES chat_members(chat_id, user_id)
Referenced by:
TABLE "message_attachments" CONSTRAINT "message_attachments_attachment_fkey" FOREIGN KEY (attachment_id, chat_id) REFERENCES attachments(id, chat_id) ON DELETE RESTRICT
$ psql -c '\d message_attachments'
Table "public.message_attachments"
Column | Type | Collation | Nullable | Default
---------------+----------+-----------+----------+---------
message_id | uuid | | not null |
position | smallint | | not null |
chat_id | uuid | | not null |
attachment_id | uuid | | not null |
Indexes:
"message_attachments_pkey" PRIMARY KEY, btree (message_id, "position")
"message_attachments_attachment_idx" btree (attachment_id)
"message_attachments_message_id_attachment_id_key" UNIQUE CONSTRAINT, btree (message_id, attachment_id)
Check constraints:
"message_attachments_position_check" CHECK ("position" >= 0 AND "position" <= 9)
Foreign-key constraints:
"message_attachments_attachment_fkey" FOREIGN KEY (attachment_id, chat_id) REFERENCES attachments(id, chat_id) ON DELETE RESTRICT
"message_attachments_message_id_fkey" FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE CASCADE
$ psql: столбцы bytea во всей схеме (хеши токенов и отпечатки, не файлы)
table_name | column_name
------------------+-------------
idempotency_keys | fingerprint
sessions | token_hash
(2 rows)
$ psql: вложения по статусу и максимальный размер строки attachments
status | count | max_row_bytes
---------+-------+---------------
ready | 10 | 264
pending | 3 | 264
(2 rows)
$ rc object list --recursive root/messenger-attachments/attachments/ | count
10
$ rc object list root/messenger-attachments/ (первые 3 объекта, ключи назначены сервером)
[2026-11-05 22:58:21] 109.20 KiB attachments/01a1adef-432f-74b3-9212-2983a33641cd
[2026-11-05 22:58:21] 109.20 KiB attachments/01a1adef-45b4-753d-a583-15cfdd598dd2
[2026-11-05 22:58:34] 109.20 KiB attachments/01a1adef-788a-7696-bc0a-77207d3a287a
$ сверка вне API: sha256 и размер последнего ready-вложения в PostgreSQL против байтов объекта в bucket
postgres: 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75 111817
s3: 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75 111817
$ docker inspect api: ReadonlyRootfs, tmpfs, volumes/bind mounts
cff4a17e0883 ro=true tmpfs={"/tmp":""} mounts=bind:/run/secrets/cache_url bind:/run/secrets/cursor_secret bind:/run/secrets/s3_access_key_id bind:/run/secrets/s3_secret_access_key bind:/run/secrets/database_url
f2e1260f6803 ro=true tmpfs={"/tmp":""} mounts=bind:/run/secrets/s3_secret_access_key bind:/run/secrets/database_url bind:/run/secrets/cache_url bind:/run/secrets/cursor_secret bind:/run/secrets/s3_access_key_id
$ docker inspect s3: volume данных
volume:hlpipe-lab4-grades-20261106_s3data:/data bind::/run/secrets/s3_root_password bind::/run/secrets/s3_root_user
$ секреты сервисов: root-ключи S3 только у s3/s3-init/s3-cli
api ['cache_url', 'cursor_secret', 'database_url', 's3_access_key_id', 's3_secret_access_key']
lb []
migrate ['database_url']
postgres ['postgres_password']
s3 ['s3_root_password', 's3_root_user']
s3-init ['s3_access_key_id', 's3_reconciler_access_key_id', 's3_reconciler_secret_access_key', 's3_root_password', 's3_root_user', 's3_secret_access_key']
valkey ['valkey.conf']
@@ -0,0 +1,12 @@
date: 2026-11-05T22:54:43Z commit: 1aec062aba4560b51a6d9155571c9610bc777d7e
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ make student-test PYTEST_ARGS=-q
.venv/bin/pytest -q
........................................................................ [ 17%]
........................................................................ [ 35%]
........................................................................ [ 53%]
........................................................................ [ 71%]
........................................................................ [ 89%]
............................................ [100%]
404 passed, 19 deselected in 72.06s (0:01:12)
exit_code: 0 elapsed_seconds: 73.530
@@ -0,0 +1,149 @@
date: 2026-11-05T22:57:59Z commit: 1aec062aba4560b51a6d9155571c9610bc777d7e
environment: {"COMPOSE_PROJECT_NAME": "hlpipe-lab4-grades-20261106", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18084", "LB_STATS_PORT": "24844", "BASE_URL": "http://127.0.0.1:18084", "EVIDENCE_DIR": "evidence/sqlalchemy-2026-11-06/grade3", "NO_PROXY": "localhost,127.0.0.1,::1"}
$ make up
sh scripts/secrets.sh
docker compose up -d --build --wait
#1 [internal] load local bake definitions
#1 reading from stdin 446B done
#1 DONE 0.0s
#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 1.65kB done
#2 DONE 0.0s
#3 [internal] load metadata for docker.io/library/python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d
#3 DONE 0.0s
#4 [internal] load metadata for ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142
#4 DONE 0.0s
#5 [internal] load .dockerignore
#5 transferring context: 437B done
#5 DONE 0.0s
#6 [internal] load build context
#6 transferring context: 18.81kB done
#6 DONE 0.0s
#7 [builder 1/7] FROM docker.io/library/python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d
#7 resolve docker.io/library/python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d 0.0s done
#7 DONE 0.0s
#8 FROM ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142
#8 resolve ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142 done
#8 DONE 0.0s
#9 [builder 5/7] RUN uv sync --locked --no-dev --no-install-project --no-editable
#9 CACHED
#10 [builder 7/7] RUN uv sync --locked --no-dev --no-editable
#10 CACHED
#11 [runtime 5/6] COPY --chown=root:root alembic.ini ./
#11 CACHED
#12 [builder 4/7] COPY pyproject.toml uv.lock README.md ./
#12 CACHED
#13 [runtime 4/6] WORKDIR /app
#13 CACHED
#14 [builder 6/7] COPY src ./src
#14 CACHED
#15 [builder 2/7] COPY --from=ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142 /uv /usr/local/bin/uv
#15 CACHED
#16 [builder 3/7] WORKDIR /build
#16 CACHED
#17 [runtime 3/6] COPY --from=builder --chown=root:root /opt/venv /opt/venv
#17 CACHED
#18 [runtime 2/6] RUN groupadd --system --gid 10001 messenger && useradd --system --uid 10001 --gid messenger --no-create-home --shell /usr/sbin/nologin messenger
#18 CACHED
#19 [runtime 6/6] COPY --chown=root:root alembic ./alembic
#19 CACHED
#20 exporting to image
#20 exporting layers done
#20 exporting manifest sha256:efcfd8e45391397a3b1d9e97aac8e2eb4ec3ebbf81b1b32f274e3ff9662f2b18 done
#20 exporting config sha256:1b989fd9f1fe475c17919ffa36fb8b6c8ae3f48cb8235b14e1c8fc36fedbaffb done
#20 exporting attestation manifest sha256:68f2cf5de99b78132ddf04adc68f6930aa392182059e414bc71b5f02d8d9e07a done
#20 exporting manifest list sha256:c3b6030f4b3d406ada635dec2541637d5ae4b59c35524731f9c1e8dd3d391003 done
#20 naming to docker.io/library/mtusi-messenger:hlpipe-lab4-grades-20261106 done
#20 unpacking to docker.io/library/mtusi-messenger:hlpipe-lab4-grades-20261106 done
#20 DONE 0.0s
#21 resolving provenance for metadata file
#21 DONE 0.0s
api Built
Network hlpipe-lab4-grades-20261106_backend Creating
Network hlpipe-lab4-grades-20261106_backend Created
Network hlpipe-lab4-grades-20261106_edge Creating
Network hlpipe-lab4-grades-20261106_edge Created
Volume "hlpipe-lab4-grades-20261106_valkeydata" Creating
Volume "hlpipe-lab4-grades-20261106_valkeydata" Created
Volume "hlpipe-lab4-grades-20261106_s3data" Creating
Volume "hlpipe-lab4-grades-20261106_s3data" Created
Volume "hlpipe-lab4-grades-20261106_pgdata" Creating
Volume "hlpipe-lab4-grades-20261106_pgdata" Created
Container hlpipe-lab4-grades-20261106-s3-1 Creating
Container hlpipe-lab4-grades-20261106-lb-1 Creating
Container hlpipe-lab4-grades-20261106-postgres-1 Creating
Container hlpipe-lab4-grades-20261106-valkey-1 Creating
Container hlpipe-lab4-grades-20261106-valkey-1 Created
Container hlpipe-lab4-grades-20261106-s3-1 Created
Container hlpipe-lab4-grades-20261106-s3-init-1 Creating
Container hlpipe-lab4-grades-20261106-lb-1 Created
Container hlpipe-lab4-grades-20261106-postgres-1 Created
Container hlpipe-lab4-grades-20261106-migrate-1 Creating
Container hlpipe-lab4-grades-20261106-s3-init-1 Created
Container hlpipe-lab4-grades-20261106-migrate-1 Created
Container hlpipe-lab4-grades-20261106-api-2 Creating
Container hlpipe-lab4-grades-20261106-api-1 Creating
Container hlpipe-lab4-grades-20261106-api-1 Created
Container hlpipe-lab4-grades-20261106-api-2 Created
Container hlpipe-lab4-grades-20261106-postgres-1 Starting
Container hlpipe-lab4-grades-20261106-s3-1 Starting
Container hlpipe-lab4-grades-20261106-valkey-1 Starting
Container hlpipe-lab4-grades-20261106-lb-1 Starting
Container hlpipe-lab4-grades-20261106-s3-1 Started
Container hlpipe-lab4-grades-20261106-s3-1 Waiting
Container hlpipe-lab4-grades-20261106-valkey-1 Started
Container hlpipe-lab4-grades-20261106-postgres-1 Started
Container hlpipe-lab4-grades-20261106-postgres-1 Waiting
Container hlpipe-lab4-grades-20261106-lb-1 Started
Container hlpipe-lab4-grades-20261106-postgres-1 Healthy
Container hlpipe-lab4-grades-20261106-migrate-1 Starting
Container hlpipe-lab4-grades-20261106-migrate-1 Started
Container hlpipe-lab4-grades-20261106-s3-1 Healthy
Container hlpipe-lab4-grades-20261106-s3-init-1 Starting
Container hlpipe-lab4-grades-20261106-s3-init-1 Started
Container hlpipe-lab4-grades-20261106-s3-init-1 Waiting
Container hlpipe-lab4-grades-20261106-migrate-1 Waiting
Container hlpipe-lab4-grades-20261106-s3-init-1 Exited
Container hlpipe-lab4-grades-20261106-migrate-1 Exited
Container hlpipe-lab4-grades-20261106-api-2 Starting
Container hlpipe-lab4-grades-20261106-api-2 Started
Container hlpipe-lab4-grades-20261106-api-1 Starting
Container hlpipe-lab4-grades-20261106-api-1 Started
Container hlpipe-lab4-grades-20261106-postgres-1 Waiting
Container hlpipe-lab4-grades-20261106-api-2 Waiting
Container hlpipe-lab4-grades-20261106-api-1 Waiting
Container hlpipe-lab4-grades-20261106-valkey-1 Waiting
Container hlpipe-lab4-grades-20261106-s3-1 Waiting
Container hlpipe-lab4-grades-20261106-lb-1 Waiting
Container hlpipe-lab4-grades-20261106-s3-init-1 Waiting
Container hlpipe-lab4-grades-20261106-migrate-1 Waiting
Container hlpipe-lab4-grades-20261106-s3-init-1 Exited
Container hlpipe-lab4-grades-20261106-s3-1 Healthy
Container hlpipe-lab4-grades-20261106-migrate-1 Exited
Container hlpipe-lab4-grades-20261106-valkey-1 Healthy
Container hlpipe-lab4-grades-20261106-postgres-1 Healthy
Container hlpipe-lab4-grades-20261106-api-2 Healthy
Container hlpipe-lab4-grades-20261106-api-1 Healthy
Container hlpipe-lab4-grades-20261106-lb-1 Healthy
scripts/lb-wait.sh
exit_code: 0 elapsed_seconds: 11.254
@@ -1,3 +1,6 @@
schema: spec-driven
created: 2026-11-06
skip_specs: true
archived: 2026-11-06
lab: 4
@@ -1,14 +1,14 @@
## 1. Подготовка
- [x] 1.1 Добавить безопасный захват сырого вывода и отдельный каталог серии.
- [ ] 1.2 Выполнить check/validate/lint/student-test, поднять собственный новый стенд.
- [x] 1.2 Выполнить check/validate/lint/student-test, поднять собственный новый стенд.
## 2. Проверки уровня 3
- [ ] 2.1 Выполнить smoke, persistence, failover с состояниями контейнеров.
- [ ] 2.2 Выполнить upload-failover, три S3-outage, негативные файлы и проверку приватности/layout.
- [ ] 2.3 Подтвердить минимум ЛР3: две реплики, общий токен, гонки Idempotency-Key и потерянный ответ.
- [x] 2.1 Выполнить smoke, persistence, failover с состояниями контейнеров.
- [x] 2.2 Выполнить upload-failover, три S3-outage, негативные файлы и проверку приватности/layout.
- [x] 2.3 Подтвердить минимум ЛР3: две реплики, общий токен, гонки Idempotency-Key и потерянный ответ.
## 3. Завершение
- [ ] 3.1 Записать матрицу критерий/команда/наблюдение/файл; архивировать только после PASS.
- [x] 3.1 Записать матрицу критерий/команда/наблюдение/файл; архивировать только после PASS.