ЛР 5 - БВТ2301 - Шептунов - на 5 #5

Closed
kittsune wants to merge 1 commits from kittsune/mtusi2026lab5:solution/bvt2301-sheptunov into main
96 changed files with 17965 additions and 21 deletions
+2
View File
@@ -18,3 +18,5 @@ __pycache__
node_modules
evidence
.DS_Store
.secrets
+2
View File
@@ -30,3 +30,5 @@ coverage/
.vscode/
# Keep small, sanitized evidence summaries in evidence/ under version control.
# Inspect git diff --cached: ignore rules are not a secret scanner.
.secrets/
+30
View File
@@ -0,0 +1,30 @@
FROM python:3.12.10-slim-bookworm
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
APP_HOST=0.0.0.0 \
APP_PORT=8080
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir --requirement requirements.txt \
&& groupadd --system --gid 10001 app \
&& useradd --system --uid 10001 --gid app --home-dir /nonexistent --shell /usr/sbin/nologin app
COPY --chown=app:app src ./src
COPY --chown=app:app migrations ./migrations
COPY --chown=app:app scripts ./scripts
COPY --chown=app:app student-tests ./student-tests
COPY --chown=app:app tests ./tests
COPY --chown=app:app contracts ./contracts
COPY --chown=app:app lab.json ./lab.json
RUN mkdir -p evidence && chown app:app evidence
USER 10001:10001
EXPOSE 8080
HEALTHCHECK --interval=10s --timeout=3s --start-period=3s --retries=3 \
CMD ["python", "/app/scripts/healthcheck.py"]
CMD ["sh", "-c", "exec uvicorn src.main:app --host \"${APP_HOST}\" --port \"${APP_PORT}\" --workers 1 --timeout-graceful-shutdown 8"]
+31
View File
@@ -28,3 +28,34 @@ test-persistence:
test-failover:
@test -n "$(ACTION_SCRIPT)" || (echo "Set ACTION_SCRIPT to your implemented executable stop-one hook"; exit 2)
$(PYTHON) tests/resilience.py --mode failover --action-script "$(ACTION_SCRIPT)" --base-url "$(BASE_URL)" $(TLS_ARGS)
.PHONY: setup start ready student-checks test-files test-file-failover test-pipeline experiment cleanup stop test-dependencies test-expiry
setup:
bash scripts/setup.sh
start:
bash scripts/start.sh
ready:
BASE_URL="$(BASE_URL)" $(PYTHON) scripts/stack.py wait --count 2
student-checks:
$(PYTHON) student-tests/test_api.py --base-url "$(BASE_URL)"
$(PYTHON) student-tests/checks.py --base-url "$(BASE_URL)"
$(PYTHON) student-tests/idempotency.py --base-url "$(BASE_URL)"
docker exec "$$(docker compose ps --status running -q api | head -n 1)" python student-tests/database.py
test-files:
$(PYTHON) student-tests/attachments.py --base-url "$(BASE_URL)"
$(PYTHON) student-tests/variants.py --base-url "$(BASE_URL)"
test-file-failover:
BASE_URL="$(BASE_URL)" $(PYTHON) student-tests/file_failover.py
test-pipeline:
BASE_URL="$(BASE_URL)" $(PYTHON) scripts/experiment.py --repeats 1
experiment:
BASE_URL="$(BASE_URL)" $(PYTHON) scripts/experiment.py --repeats 3
cleanup:
docker compose run --rm --no-deps reconciler python -m src.cleanup
stop:
docker compose down
test-dependencies:
BASE_URL="$(BASE_URL)" $(PYTHON) student-tests/dependencies.py
test-expiry:
bash scripts/test_expiry.sh
+392 -21
View File
@@ -1,37 +1,408 @@
# Отчёт — лабораторная 5
# Лабораторная 5 — очередь и обработка изображений
- Автор, группа: TODO
- Целевая оценка; выбранный трек 5, если нужен: TODO
- Commit/PR: TODO после публикации
- Использованные источники, библиотеки и помощь ИИ: TODO
- Автор: Максим Шептунов, БВТ2301.
- Целевая оценка: 5, трек 2 — «Доказанная идемпотентность pipeline».
- Skeleton lab5: `276dbdad8a34da4c5b57fbf1879ca169b581d75b`.
- Заявленная основа подготовленного решения: собственная lab4, commit `16709c91b3e06028b10d72095fb1e5d2bacbc5ef`; соответствие этому commit отдельно не перепроверялось.
- Проверка: 26 октября 2026, WSL2 Ubuntu 22.04 / Docker Desktop. Факты окружения: evidence/local_environment.json.
- Помощь ИИ: подготовка реализации и собственных проверок
- Основные библиотеки: FastAPI 0.115.12, Uvicorn 0.34.2, Psycopg 3.2.9, redis-py 5.2.1, Pillow 12.0.0, boto3 1.40.18, argon2-cffi 23.1.0; полный фактический список — evidence/runtime_versions.json.
README задания, обязательный контракт и публичные tests сохранены. Отдельного
файла миграции решения нет: перенос и переход API описаны здесь. Результаты ниже взяты из текущих логов WSL; прежняя облачная проверка не считается Docker-прогоном.
## Запуск из чистого clone
TODO: версии runtime/образов, prerequisites, команды создания локальных secrets/.env, build, миграций, запуска, ожидания готовности, тестов и остановки. Указать необходимые действия оператора. Не вставлять секреты. Отдельно указать безопасную остановку и команду намеренного удаления учебных данных.
Нужны Docker Desktop/Engine с Compose v2/BuildKit, Linux amd64, Python 3.10+ на
хосте. В Windows используется WSL2 Ubuntu. Порт 8080 должен быть свободен; при занятом порте сначала нужно установить владельца. При текущем запуске других работающих контейнеров не было. Для сборки нужен доступ к Docker Hub,
PyPI и GitHub Releases.
## Архитектура и решения
```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt -r requirements-experiment.txt
chmod +x scripts/*.sh
make setup
make start
make ready
make check
make validate
make test
make student-checks
make test-files
make test-persistence ACTION_SCRIPT=scripts/restart.sh
make test-failover ACTION_SCRIPT=scripts/stop-one.sh
bash scripts/restore-api.sh
make ready
make test-file-failover
make test-dependencies
make test-expiry
make experiment
make ready
make test
```
TODO: схема процессов/хранилищ, источник истины, транзакционные границы, ограничения. Что перенесено из lab4, что изменено в этой работе. Соответствие переменных из .env.example реальной конфигурации.
Безопасная остановка с сохранением данных: `make stop`. Намеренное удаление
учебных данных текущего проекта: `docker compose down -v`; эта команда не
применяется в проверках сохранности.
`setup.sh` создаёт `.env` и случайные secrets в `.secrets`. Повторный setup не
меняет существующие пароли. Папка имеет права 700; файлы для UID10001 — 644 внутри
закрытой папки. Пароль PostgreSQL, MinIO root и broker password — 600. API не
получает root credentials и broker URL. В Git и build context secrets не входят.
Все роли приложения собираются в один локальный image `mtusi2026lab5-app:1`.
База — Python 3.12.10 slim-bookworm. PostgreSQL 16.9 bookworm; cache и broker —
Redis 7.4.3 bookworm; HAProxy 3.0.11 bookworm. MinIO RELEASE.2025-04-22T22-12-26Z
и mc RELEASE.2025-04-16T18-13-26Z скачиваются из официальных GitHub Releases в
`infra/s3.Dockerfile`; закреплённые SHA-256 проверяются во время сборки.
После старта работают db, cache, broker, s3, две api, lb, dispatcher, worker и
reconciler. `migrate` и `s3-bootstrap` завершаются с кодом 0 — это нормально.
Общий `start.sh` не использует Compose `--wait`, поскольку у фоновых процессов
нет HTTP healthcheck. Две готовые API отдельно ожидаются через LB.
Readiness API проверяет PG и S3; отсутствие worker не запрещает durable приём.
Сам прогресс pipeline проверяется smoke, статусами job и отдельными сценариями.
Лимиты: каждая API 1 CPU/512 MiB; worker 1 CPU/768 MiB; PG и S3 по 1 CPU/512 MiB;
broker 0.5 CPU/256 MiB; dispatcher и reconciler по 0.5 CPU/256 MiB;
cache/LB по 0.5 CPU/128 MiB. Фактические значения сохраняются через inspect.
Docker-логи ограничены: 5 MiB × 2 файла на контейнер.
## Перенос и архитектура
Перенесены пользователи, Argon2id, PostgreSQL-сессии, Redis-кеш профиля, чаты,
сообщения, keyset-пагинация, общая идемпотентность, две API, HAProxy и приватный
MinIO. Сохранены проверка типов cursor (400 invalid_request), выбор реально
работающего контейнера вместо жёсткого индекса и исправление общего `--wait`.
Исследования масштабирования lab3 и сверки lab4 повторно не требуются.
Изменён объявленный переход lab4 → lab5: upload возвращает **202 queued**,
а готовность определяется GET метаданных. Все bytes по-прежнему передаются в HTTP.
Сообщение может ссылаться на queued/processing; failed прикреплять нельзя (409).
Content для queued/processing/failed — 409. Для ready доступны original,
thumbnail, crop, optimized; неизвестный вариант — 404. ACL чата проверяется
при каждом запросе метаданных и содержимого. Публичный ответ не раскрывает S3 keys.
Роли и источник истины:
- API принимает ограниченный файл и фиксирует намерение. SQL — источник сессий,
метаданных, статусов, версий, attempts и outbox.
- Отдельный persistent Redis Streams — broker. Cache профилей остаётся другим
сервисом Redis: сброс кеша не затрагивает очередь.
- Dispatcher публикует outbox и восстанавливает брошенные leases.
- Worker забирает задания consumer group, обрабатывает изображение в дочернем
процессе и публикует результат.
- Reconciler в этой лабораторной выполняет безопасную очистку staging.
- MinIO хранит staging, неизменённые оригиналы и готовые варианты.
Наружу опубликован только LB `127.0.0.1:8080`. Консоль MinIO выключена и привязана
к loopback контейнера. Ограниченный S3-пользователь общий для API/worker: операции
разрешены только в originals/, variants/, staging/ указанного bucket; нет IAM и
создания bucket. Broker защищён отдельным паролем, публичного порта нет.
### Что сохранено к моменту 202
1. API потоково пишет максимум 10485760 bytes во временный файл. Проверяет MIME,
filename, структуру PNG/JPEG и максимум 40000000 pixels до полного декодирования.
Для JPEG проверяется наличие EOI. Считаются SHA-256 и transport Content-MD5.
2. Под блокировкой UUID вложения сохраняет полный исходник в S3 staging.
3. Одной SQL-транзакцией создаёт attachment queued, job и outbox. Общая admission
блокировка ограничивает число queued/processing заданиями MAX_PENDING_JOBS.
4. После COMMIT возвращает снимок queued, даже если worker уже успел завершиться.
API не делает resize и полное декодирование пикселей. Нераспознаваемый формат/
очевидное повреждение/MIME mismatch — 415, лимиты bytes/pixels — 413, опасное имя —
400. Повреждение, обнаруженное только при полном декодировании, становится failed
с безопасным кодом worker. Временный файл API не является durable staging.
При неопределённом COMMIT staging немедленно не удаляется.
### Broker, outbox и подтверждения
Broker использует Redis Streams consumer group `image-workers`, AOF и
`appendfsync always`, persistent volume, `maxmemory-policy noeviction`.
`XADD` отвечает producer после записи по выбранной AOF-политике. Если publish
прошёл, но dispatcher умер до фиксации published_at, он может отправить дубль.
Если умер до publish, незавершённый outbox будет опубликован после восстановления.
Carrier соответствует `contracts/jobs.schema.json`: schema_version, job_id,
type, attachment_id, pipeline_version, attempt, created_at. Нет bytes, credentials,
URL или клиентского пути. Worker сверяет job с доверенными metadata в PG.
Некорректный carrier попадает в broker_rejections с hash/кодом, без исходного тела.
`XACK` выполняется после ready/устойчивого terminal no-op либо после фиксации
следующей попытки в outbox/окончательного failed. Pending после смерти consumer
забирается через XAUTOCLAIM. Publisher acknowledgement и consumer ack относятся
к разным границам; доставка остаётся at least once.
### Обработка, ограничения и варианты
Исходник скачивается из staging с ограничением bytes и проверкой SHA-256. Затем
отдельный процесс Pillow полностью декодирует изображение, применяет EXIF
orientation, ограничивает pixels и адресное пространство до 512 MiB. Родитель
ограничивает время job (по умолчанию 30 s), включая проверяемые этапы download,
преобразования и PUT. Синхронный вызов S3 может закончиться позже deadline на
величину своего сетевого timeout (connect/read 2/5 s; Docker DNS timeout 1 s, attempts 1).
На worker по умолчанию concurrency=1 и prefetch=1 на consumer. API допускает
четыре ограниченных upload на процесс; сверх очереди MAX_PENDING_JOBS=1000
новые приёмы получают 503. Значения 1..4 concurrency доступны, но увеличение
требует отдельного бюджета RAM и измерений; в исследовании используется 1.
Worker публикует неизменённый original и три варианта:
| Вариант | Формат и правила |
| --- | --- |
| thumbnail | JPEG, вписан в 256×256, без увеличения, размеры округляются вниз |
| crop | JPEG, центрированный квадрат 128×128, маленькие изображения увеличиваются |
| optimized | WebP, вписан в 1280×1280, без увеличения |
Alpha компонуется на белый. EXIF/ICC/XMP в вариантах не сохраняются. Качество
JPEG/WebP — 82 для pipeline v1 и 86 для v2; WebP method=4, JPEG optimize=true.
Original не перекодируется. WebP не обязан быть меньше каждого маленького PNG.
Ready фиксируется только после оригинала и всех трёх вариантов, вместе с их
размерами/checksums и внутренними keys.
### Lease, retry, failed и replay
Worker держит PostgreSQL session advisory lock на attachment UUID. При захвате
фиксирует processing, очередную attempt, lease token и deadline. Dispatcher
возвращает истёкший processing в очередь только если общий lock свободен.
Lease=15 s может истечь во время корректной длинной обработки; активный lock
защищает её. Зависшая обработка ограничена job timeout и лимитами процесса.
Одна попытка не равна одному broker redelivery: устаревшие attempts и дубли
завершённых jobs подтверждаются без повторной обработки. По умолчанию максимум
5 управляемых попыток. Для временных сетевых/хранилищных ошибок — exponential
backoff с jitter, базовая пауза до 10 s + 0..0.5 s. Невалидный исходник, отсутствие
staging и неверные S3 credentials — постоянные ошибки. После исчерпания временных
попыток error_code=retry_exhausted. Текст SDK/stack trace наружу не выдаётся.
DLQ реализована как устойчивый реестр jobs со status=failed плюс job_events.
Команды выполняются оператором внутри контейнера; публичного admin endpoint нет:
```bash
docker compose exec -T dispatcher python -m src.jobs failed
docker compose exec -T dispatcher python -m src.jobs inspect JOB_UUID
docker compose exec -T dispatcher python -m src.jobs replay JOB_UUID
docker compose exec -T dispatcher python -m src.jobs version ATTACHMENT_UUID 2
```
Replay разрешён только для текущей failed job при доступном staging. Job ID
и effect key сохраняются; номер attempt растёт, новый бюджет начинается после
явного replay. Уже ready → noop; старая версия не активируется replay-командой.
Версия повышается только отдельной операторской командой.
### Версии и идемпотентность эффекта
Ключ эффекта — `(attachment_id, pipeline_version, variant)`. В PG уникальна пара
attachment/version; S3 keys детерминированы и включают version. Повтор может ещё
раз выполнить PUT в тот же key, но не создаёт дополнительные variants.
Перед processing проверяется current_job_id/version; перед публикацией — ещё
lease token и условный UPDATE текущей версии. Общий lock сериализует изменения.
Старая job после появления v2 становится no-op и не откатывает ready в processing.
Вторая версия действительно меняет настройки encoder, а не только название.
Это не exactly-once доставка: XADD/получение/PUT могут повториться. Проверяется
однократная публикация устойчивого результата одной job и отсутствие перезаписи
текущего результата старой версией.
### Очистка и retention
После ready staging удаляется; отдельная сверка каждые 60 s повторяет очистку,
если worker умер после COMMIT. Failed/superseded staging и объекты без job
хранятся 86400 s. Перед удалением повторно проверяются PG, реальный LastModified
и общий lock; queued/processing не удаляются. Dry-run по умолчанию:
```bash
make cleanup
docker compose run --rm --no-deps reconciler python -m src.cleanup --apply
```
Предыдущие опубликованные версии original/variants оставлены для аудита; их
автоматический GC не заявляется. Старые lab4 ready-оригиналы сохраняются миграцией;
варианты для них можно создать командой новой версии. Переносится реализация,
старые Docker volumes между разными проектами автоматически не подключаются.
## Доказательства критериев
| Критерий README | Команда/сценарий | Наблюдаемый результат | Файл доказательства |
Структура и OpenAPI проверены отдельно от работающего HTTP-приложения. Ниже результаты текущего последовательного прогона. Полный трек 2 завершён: status=PASS, checks=39; финальный HTTP smoke прошёл после серии и дополнительного отказа второй API.
| Критерий | Команда | Наблюдение моего стенда | Evidence |
| --- | --- | --- | --- |
| Публичный smoke | make test | TODO | TODO |
| Остальные пункты уровня 3 | TODO | TODO | TODO |
| Все пункты уровня 4, если заявлен | TODO | TODO | TODO |
| Выбранный трек 5, если заявлен | TODO | TODO | TODO |
| Структура/OpenAPI | make check; make validate | PASS: структура, ссылки, синтаксис и OpenAPI 3.1 | local_check.txt, local_validate.txt |
| Обязательный lab5 API | make test | PASS: публичный сквозной HTTP-сценарий | local_smoke.txt, local_final_smoke.txt |
| Минимум предыдущих работ, SQL/cursor/ключи | make student-checks | PASS: гонки регистрации, 100 сообщений от 10 клиентов, cursor, idempotency и SQL rollback | local_student_checks.txt, idempotency.json |
| Отрицательные файлы, ACL и сообщение с вложением | make test-files | PASS: MIME/filename/bytes/pixels, ACL, повтор сообщения | local_files.txt |
| Реальные thumbnail/crop/WebP, EXIF/alpha/маленький файл | make test-files | PASS: реальные форматы, размеры, белый фон, EXIF orientation, отсутствие увеличения | local_files.txt |
| Перезапуск всех хранилищ и прежняя сессия | make test-persistence | PASS: подтверждённые данные, original и старая сессия сохранены; 4 хранилища перезапущены | local_persistence.txt, containers_before_retry.json, containers_after_restart.json, persistence_scope.json |
| Отказ одной API и original через другую | make test-failover; make test-file-failover | PASS: 114 подтверждённых записей, 3 неудачные попытки, восстановление 2.581 s; original через другую API | local_failover.txt, local_file_failover.txt, attachment_failover.json |
| Redis/PG outage, expiry | make test-dependencies; make test-expiry | PASS: fallback без cache, PG → 503 и восстановление прежних данных/сессии; TTL=2 s → отказ истёкшей сессии | dependencies.json, local_dependencies.txt, local_expiry.txt |
| Worker stop, queued message, API/broker restart | make experiment | PASS ×3: 202 при выключенном worker, queued message, прежние stream IDs и ready после рестартов | pipeline_raw.json: accepted_restart_broker_api |
| Outbox COMMIT/publish и publish/mark crash | make experiment | PASS ×3 для каждого окна: outbox доставил прежнюю job после реального crash dispatcher | pipeline_raw.json: before_publish, after_publish |
| Crash до/после S3 и до ack, lease recovery | make experiment | PASS ×3 для каждого окна: до ready — 2 попытки; после COMMIT ready — 1 попытка | pipeline_raw.json: before_effect, after_original, after_effects, after_commit |
| Дубли и схема carrier | make experiment | PASS ×3: по 16 дублей, неизменные metadata/bytes, неверный carrier отклонён | pipeline_raw.json: duplicates_and_invalid_carrier |
| Reorder и stale после новой версии | make experiment | PASS ×3 для каждого случая: v2 сохранена, v1 не меняет текущие bytes/metadata | pipeline_raw.json: reorder_new_before_old, stale_after_new_ready |
| Постоянная ошибка и безопасный replay | make experiment | PASS ×3: staging_missing → явный replay той же job → ready; replay ready = noop | pipeline_raw.json: permanent_failure_replay |
| Физический S3 outage, пять попыток, failed/replay | make experiment | PASS ×3: retry_exhausted после 5 попыток; replay → ready на 6-й попытке | pipeline_raw.json: bounded_retry_and_replay |
| Retention, fresh/active и приватность | make experiment | PASS ×3: старый orphan удалён, fresh/queued сохранены, anonymous GET=403 | pipeline_raw.json: staging_retention_and_privacy |
TODO: добавить отдельную строку для каждого заявленного критерия. PASS без команды и наблюдения не является доказательством. Проверка инфраструктурного hook требует подтверждения, какие реальные процессы/хранилища перезапущены.
### Фактическое окружение и найденная ошибка
## Эксперименты и отказы
Intel Core i5-1240P; WSL видит 16 CPU. Docker Server 26.1.1, Compose
2.27.0-desktop.2; Docker видит 16 CPU и 8 187 711 488 bytes RAM.
Хостовый Python 3.10.12, runtime контейнера 3.12.10.
Фактические runtime/библиотеки/image IDs и mounts — runtime_versions.json.
Broker подтверждён с AOF=1, appendonly=yes, appendfsync=always и noeviction
(broker_runtime.json). Лимиты контейнеров сохранены в containers_before_retry.json и
containers_after_restart.json; факт перезапуска db/cache/s3/broker —
в persistence_scope.json.
TODO: гипотеза, hardware/лимиты, версии, объём данных, профиль нагрузки, concurrency/arrival rate, длительность/прогрев, повторы, успешные RPS, ошибки, p50/p95/p99, CPU/RAM. Сохранить raw summary без tokens и объяснить ограничения измерения.
Первый persistence выявил дефект infra/broker-entrypoint.sh: после первого
запуска /tmp/broker.conf принадлежал redis; повторная root redirection в sticky
/tmp блокировалась Linux protected_regular («Permission denied»).
Конфиг перенесён в /run/broker/broker.conf внутри root-owned каталога.
AOF, Redis-настройки и volume сохранены. После исправления persistence прошёл.
Неудачные логи сохранены в local_persistence_failed_initial.txt,
local_restart_diagnostic.txt, broker_restart_diagnostic.txt; успешный повтор —
local_restart_fixed.txt и local_persistence.txt.
Попытка запустить persistence до восстановления остановленного стенда также
сохранена отдельно: local_persistence_failed_stopped_stack.txt.
| Воздействие | Что ожидаем | Что наблюдали | Время восстановления / потеря данных |
| --- | --- | --- | --- |
| TODO | TODO | TODO | TODO |
Перед переносом рабочий Git был чист от tracked-изменений; существовали только
пользовательские AGENTS.md и CODEX_HANDOFF.md. Сохранены они и .git.
Решение распаковано из incoming/mtusi2026lab5_solution.zip; добавлено 47 файлов,
изменены .dockerignore, .gitignore, Makefile и REPORT.md, 32 файла совпали.
Сравнение — import_comparison.json. Текущий upstream HEAD совпал со skeleton.
Контракты, публичные tests, README и COURSE не изменены. Старые лабы и volumes
не удалялись; commit/push/MR не выполнялись.
## Ограничения и следующие шаги
## Эксперимент на 5
TODO: какие отказы выдерживаются и какие нет; что не реализовано; где учебное упрощение; какое улучшение подтверждено, а какое пока гипотеза.
Гипотеза: durable staging/outbox, consumer group, versioned keys и проверка версии
при COMMIT позволяют пережить дубли, reorder и crashes без потери подтверждённой
работы и публикации старого результата поверх нового.
`make experiment` выполняет 13 случаев по три раза — 39 проверок. Для каждого
создаются новые синтетические пользователи/чат/attachment/job; fixture 320×200.
Worker concurrency=1, prefetch=1, максимум 5 попыток; остальные лимиты выше.
Настройки, версии Docker/Compose, actual containers/limits фиксируются в
pipeline_environment.json. В research серии не измеряется предельный throughput.
Fault injection — адресные одноразовые checkpoints для конкретного job UUID.
Они выключены при обычном ALLOW_FAULT_INJECTION=0. Скрипт временно пересоздаёт
worker/dispatcher с флагом 1. После устойчивой отметки checkpoint выполняется
os._exit: нет finally и ack, процесс реально умирает, Docker restart:on-failure
возвращает его. В evidence сохраняются fired_at, events, aliases/RestartCount
и состояния контейнеров. После эксперимента флаг возвращается в 0.
Проверки не создают вручную новое задание для исправления outbox: accepted job
должна восстановиться сама. Для дубликатов/reorder намеренно публикуются повторные
carrier уже существующих jobs. Поздний v1 проверяется после готового v2.
При S3 outage сервис физически остановлен; после failed возвращается S3,
оператор явно запускает replay той же job.
Для каждого ready проверяются original/checksum, три варианта/checksums,
ровно четыре key текущей версии, один ready event на job, очистка staging.
В duplicate/stale случаях сравнивается весь публичный Attachment до/после:
ID, updated_at, variants и checksums не должны измениться. При broker restart
проверяются те же опубликованные stream IDs после восстановления volume.
Raw: `evidence/pipeline_raw.json`; сводка: `pipeline_summary.json`.
Каждый случай содержит длительность сценария с управляющими действиями Docker,
attempts, job events/outbox и результат инвариантов. queued_to_ready_seconds
считается между SQL-временем создания job и публикации ready, включая намеренные
остановки. Эти времена не являются чистой стоимостью resize или production SLA.
При незавершённом/ошибочном запуске summary не остаётся старым PASS.
### Реальные результаты 26.10.2026
Полная команда: `make experiment` (repeats=3). Итог: **PASS, 39/39**,
все 13 случаев завершились по три раза. Сумма длительностей сценариев —
1947.325 s (32.46 min); это последовательный эксперимент с управлением
Docker и намеренными остановками, включая backoff и lease.
Fixture — PNG 320×200, 111817 bytes, SHA-256
`99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75`.
Рабочая конфигурация: concurrency=1, prefetch=1, lease=15 s,
timeout=30 s, максимум 5 попыток до явного replay.
Отдельный прогрев и нагрузочный профиль не применялись: это проверка
корректности при отказах, не измерение предельного throughput.
RPS и p95/p99 resize в этом треке не измерялись.
| Сценарий | Итог | Медиана полного сценария, s | Attempts итоговой job |
| --- | --- | ---: | ---: |
| accepted_restart_broker_api | 3/3 PASS | 62.692 | 1 |
| before_publish | 3/3 PASS | 45.890 | 1 |
| after_publish | 3/3 PASS | 44.544 | 1 |
| before_effect | 3/3 PASS | 45.350 | 2 |
| after_original | 3/3 PASS | 43.115 | 2 |
| after_effects | 3/3 PASS | 46.272 | 2 |
| after_commit | 3/3 PASS | 36.306 | 1 |
| duplicates_and_invalid_carrier | 3/3 PASS | 36.795 | 1 |
| reorder_new_before_old | 3/3 PASS | 57.728 | 1 |
| stale_after_new_ready | 3/3 PASS | 54.823 | 1 |
| permanent_failure_replay | 3/3 PASS | 56.230 | 2 |
| bounded_retry_and_replay | 3/3 PASS | 75.655 | 6 |
| staging_retention_and_privacy | 3/3 PASS | 37.404 | 1 |
Время сценария включает создание данных, Docker stop/recreate/start, ожидание
готовности и проверки. queued_to_ready_seconds в raw — отдельное SQL-время
от создания job до ready; оно также включает намеренные простои.
Эти результаты не являются SLA и не сравнивают производительность компьютеров.
Во всех ready snapshot проверены побайтный original и его checksum, checksums
трёх вариантов, ровно четыре key текущей версии и один ready event на job.
Во всех девяти случаях crash worker до ready (3 окна ×3) job завершилась
на второй попытке; после COMMIT ready во всех трёх повторах осталась одна попытка.
В каждом bounded_retry_and_replay зафиксирован failed после ровно пяти попыток
и ready той же job после операторского replay на шестой. Без replay бесконечных
попыток не было. В каждом duplicate-сценарии доставлено и подтверждено 16 дублей
(48 суммарно); весь публичный Attachment и bytes остались прежними.
Во всех шести проверках reorder/stale current_version=2; настройки v2 действительно
изменили bytes вариантов относительно v1. Это согласуется с гипотезой в пределах
проверенных окон сбоев; потери диска или целого host эксперимент не моделирует.
После эксперимента выполнены make ready и make test, затем дополнительный
публичный failover именно mtusi2026lab5-api-2: 110 подтверждённых записей,
4 неудачные попытки, first_recovery_seconds=2.521. Первый публичный failover
и file failover останавливали api-1: 114 подтверждённых записей/3 неудачные
попытки/2.581 s; original скачан другой API за 2.386 s, failed_attempts=0.
Дополнительные доказательства: local_failover_additional_1.txt,
api_failover_additional_1.json, attachment_failover.json.
После восстановления повторно прошли ready и публичный smoke.
Две API и все фоновые службы работают; migrate и s3-bootstrap завершены с code=0.
Fault injection у worker/dispatcher/reconciler выключен (все флаги 0);
факты — runtime_versions.json, containers_final.json.
Host и container pip check не нашли конфликтов зависимостей.
Аудит: обязательные contracts/, tests/, README и COURSE совпали с Git HEAD
и исходным решением; git diff --check прошёл. Проверка evidence и неигнорируемых
файлов на фактические значения локальных secrets и поля токенов — final_audit.json.
Секреты, .env и .venv остались локальными. Commit/push/MR не выполнялись.
## Ограничения и источники
Один host, LB, PG, S3 и broker остаются SPOF. Проверяются перезапуски с сохранением
volumes, не потеря диска. Физически потерянный исходник нужен из внешней копии.
AOF/persistent volume не заменяют резервную копию и репликацию.
Stream, outbox и job_events автоматически не обрезаются; для длительной работы
нужен retention с учётом PEL и аудита. Broker ограничен 192 MiB/noeviction:
при невозможности XADD outbox сохраняется, затем MAX_PENDING_JOBS ограничивает
новые приёмы. Для прерванного до 202 HTTP-приёма гарантии задания нет; staging
без намерения очищается по retention. Дубликат upload может создать новый attachment.
Поддерживаются pipeline версии 1 и 2. Параметры качества закреплены версией кода;
их нельзя произвольно менять под прежним номером pipeline. Переключение версии
явное и доступно только оператору. Горизонтальное масштабирование worker требует
общего PG/broker/S3 и отдельного бюджета CPU/RAM; исследование concurrency/prefetch
трек 1 не заявляется.
Источники: README/COURSE/OpenAPI/jobs.schema/attachment-states lab5, собственная lab4;
[Redis Streams](https://redis.io/docs/latest/develop/data-types/streams/),
[XAUTOCLAIM](https://redis.io/docs/latest/commands/xautoclaim/),
[Redis AOF](https://redis.io/docs/latest/operate/oss_and_stack/management/persistence/),
[PostgreSQL locks](https://www.postgresql.org/docs/16/explicit-locking.html),
[Pillow ImageOps](https://pillow.readthedocs.io/en/stable/reference/ImageOps.html),
[MinIO release](https://github.com/minio/minio/releases/tag/RELEASE.2025-04-22T22-12-26Z).
+389
View File
@@ -0,0 +1,389 @@
services:
db:
image: postgres:16.9-bookworm
environment:
POSTGRES_DB: messenger
POSTGRES_USER: messenger
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
secrets:
- db_password
volumes:
- postgres_data:/var/lib/postgresql/data
cpus: 1.0
mem_limit: 512m
healthcheck:
test:
- CMD-SHELL
- pg_isready -U messenger -d messenger
interval: 2s
timeout: 3s
retries: 30
logging:
driver: json-file
options:
max-size: 5m
max-file: '2'
cache:
image: redis:7.4.3-bookworm
command:
- redis-server
- --appendonly
- 'yes'
- --appendfsync
- everysec
volumes:
- redis_data:/data
cpus: 0.5
mem_limit: 128m
healthcheck:
test:
- CMD
- redis-cli
- ping
interval: 2s
timeout: 3s
retries: 30
logging:
driver: json-file
options:
max-size: 5m
max-file: '2'
migrate:
build: .
command:
- python
- -m
- src.migrate
environment:
DATABASE_URL_FILE: /run/secrets/database_url
secrets:
- database_url
cpus: 0.5
mem_limit: 128m
depends_on:
db:
condition: service_healthy
healthcheck:
disable: true
image: mtusi2026lab5-app:1
logging:
driver: json-file
options:
max-size: 5m
max-file: '2'
s3:
image: mtusi2026lab5-minio:2025-04-22
build:
context: .
dockerfile: infra/s3.Dockerfile
args:
COMPONENT: minio
RELEASE: RELEASE.2025-04-22T22-12-26Z
SHA256: 53e2a2cb16c5366ea6fbbc479c19ddb4c6a0948273e752f740fb1fbf27bb817c
command:
- server
- /data
- --address
- :9000
- --console-address
- 127.0.0.1:9001
environment:
MINIO_ROOT_USER_FILE: /run/secrets/s3_root_user
MINIO_ROOT_PASSWORD_FILE: /run/secrets/s3_root_password
MINIO_BROWSER: 'off'
secrets:
- s3_root_user
- s3_root_password
volumes:
- s3_data:/data
cpus: 1.0
mem_limit: 512m
healthcheck:
test:
- CMD
- python
- -c
- import urllib.request; urllib.request.urlopen("http://localhost:9000/minio/health/live",timeout=2)
interval: 2s
timeout: 3s
retries: 30
logging:
driver: json-file
options:
max-size: 5m
max-file: '2'
s3-bootstrap:
image: mtusi2026lab5-mc:2025-04-16
build:
context: .
dockerfile: infra/s3.Dockerfile
args:
COMPONENT: mc
RELEASE: RELEASE.2025-04-16T18-13-26Z
SHA256: ac90da87a35641be5a0ac75d49de5161ddb47d629b5ba01261b0ae9e00aea15f
entrypoint:
- /bin/sh
- /bootstrap.sh
volumes:
- ./scripts/bootstrap_s3.sh:/bootstrap.sh:ro
- ./infra:/policies:ro
secrets:
- s3_root_user
- s3_root_password
- s3_access_key_id
- s3_secret_access_key
environment:
S3_ENDPOINT: http://s3:9000
depends_on:
s3:
condition: service_healthy
cpus: 0.5
mem_limit: 128m
logging:
driver: json-file
options:
max-size: 5m
max-file: '2'
api:
build: .
scale: 2
environment:
DATABASE_URL_FILE: /run/secrets/database_url
CACHE_URL: redis://cache:6379/0
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
DB_POOL_MAX: ${DB_POOL_MAX:-8}
S3_ENDPOINT: http://s3:9000
S3_BUCKET: messenger-attachments
S3_REGION: us-east-1
S3_ACCESS_KEY_ID_FILE: /run/secrets/s3_access_key_id
S3_SECRET_ACCESS_KEY_FILE: /run/secrets/s3_secret_access_key
MAX_UPLOAD_BYTES: '10485760'
MAX_IMAGE_PIXELS: '40000000'
MAX_PENDING_JOBS: ${MAX_PENDING_JOBS:-1000}
secrets:
- database_url
- s3_access_key_id
- s3_secret_access_key
dns_opt:
- timeout:1
- attempts:1
cpus: ${API_CPU:-1.0}
mem_limit: ${API_MEMORY:-512m}
stop_grace_period: 10s
depends_on:
migrate:
condition: service_completed_successfully
cache:
condition: service_healthy
s3-bootstrap:
condition: service_completed_successfully
healthcheck:
test:
- CMD
- python
- /app/scripts/healthcheck.py
interval: 2s
timeout: 4s
retries: 30
image: mtusi2026lab5-app:1
logging:
driver: json-file
options:
max-size: 5m
max-file: '2'
reconciler:
build: .
command:
- python
- -m
- src.cleanup
- --apply
- --loop
environment:
DATABASE_URL_FILE: /run/secrets/database_url
S3_ENDPOINT: http://s3:9000
S3_BUCKET: messenger-attachments
S3_ACCESS_KEY_ID_FILE: /run/secrets/s3_access_key_id
S3_SECRET_ACCESS_KEY_FILE: /run/secrets/s3_secret_access_key
BROKER_URL_FILE: /run/secrets/broker_url
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5}
JOB_TIMEOUT_SECONDS: ${JOB_TIMEOUT_SECONDS:-30}
JOB_LEASE_SECONDS: ${JOB_LEASE_SECONDS:-15}
STAGING_RETENTION_SECONDS: ${STAGING_RETENTION_SECONDS:-86400}
ALLOW_FAULT_INJECTION: ${ALLOW_FAULT_INJECTION:-0}
secrets:
- database_url
- s3_access_key_id
- s3_secret_access_key
- broker_url
cpus: 0.5
mem_limit: 256m
depends_on:
migrate:
condition: service_completed_successfully
s3-bootstrap:
condition: service_completed_successfully
healthcheck:
disable: true
image: mtusi2026lab5-app:1
logging:
driver: json-file
options:
max-size: 5m
max-file: '2'
dns_opt:
- timeout:1
- attempts:1
lb:
image: haproxy:3.0.11-bookworm
ports:
- 127.0.0.1:${APP_PORT:-8080}:8080
volumes:
- ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
cpus: 0.5
mem_limit: 128m
depends_on:
api:
condition: service_healthy
logging:
driver: json-file
options:
max-size: 5m
max-file: '2'
broker:
image: redis:7.4.3-bookworm
entrypoint:
- /bin/sh
- /broker.sh
volumes:
- broker_data:/data
- ./infra/broker-entrypoint.sh:/broker.sh:ro
secrets:
- broker_password
cpus: 0.5
mem_limit: 256m
healthcheck:
test:
- CMD-SHELL
- REDISCLI_AUTH="$$(cat /run/secrets/broker_password)" redis-cli ping
interval: 2s
timeout: 3s
retries: 30
logging:
driver: json-file
options:
max-size: 5m
max-file: '2'
dispatcher:
image: mtusi2026lab5-app:1
build: .
command:
- python
- -m
- src.dispatcher
environment:
DATABASE_URL_FILE: /run/secrets/database_url
S3_ENDPOINT: http://s3:9000
S3_BUCKET: messenger-attachments
S3_ACCESS_KEY_ID_FILE: /run/secrets/s3_access_key_id
S3_SECRET_ACCESS_KEY_FILE: /run/secrets/s3_secret_access_key
BROKER_URL_FILE: /run/secrets/broker_url
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5}
JOB_TIMEOUT_SECONDS: ${JOB_TIMEOUT_SECONDS:-30}
JOB_LEASE_SECONDS: ${JOB_LEASE_SECONDS:-15}
STAGING_RETENTION_SECONDS: ${STAGING_RETENTION_SECONDS:-86400}
ALLOW_FAULT_INJECTION: ${ALLOW_FAULT_INJECTION:-0}
secrets:
- database_url
- s3_access_key_id
- s3_secret_access_key
- broker_url
cpus: 0.5
mem_limit: 256m
depends_on:
migrate:
condition: service_completed_successfully
s3-bootstrap:
condition: service_completed_successfully
broker:
condition: service_healthy
restart: on-failure
healthcheck:
disable: true
logging:
driver: json-file
options:
max-size: 5m
max-file: '2'
dns_opt:
- timeout:1
- attempts:1
worker:
image: mtusi2026lab5-app:1
build: .
command:
- python
- -m
- src.worker
environment:
DATABASE_URL_FILE: /run/secrets/database_url
S3_ENDPOINT: http://s3:9000
S3_BUCKET: messenger-attachments
S3_ACCESS_KEY_ID_FILE: /run/secrets/s3_access_key_id
S3_SECRET_ACCESS_KEY_FILE: /run/secrets/s3_secret_access_key
BROKER_URL_FILE: /run/secrets/broker_url
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5}
JOB_TIMEOUT_SECONDS: ${JOB_TIMEOUT_SECONDS:-30}
JOB_LEASE_SECONDS: ${JOB_LEASE_SECONDS:-15}
STAGING_RETENTION_SECONDS: ${STAGING_RETENTION_SECONDS:-86400}
ALLOW_FAULT_INJECTION: ${ALLOW_FAULT_INJECTION:-0}
WORKER_CONCURRENCY: ${WORKER_CONCURRENCY:-1}
WORKER_IMAGE_MEMORY_MIB: '512'
secrets:
- database_url
- s3_access_key_id
- s3_secret_access_key
- broker_url
cpus: 1.0
mem_limit: 768m
stop_grace_period: 5s
depends_on:
migrate:
condition: service_completed_successfully
s3-bootstrap:
condition: service_completed_successfully
broker:
condition: service_healthy
restart: on-failure
healthcheck:
disable: true
logging:
driver: json-file
options:
max-size: 5m
max-file: '2'
dns_opt:
- timeout:1
- attempts:1
volumes:
postgres_data: null
redis_data: null
s3_data: null
broker_data: null
secrets:
db_password:
file: .secrets/db_password
database_url:
file: .secrets/database_url
s3_root_user:
file: .secrets/s3_root_user
s3_root_password:
file: .secrets/s3_root_password
s3_access_key_id:
file: .secrets/s3_access_key_id
s3_secret_access_key:
file: .secrets/s3_secret_access_key
broker_password:
file: .secrets/broker_password
broker_url:
file: .secrets/broker_url
+340
View File
@@ -0,0 +1,340 @@
{
"target": "768f094b3536:ba81595e",
"stopped_container": "768f094b3536247e53a7fa69357a507504aa11cd094149723e47ec1758b0805d",
"before": [
{
"id": "6d5ccd7883e55d222f7bcb15064b8a7c0d5722ca54f2c941d4ba35b1e1ef4128",
"name": "mtusi2026lab5-api-1",
"hostname": "6d5ccd7883e5",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:44:11.837673643Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "768f094b3536247e53a7fa69357a507504aa11cd094149723e47ec1758b0805d",
"name": "mtusi2026lab5-api-2",
"hostname": "768f094b3536",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:44:12.329596734Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "926c8de7fdfd9772c439414fc2e468cc0c23c641b68a83b84e4d8cb4e4998548",
"name": "mtusi2026lab5-broker-1",
"hostname": "926c8de7fdfd",
"service": "broker",
"running": true,
"started_at": "2026-10-26T13:44:16.426131982Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "664d5065e4e2057903eaf1e47fe90f099597e81d28324c54f81141d3255a6f63",
"name": "mtusi2026lab5-cache-1",
"hostname": "664d5065e4e2",
"service": "cache",
"running": true,
"started_at": "2026-10-26T13:21:15.687084123Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "a8efd18d965de2c9a1c93cf00e9230cb17f6b769af6446228ded6d262c12f650",
"name": "mtusi2026lab5-db-1",
"hostname": "a8efd18d965d",
"service": "db",
"running": true,
"started_at": "2026-10-26T13:21:23.472099949Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"5432/tcp": null
}
},
{
"id": "9dddbe68f5014a882f21775814a22bff73c2e7afa06aec44f6afaacf862e0938",
"name": "mtusi2026lab5-dispatcher-1",
"hostname": "9dddbe68f501",
"service": "dispatcher",
"running": true,
"started_at": "2026-10-26T13:53:56.773872211Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "17d5d00bd730356064b7324bfb190a5726be5dde524938e43a0e95fda8a097d2",
"name": "mtusi2026lab5-lb-1",
"hostname": "17d5d00bd730",
"service": "lb",
"running": true,
"started_at": "2026-10-26T13:20:11.844174641Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"8080/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "8080"
}
]
}
},
{
"id": "85c2bb372517d143c1bc4f0d62f919c03fcd0b2922f6d80527b5dd967afc87a2",
"name": "mtusi2026lab5-migrate-1",
"hostname": "85c2bb372517",
"service": "migrate",
"running": false,
"started_at": "2026-10-26T13:21:01.323626814Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "a62f7b1a9e058209c3e1c8e99fc418406270224effc82faa4bf1587d1250c18a",
"name": "mtusi2026lab5-reconciler-1",
"hostname": "a62f7b1a9e05",
"service": "reconciler",
"running": true,
"started_at": "2026-10-26T13:53:57.612149851Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "5bd819ea48506fa8a38869e22ddc3607f8f9aeb23348b4b46aa594acdd61466a",
"name": "mtusi2026lab5-s3-1",
"hostname": "5bd819ea4850",
"service": "s3",
"running": true,
"started_at": "2026-10-26T13:52:45.447139686Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "9a802ad7d2417be1c16ff80944bc599eeb8ad9bcd0c91ab7c0dbfa761154b22c",
"name": "mtusi2026lab5-s3-bootstrap-1",
"hostname": "9a802ad7d241",
"service": "s3-bootstrap",
"running": false,
"started_at": "2026-10-26T13:21:01.324968308Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "e1b41eef77857e6216dd324988b41d2a7386ee93c2405dce35e9f22917c914dd",
"name": "mtusi2026lab5-worker-1",
"hostname": "e1b41eef7785",
"service": "worker",
"running": true,
"started_at": "2026-10-26T13:53:56.773642491Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 805306368,
"published_ports": {
"8080/tcp": null
}
}
],
"after": [
{
"id": "6d5ccd7883e55d222f7bcb15064b8a7c0d5722ca54f2c941d4ba35b1e1ef4128",
"name": "mtusi2026lab5-api-1",
"hostname": "6d5ccd7883e5",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:44:11.837673643Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "768f094b3536247e53a7fa69357a507504aa11cd094149723e47ec1758b0805d",
"name": "mtusi2026lab5-api-2",
"hostname": "768f094b3536",
"service": "api",
"running": false,
"started_at": "2026-10-26T13:44:12.329596734Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "926c8de7fdfd9772c439414fc2e468cc0c23c641b68a83b84e4d8cb4e4998548",
"name": "mtusi2026lab5-broker-1",
"hostname": "926c8de7fdfd",
"service": "broker",
"running": true,
"started_at": "2026-10-26T13:44:16.426131982Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "664d5065e4e2057903eaf1e47fe90f099597e81d28324c54f81141d3255a6f63",
"name": "mtusi2026lab5-cache-1",
"hostname": "664d5065e4e2",
"service": "cache",
"running": true,
"started_at": "2026-10-26T13:21:15.687084123Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "a8efd18d965de2c9a1c93cf00e9230cb17f6b769af6446228ded6d262c12f650",
"name": "mtusi2026lab5-db-1",
"hostname": "a8efd18d965d",
"service": "db",
"running": true,
"started_at": "2026-10-26T13:21:23.472099949Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"5432/tcp": null
}
},
{
"id": "9dddbe68f5014a882f21775814a22bff73c2e7afa06aec44f6afaacf862e0938",
"name": "mtusi2026lab5-dispatcher-1",
"hostname": "9dddbe68f501",
"service": "dispatcher",
"running": true,
"started_at": "2026-10-26T13:53:56.773872211Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "17d5d00bd730356064b7324bfb190a5726be5dde524938e43a0e95fda8a097d2",
"name": "mtusi2026lab5-lb-1",
"hostname": "17d5d00bd730",
"service": "lb",
"running": true,
"started_at": "2026-10-26T13:20:11.844174641Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"8080/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "8080"
}
]
}
},
{
"id": "85c2bb372517d143c1bc4f0d62f919c03fcd0b2922f6d80527b5dd967afc87a2",
"name": "mtusi2026lab5-migrate-1",
"hostname": "85c2bb372517",
"service": "migrate",
"running": false,
"started_at": "2026-10-26T13:21:01.323626814Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "a62f7b1a9e058209c3e1c8e99fc418406270224effc82faa4bf1587d1250c18a",
"name": "mtusi2026lab5-reconciler-1",
"hostname": "a62f7b1a9e05",
"service": "reconciler",
"running": true,
"started_at": "2026-10-26T13:53:57.612149851Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "5bd819ea48506fa8a38869e22ddc3607f8f9aeb23348b4b46aa594acdd61466a",
"name": "mtusi2026lab5-s3-1",
"hostname": "5bd819ea4850",
"service": "s3",
"running": true,
"started_at": "2026-10-26T13:52:45.447139686Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "9a802ad7d2417be1c16ff80944bc599eeb8ad9bcd0c91ab7c0dbfa761154b22c",
"name": "mtusi2026lab5-s3-bootstrap-1",
"hostname": "9a802ad7d241",
"service": "s3-bootstrap",
"running": false,
"started_at": "2026-10-26T13:21:01.324968308Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "e1b41eef77857e6216dd324988b41d2a7386ee93c2405dce35e9f22917c914dd",
"name": "mtusi2026lab5-worker-1",
"hostname": "e1b41eef7785",
"service": "worker",
"running": true,
"started_at": "2026-10-26T13:53:56.773642491Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 805306368,
"published_ports": {
"8080/tcp": null
}
}
]
}
+349
View File
@@ -0,0 +1,349 @@
{
"status": "PASS",
"uploader": "19035f4f4225:4d87e6fb",
"downloader": "8f4a872818e5:968954bd",
"recovery_seconds": 2.3859084759999405,
"failed_attempts": 0,
"original_size": 111817,
"checksum_verified": true,
"stop": {
"target": "19035f4f4225:4d87e6fb",
"stopped_container": "19035f4f4225999dacd97a3f68c06cd1a08c18b720efcaa4a6c3af76ceb3512c",
"before": [
{
"id": "19035f4f4225999dacd97a3f68c06cd1a08c18b720efcaa4a6c3af76ceb3512c",
"name": "mtusi2026lab5-api-1",
"hostname": "19035f4f4225",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:20:51.434643261Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "8f4a872818e5648c47a76de51084bc0af53672fe0095a1b1f64e1fbe76266c70",
"name": "mtusi2026lab5-api-2",
"hostname": "8f4a872818e5",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:20:07.260090532Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "926c8de7fdfd9772c439414fc2e468cc0c23c641b68a83b84e4d8cb4e4998548",
"name": "mtusi2026lab5-broker-1",
"hostname": "926c8de7fdfd",
"service": "broker",
"running": true,
"started_at": "2026-10-26T13:19:58.542392464Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "664d5065e4e2057903eaf1e47fe90f099597e81d28324c54f81141d3255a6f63",
"name": "mtusi2026lab5-cache-1",
"hostname": "664d5065e4e2",
"service": "cache",
"running": true,
"started_at": "2026-10-26T13:19:58.561302804Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "a8efd18d965de2c9a1c93cf00e9230cb17f6b769af6446228ded6d262c12f650",
"name": "mtusi2026lab5-db-1",
"hostname": "a8efd18d965d",
"service": "db",
"running": true,
"started_at": "2026-10-26T13:19:58.562034277Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"5432/tcp": null
}
},
{
"id": "006c11ae2e2c025877906965f955d50a070e03dcefdf10251219d986aa951287",
"name": "mtusi2026lab5-dispatcher-1",
"hostname": "006c11ae2e2c",
"service": "dispatcher",
"running": true,
"started_at": "2026-10-26T13:20:11.830304855Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "17d5d00bd730356064b7324bfb190a5726be5dde524938e43a0e95fda8a097d2",
"name": "mtusi2026lab5-lb-1",
"hostname": "17d5d00bd730",
"service": "lb",
"running": true,
"started_at": "2026-10-26T13:20:11.844174641Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"8080/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "8080"
}
]
}
},
{
"id": "85c2bb372517d143c1bc4f0d62f919c03fcd0b2922f6d80527b5dd967afc87a2",
"name": "mtusi2026lab5-migrate-1",
"hostname": "85c2bb372517",
"service": "migrate",
"running": false,
"started_at": "2026-10-26T13:20:46.898485224Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "a62f7b1a9e058209c3e1c8e99fc418406270224effc82faa4bf1587d1250c18a",
"name": "mtusi2026lab5-reconciler-1",
"hostname": "a62f7b1a9e05",
"service": "reconciler",
"running": true,
"started_at": "2026-10-26T13:20:11.405575488Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "5bd819ea48506fa8a38869e22ddc3607f8f9aeb23348b4b46aa594acdd61466a",
"name": "mtusi2026lab5-s3-1",
"hostname": "5bd819ea4850",
"service": "s3",
"running": true,
"started_at": "2026-10-26T13:19:58.541630268Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "9a802ad7d2417be1c16ff80944bc599eeb8ad9bcd0c91ab7c0dbfa761154b22c",
"name": "mtusi2026lab5-s3-bootstrap-1",
"hostname": "9a802ad7d241",
"service": "s3-bootstrap",
"running": false,
"started_at": "2026-10-26T13:20:46.909369372Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "8f8673d67ca93d49031a9e5f55cd6fbf532142965a466de61353b15112472775",
"name": "mtusi2026lab5-worker-1",
"hostname": "8f8673d67ca9",
"service": "worker",
"running": true,
"started_at": "2026-10-26T13:20:11.799525654Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 805306368,
"published_ports": {
"8080/tcp": null
}
}
],
"after": [
{
"id": "19035f4f4225999dacd97a3f68c06cd1a08c18b720efcaa4a6c3af76ceb3512c",
"name": "mtusi2026lab5-api-1",
"hostname": "19035f4f4225",
"service": "api",
"running": false,
"started_at": "2026-10-26T13:20:51.434643261Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "8f4a872818e5648c47a76de51084bc0af53672fe0095a1b1f64e1fbe76266c70",
"name": "mtusi2026lab5-api-2",
"hostname": "8f4a872818e5",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:20:07.260090532Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "926c8de7fdfd9772c439414fc2e468cc0c23c641b68a83b84e4d8cb4e4998548",
"name": "mtusi2026lab5-broker-1",
"hostname": "926c8de7fdfd",
"service": "broker",
"running": true,
"started_at": "2026-10-26T13:19:58.542392464Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "664d5065e4e2057903eaf1e47fe90f099597e81d28324c54f81141d3255a6f63",
"name": "mtusi2026lab5-cache-1",
"hostname": "664d5065e4e2",
"service": "cache",
"running": true,
"started_at": "2026-10-26T13:19:58.561302804Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "a8efd18d965de2c9a1c93cf00e9230cb17f6b769af6446228ded6d262c12f650",
"name": "mtusi2026lab5-db-1",
"hostname": "a8efd18d965d",
"service": "db",
"running": true,
"started_at": "2026-10-26T13:19:58.562034277Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"5432/tcp": null
}
},
{
"id": "006c11ae2e2c025877906965f955d50a070e03dcefdf10251219d986aa951287",
"name": "mtusi2026lab5-dispatcher-1",
"hostname": "006c11ae2e2c",
"service": "dispatcher",
"running": true,
"started_at": "2026-10-26T13:20:11.830304855Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "17d5d00bd730356064b7324bfb190a5726be5dde524938e43a0e95fda8a097d2",
"name": "mtusi2026lab5-lb-1",
"hostname": "17d5d00bd730",
"service": "lb",
"running": true,
"started_at": "2026-10-26T13:20:11.844174641Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"8080/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "8080"
}
]
}
},
{
"id": "85c2bb372517d143c1bc4f0d62f919c03fcd0b2922f6d80527b5dd967afc87a2",
"name": "mtusi2026lab5-migrate-1",
"hostname": "85c2bb372517",
"service": "migrate",
"running": false,
"started_at": "2026-10-26T13:20:46.898485224Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "a62f7b1a9e058209c3e1c8e99fc418406270224effc82faa4bf1587d1250c18a",
"name": "mtusi2026lab5-reconciler-1",
"hostname": "a62f7b1a9e05",
"service": "reconciler",
"running": true,
"started_at": "2026-10-26T13:20:11.405575488Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "5bd819ea48506fa8a38869e22ddc3607f8f9aeb23348b4b46aa594acdd61466a",
"name": "mtusi2026lab5-s3-1",
"hostname": "5bd819ea4850",
"service": "s3",
"running": true,
"started_at": "2026-10-26T13:19:58.541630268Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "9a802ad7d2417be1c16ff80944bc599eeb8ad9bcd0c91ab7c0dbfa761154b22c",
"name": "mtusi2026lab5-s3-bootstrap-1",
"hostname": "9a802ad7d241",
"service": "s3-bootstrap",
"running": false,
"started_at": "2026-10-26T13:20:46.909369372Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "8f8673d67ca93d49031a9e5f55cd6fbf532142965a466de61353b15112472775",
"name": "mtusi2026lab5-worker-1",
"hostname": "8f8673d67ca9",
"service": "worker",
"running": true,
"started_at": "2026-10-26T13:20:11.799525654Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 805306368,
"published_ports": {
"8080/tcp": null
}
}
]
}
}
+53
View File
@@ -0,0 +1,53 @@
broker-1 | 1:C 26 Oct 2026 13:16:13.246 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
broker-1 | 1:C 26 Oct 2026 13:16:13.246 * Redis version=7.4.3, bits=64, commit=00000000, modified=0, pid=1, just started
broker-1 | 1:C 26 Oct 2026 13:16:13.246 * Configuration loaded
broker-1 | 1:M 26 Oct 2026 13:16:13.247 * monotonic clock: POSIX clock_gettime
broker-1 | 1:M 26 Oct 2026 13:16:13.249 * Running mode=standalone, port=6379.
broker-1 | 1:M 26 Oct 2026 13:16:13.250 * Server initialized
broker-1 | 1:M 26 Oct 2026 13:16:13.259 * Creating AOF base file appendonly.aof.1.base.rdb on server start
broker-1 | 1:M 26 Oct 2026 13:16:13.272 * Creating AOF incr file appendonly.aof.1.incr.aof on server start
broker-1 | 1:M 26 Oct 2026 13:16:13.272 * Ready to accept connections tcp
broker-1 | 1:signal-handler (1793020629) Received SIGTERM scheduling shutdown...
broker-1 | 1:M 26 Oct 2026 13:17:10.009 * User requested shutdown...
broker-1 | 1:M 26 Oct 2026 13:17:10.010 * Calling fsync() on the AOF file.
broker-1 | 1:M 26 Oct 2026 13:17:10.011 # Redis is now ready to exit, bye bye...
broker-1 | /broker.sh: 4: cannot create /tmp/broker.conf: Permission denied
broker-1 | /broker.sh: 4: cannot create /tmp/broker.conf: Permission denied
broker-1 | 1:C 26 Oct 2026 13:18:36.800 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
broker-1 | 1:C 26 Oct 2026 13:18:36.800 * Redis version=7.4.3, bits=64, commit=00000000, modified=0, pid=1, just started
broker-1 | 1:C 26 Oct 2026 13:18:36.800 * Configuration loaded
broker-1 | 1:M 26 Oct 2026 13:18:36.801 * monotonic clock: POSIX clock_gettime
broker-1 | 1:M 26 Oct 2026 13:18:36.807 * Running mode=standalone, port=6379.
broker-1 | 1:M 26 Oct 2026 13:18:36.808 * Server initialized
broker-1 | 1:M 26 Oct 2026 13:18:36.815 * Reading RDB base file on AOF loading...
broker-1 | 1:M 26 Oct 2026 13:18:36.815 * Loading RDB produced by version 7.4.3
broker-1 | 1:M 26 Oct 2026 13:18:36.815 * RDB age 143 seconds
broker-1 | 1:M 26 Oct 2026 13:18:36.815 * RDB memory usage when created 0.90 Mb
broker-1 | 1:M 26 Oct 2026 13:18:36.815 * RDB is base AOF
broker-1 | 1:M 26 Oct 2026 13:18:36.815 * Done loading RDB, keys loaded: 0, keys expired: 0.
broker-1 | 1:M 26 Oct 2026 13:18:36.816 * DB loaded from base file appendonly.aof.1.base.rdb: 0.008 seconds
broker-1 | 1:M 26 Oct 2026 13:18:36.816 * DB loaded from incr file appendonly.aof.1.incr.aof: 0.000 seconds
broker-1 | 1:M 26 Oct 2026 13:18:36.816 * DB loaded from append only file: 0.008 seconds
broker-1 | 1:M 26 Oct 2026 13:18:36.816 * Opening AOF incr file appendonly.aof.1.incr.aof on server start
broker-1 | 1:M 26 Oct 2026 13:18:36.816 * Ready to accept connections tcp
broker-1 | 1:signal-handler (1793020796) Received SIGTERM scheduling shutdown...
broker-1 | 1:M 26 Oct 2026 13:19:56.437 * User requested shutdown...
broker-1 | 1:M 26 Oct 2026 13:19:56.437 * Calling fsync() on the AOF file.
broker-1 | 1:M 26 Oct 2026 13:19:56.438 # Redis is now ready to exit, bye bye...
broker-1 | 1:C 26 Oct 2026 13:19:58.573 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
broker-1 | 1:C 26 Oct 2026 13:19:58.573 * Redis version=7.4.3, bits=64, commit=00000000, modified=0, pid=1, just started
broker-1 | 1:C 26 Oct 2026 13:19:58.573 * Configuration loaded
broker-1 | 1:M 26 Oct 2026 13:19:58.573 * monotonic clock: POSIX clock_gettime
broker-1 | 1:M 26 Oct 2026 13:19:58.574 * Running mode=standalone, port=6379.
broker-1 | 1:M 26 Oct 2026 13:19:58.574 * Server initialized
broker-1 | 1:M 26 Oct 2026 13:19:58.574 * Reading RDB base file on AOF loading...
broker-1 | 1:M 26 Oct 2026 13:19:58.575 * Loading RDB produced by version 7.4.3
broker-1 | 1:M 26 Oct 2026 13:19:58.575 * RDB age 225 seconds
broker-1 | 1:M 26 Oct 2026 13:19:58.575 * RDB memory usage when created 0.90 Mb
broker-1 | 1:M 26 Oct 2026 13:19:58.575 * RDB is base AOF
broker-1 | 1:M 26 Oct 2026 13:19:58.575 * Done loading RDB, keys loaded: 0, keys expired: 0.
broker-1 | 1:M 26 Oct 2026 13:19:58.576 * DB loaded from base file appendonly.aof.1.base.rdb: 0.001 seconds
broker-1 | 1:M 26 Oct 2026 13:19:58.576 * DB loaded from incr file appendonly.aof.1.incr.aof: 0.000 seconds
broker-1 | 1:M 26 Oct 2026 13:19:58.576 * DB loaded from append only file: 0.001 seconds
broker-1 | 1:M 26 Oct 2026 13:19:58.576 * Opening AOF incr file appendonly.aof.1.incr.aof on server start
broker-1 | 1:M 26 Oct 2026 13:19:58.576 * Ready to accept connections tcp
+1
View File
@@ -0,0 +1 @@
{"config": {"appendonly": "yes", "maxmemory-policy": "noeviction", "appendfsync": "always"}, "aof_enabled": 1}
+2
View File
@@ -0,0 +1,2 @@
WARNING: The directory '/nonexistent/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
No broken requirements found.
+169
View File
@@ -0,0 +1,169 @@
[
{
"id": "19035f4f4225999dacd97a3f68c06cd1a08c18b720efcaa4a6c3af76ceb3512c",
"name": "mtusi2026lab5-api-1",
"hostname": "19035f4f4225",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:20:07.596155423Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "8f4a872818e5648c47a76de51084bc0af53672fe0095a1b1f64e1fbe76266c70",
"name": "mtusi2026lab5-api-2",
"hostname": "8f4a872818e5",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:20:07.260090532Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "926c8de7fdfd9772c439414fc2e468cc0c23c641b68a83b84e4d8cb4e4998548",
"name": "mtusi2026lab5-broker-1",
"hostname": "926c8de7fdfd",
"service": "broker",
"running": true,
"started_at": "2026-10-26T13:19:58.542392464Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "664d5065e4e2057903eaf1e47fe90f099597e81d28324c54f81141d3255a6f63",
"name": "mtusi2026lab5-cache-1",
"hostname": "664d5065e4e2",
"service": "cache",
"running": true,
"started_at": "2026-10-26T13:19:58.561302804Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "a8efd18d965de2c9a1c93cf00e9230cb17f6b769af6446228ded6d262c12f650",
"name": "mtusi2026lab5-db-1",
"hostname": "a8efd18d965d",
"service": "db",
"running": true,
"started_at": "2026-10-26T13:19:58.562034277Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"5432/tcp": null
}
},
{
"id": "006c11ae2e2c025877906965f955d50a070e03dcefdf10251219d986aa951287",
"name": "mtusi2026lab5-dispatcher-1",
"hostname": "006c11ae2e2c",
"service": "dispatcher",
"running": true,
"started_at": "2026-10-26T13:20:11.830304855Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "17d5d00bd730356064b7324bfb190a5726be5dde524938e43a0e95fda8a097d2",
"name": "mtusi2026lab5-lb-1",
"hostname": "17d5d00bd730",
"service": "lb",
"running": true,
"started_at": "2026-10-26T13:20:11.844174641Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"8080/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "8080"
}
]
}
},
{
"id": "85c2bb372517d143c1bc4f0d62f919c03fcd0b2922f6d80527b5dd967afc87a2",
"name": "mtusi2026lab5-migrate-1",
"hostname": "85c2bb372517",
"service": "migrate",
"running": false,
"started_at": "2026-10-26T13:16:16.209515476Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "a62f7b1a9e058209c3e1c8e99fc418406270224effc82faa4bf1587d1250c18a",
"name": "mtusi2026lab5-reconciler-1",
"hostname": "a62f7b1a9e05",
"service": "reconciler",
"running": true,
"started_at": "2026-10-26T13:20:11.405575488Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "5bd819ea48506fa8a38869e22ddc3607f8f9aeb23348b4b46aa594acdd61466a",
"name": "mtusi2026lab5-s3-1",
"hostname": "5bd819ea4850",
"service": "s3",
"running": true,
"started_at": "2026-10-26T13:19:58.541630268Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "9a802ad7d2417be1c16ff80944bc599eeb8ad9bcd0c91ab7c0dbfa761154b22c",
"name": "mtusi2026lab5-s3-bootstrap-1",
"hostname": "9a802ad7d241",
"service": "s3-bootstrap",
"running": false,
"started_at": "2026-10-26T13:16:16.236792755Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "8f8673d67ca93d49031a9e5f55cd6fbf532142965a466de61353b15112472775",
"name": "mtusi2026lab5-worker-1",
"hostname": "8f8673d67ca9",
"service": "worker",
"running": true,
"started_at": "2026-10-26T13:20:11.799525654Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 805306368,
"published_ports": {
"8080/tcp": null
}
}
]
+169
View File
@@ -0,0 +1,169 @@
[
{
"id": "ca5bb0478ca73a96fb5298cba384bd0df6d7527cb44b4cb634aeb6bdbe69362a",
"name": "mtusi2026lab5-api-1",
"hostname": "ca5bb0478ca7",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:16:21.613946914Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "c754d451d0549989cb98b8d8a5ec3d0b0b71f60540d088338c2019c0c1d8d541",
"name": "mtusi2026lab5-api-2",
"hostname": "c754d451d054",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:16:22.355787701Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "926c8de7fdfd9772c439414fc2e468cc0c23c641b68a83b84e4d8cb4e4998548",
"name": "mtusi2026lab5-broker-1",
"hostname": "926c8de7fdfd",
"service": "broker",
"running": true,
"started_at": "2026-10-26T13:16:13.228812174Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "664d5065e4e2057903eaf1e47fe90f099597e81d28324c54f81141d3255a6f63",
"name": "mtusi2026lab5-cache-1",
"hostname": "664d5065e4e2",
"service": "cache",
"running": true,
"started_at": "2026-10-26T13:16:13.22282282Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "a8efd18d965de2c9a1c93cf00e9230cb17f6b769af6446228ded6d262c12f650",
"name": "mtusi2026lab5-db-1",
"hostname": "a8efd18d965d",
"service": "db",
"running": true,
"started_at": "2026-10-26T13:16:13.188626791Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"5432/tcp": null
}
},
{
"id": "896657e8d5c7d804714969b92ea1095774dd370e529c54a7a6fec9faf9920b11",
"name": "mtusi2026lab5-dispatcher-1",
"hostname": "896657e8d5c7",
"service": "dispatcher",
"running": true,
"started_at": "2026-10-26T13:16:22.01758076Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "53ca4a2a0ae5230e8757cd2afa56cf7b81a29478133e19e5bff78ef9d1dc5bc5",
"name": "mtusi2026lab5-lb-1",
"hostname": "53ca4a2a0ae5",
"service": "lb",
"running": true,
"started_at": "2026-10-26T13:16:25.589983116Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"8080/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "8080"
}
]
}
},
{
"id": "85c2bb372517d143c1bc4f0d62f919c03fcd0b2922f6d80527b5dd967afc87a2",
"name": "mtusi2026lab5-migrate-1",
"hostname": "85c2bb372517",
"service": "migrate",
"running": false,
"started_at": "2026-10-26T13:16:16.209515476Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "207315a71a98bf9414dcf3e3e0e7a60b06ac7efa4be311ecc3c96b35fe9a2ffe",
"name": "mtusi2026lab5-reconciler-1",
"hostname": "207315a71a98",
"service": "reconciler",
"running": true,
"started_at": "2026-10-26T13:16:21.961770232Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "5bd819ea48506fa8a38869e22ddc3607f8f9aeb23348b4b46aa594acdd61466a",
"name": "mtusi2026lab5-s3-1",
"hostname": "5bd819ea4850",
"service": "s3",
"running": true,
"started_at": "2026-10-26T13:16:13.224363452Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "9a802ad7d2417be1c16ff80944bc599eeb8ad9bcd0c91ab7c0dbfa761154b22c",
"name": "mtusi2026lab5-s3-bootstrap-1",
"hostname": "9a802ad7d241",
"service": "s3-bootstrap",
"running": false,
"started_at": "2026-10-26T13:16:16.236792755Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "2d350ddc0288bd874db28476e4aaf52c526efe177a3e3b9322bb772566d80f38",
"name": "mtusi2026lab5-worker-1",
"hostname": "2d350ddc0288",
"service": "worker",
"running": true,
"started_at": "2026-10-26T13:16:22.005089023Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 805306368,
"published_ports": {
"8080/tcp": null
}
}
]
+169
View File
@@ -0,0 +1,169 @@
[
{
"id": "19035f4f4225999dacd97a3f68c06cd1a08c18b720efcaa4a6c3af76ceb3512c",
"name": "mtusi2026lab5-api-1",
"hostname": "19035f4f4225",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:18:48.494760073Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "8f4a872818e5648c47a76de51084bc0af53672fe0095a1b1f64e1fbe76266c70",
"name": "mtusi2026lab5-api-2",
"hostname": "8f4a872818e5",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:18:48.028291998Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "926c8de7fdfd9772c439414fc2e468cc0c23c641b68a83b84e4d8cb4e4998548",
"name": "mtusi2026lab5-broker-1",
"hostname": "926c8de7fdfd",
"service": "broker",
"running": true,
"started_at": "2026-10-26T13:18:36.75300028Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "664d5065e4e2057903eaf1e47fe90f099597e81d28324c54f81141d3255a6f63",
"name": "mtusi2026lab5-cache-1",
"hostname": "664d5065e4e2",
"service": "cache",
"running": true,
"started_at": "2026-10-26T13:18:36.846503039Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "a8efd18d965de2c9a1c93cf00e9230cb17f6b769af6446228ded6d262c12f650",
"name": "mtusi2026lab5-db-1",
"hostname": "a8efd18d965d",
"service": "db",
"running": true,
"started_at": "2026-10-26T13:18:36.751584245Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"5432/tcp": null
}
},
{
"id": "006c11ae2e2c025877906965f955d50a070e03dcefdf10251219d986aa951287",
"name": "mtusi2026lab5-dispatcher-1",
"hostname": "006c11ae2e2c",
"service": "dispatcher",
"running": true,
"started_at": "2026-10-26T13:18:56.084910077Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "17d5d00bd730356064b7324bfb190a5726be5dde524938e43a0e95fda8a097d2",
"name": "mtusi2026lab5-lb-1",
"hostname": "17d5d00bd730",
"service": "lb",
"running": true,
"started_at": "2026-10-26T13:18:56.176194222Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"8080/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "8080"
}
]
}
},
{
"id": "85c2bb372517d143c1bc4f0d62f919c03fcd0b2922f6d80527b5dd967afc87a2",
"name": "mtusi2026lab5-migrate-1",
"hostname": "85c2bb372517",
"service": "migrate",
"running": false,
"started_at": "2026-10-26T13:16:16.209515476Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "a62f7b1a9e058209c3e1c8e99fc418406270224effc82faa4bf1587d1250c18a",
"name": "mtusi2026lab5-reconciler-1",
"hostname": "a62f7b1a9e05",
"service": "reconciler",
"running": true,
"started_at": "2026-10-26T13:18:56.085817704Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "5bd819ea48506fa8a38869e22ddc3607f8f9aeb23348b4b46aa594acdd61466a",
"name": "mtusi2026lab5-s3-1",
"hostname": "5bd819ea4850",
"service": "s3",
"running": true,
"started_at": "2026-10-26T13:18:36.673896353Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "9a802ad7d2417be1c16ff80944bc599eeb8ad9bcd0c91ab7c0dbfa761154b22c",
"name": "mtusi2026lab5-s3-bootstrap-1",
"hostname": "9a802ad7d241",
"service": "s3-bootstrap",
"running": false,
"started_at": "2026-10-26T13:16:16.236792755Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "8f8673d67ca93d49031a9e5f55cd6fbf532142965a466de61353b15112472775",
"name": "mtusi2026lab5-worker-1",
"hostname": "8f8673d67ca9",
"service": "worker",
"running": true,
"started_at": "2026-10-26T13:18:56.139328157Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 805306368,
"published_ports": {
"8080/tcp": null
}
}
]
+169
View File
@@ -0,0 +1,169 @@
[
{
"id": "6d5ccd7883e55d222f7bcb15064b8a7c0d5722ca54f2c941d4ba35b1e1ef4128",
"name": "mtusi2026lab5-api-1",
"hostname": "6d5ccd7883e5",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:44:11.837673643Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "768f094b3536247e53a7fa69357a507504aa11cd094149723e47ec1758b0805d",
"name": "mtusi2026lab5-api-2",
"hostname": "768f094b3536",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:54:49.167634924Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "926c8de7fdfd9772c439414fc2e468cc0c23c641b68a83b84e4d8cb4e4998548",
"name": "mtusi2026lab5-broker-1",
"hostname": "926c8de7fdfd",
"service": "broker",
"running": true,
"started_at": "2026-10-26T13:44:16.426131982Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "664d5065e4e2057903eaf1e47fe90f099597e81d28324c54f81141d3255a6f63",
"name": "mtusi2026lab5-cache-1",
"hostname": "664d5065e4e2",
"service": "cache",
"running": true,
"started_at": "2026-10-26T13:21:15.687084123Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "a8efd18d965de2c9a1c93cf00e9230cb17f6b769af6446228ded6d262c12f650",
"name": "mtusi2026lab5-db-1",
"hostname": "a8efd18d965d",
"service": "db",
"running": true,
"started_at": "2026-10-26T13:21:23.472099949Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"5432/tcp": null
}
},
{
"id": "9dddbe68f5014a882f21775814a22bff73c2e7afa06aec44f6afaacf862e0938",
"name": "mtusi2026lab5-dispatcher-1",
"hostname": "9dddbe68f501",
"service": "dispatcher",
"running": true,
"started_at": "2026-10-26T13:53:56.773872211Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "17d5d00bd730356064b7324bfb190a5726be5dde524938e43a0e95fda8a097d2",
"name": "mtusi2026lab5-lb-1",
"hostname": "17d5d00bd730",
"service": "lb",
"running": true,
"started_at": "2026-10-26T13:20:11.844174641Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"8080/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "8080"
}
]
}
},
{
"id": "85c2bb372517d143c1bc4f0d62f919c03fcd0b2922f6d80527b5dd967afc87a2",
"name": "mtusi2026lab5-migrate-1",
"hostname": "85c2bb372517",
"service": "migrate",
"running": false,
"started_at": "2026-10-26T13:54:45.19857437Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "a62f7b1a9e058209c3e1c8e99fc418406270224effc82faa4bf1587d1250c18a",
"name": "mtusi2026lab5-reconciler-1",
"hostname": "a62f7b1a9e05",
"service": "reconciler",
"running": true,
"started_at": "2026-10-26T13:53:57.612149851Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "5bd819ea48506fa8a38869e22ddc3607f8f9aeb23348b4b46aa594acdd61466a",
"name": "mtusi2026lab5-s3-1",
"hostname": "5bd819ea4850",
"service": "s3",
"running": true,
"started_at": "2026-10-26T13:52:45.447139686Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "9a802ad7d2417be1c16ff80944bc599eeb8ad9bcd0c91ab7c0dbfa761154b22c",
"name": "mtusi2026lab5-s3-bootstrap-1",
"hostname": "9a802ad7d241",
"service": "s3-bootstrap",
"running": false,
"started_at": "2026-10-26T13:54:45.195760693Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "e1b41eef77857e6216dd324988b41d2a7386ee93c2405dce35e9f22917c914dd",
"name": "mtusi2026lab5-worker-1",
"hostname": "e1b41eef7785",
"service": "worker",
"running": true,
"started_at": "2026-10-26T13:53:56.773642491Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 805306368,
"published_ports": {
"8080/tcp": null
}
}
]
+150
View File
@@ -0,0 +1,150 @@
[
{
"id": "ca5bb0478ca73a96fb5298cba384bd0df6d7527cb44b4cb634aeb6bdbe69362a",
"name": "mtusi2026lab5-api-1",
"hostname": "ca5bb0478ca7",
"service": "api",
"running": false,
"started_at": "2026-10-26T13:16:21.613946914Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "c754d451d0549989cb98b8d8a5ec3d0b0b71f60540d088338c2019c0c1d8d541",
"name": "mtusi2026lab5-api-2",
"hostname": "c754d451d054",
"service": "api",
"running": false,
"started_at": "2026-10-26T13:16:22.355787701Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "926c8de7fdfd9772c439414fc2e468cc0c23c641b68a83b84e4d8cb4e4998548",
"name": "mtusi2026lab5-broker-1",
"hostname": "926c8de7fdfd",
"service": "broker",
"running": false,
"started_at": "2026-10-26T13:17:12.497514045Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {}
},
{
"id": "664d5065e4e2057903eaf1e47fe90f099597e81d28324c54f81141d3255a6f63",
"name": "mtusi2026lab5-cache-1",
"hostname": "664d5065e4e2",
"service": "cache",
"running": true,
"started_at": "2026-10-26T13:17:12.211996217Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "a8efd18d965de2c9a1c93cf00e9230cb17f6b769af6446228ded6d262c12f650",
"name": "mtusi2026lab5-db-1",
"hostname": "a8efd18d965d",
"service": "db",
"running": true,
"started_at": "2026-10-26T13:17:12.512948413Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"5432/tcp": null
}
},
{
"id": "896657e8d5c7d804714969b92ea1095774dd370e529c54a7a6fec9faf9920b11",
"name": "mtusi2026lab5-dispatcher-1",
"hostname": "896657e8d5c7",
"service": "dispatcher",
"running": false,
"started_at": "2026-10-26T13:16:22.01758076Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {}
},
{
"id": "53ca4a2a0ae5230e8757cd2afa56cf7b81a29478133e19e5bff78ef9d1dc5bc5",
"name": "mtusi2026lab5-lb-1",
"hostname": "53ca4a2a0ae5",
"service": "lb",
"running": false,
"started_at": "2026-10-26T13:16:25.589983116Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "85c2bb372517d143c1bc4f0d62f919c03fcd0b2922f6d80527b5dd967afc87a2",
"name": "mtusi2026lab5-migrate-1",
"hostname": "85c2bb372517",
"service": "migrate",
"running": false,
"started_at": "2026-10-26T13:16:16.209515476Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "207315a71a98bf9414dcf3e3e0e7a60b06ac7efa4be311ecc3c96b35fe9a2ffe",
"name": "mtusi2026lab5-reconciler-1",
"hostname": "207315a71a98",
"service": "reconciler",
"running": false,
"started_at": "2026-10-26T13:16:21.961770232Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {}
},
{
"id": "5bd819ea48506fa8a38869e22ddc3607f8f9aeb23348b4b46aa594acdd61466a",
"name": "mtusi2026lab5-s3-1",
"hostname": "5bd819ea4850",
"service": "s3",
"running": true,
"started_at": "2026-10-26T13:17:12.503154994Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "9a802ad7d2417be1c16ff80944bc599eeb8ad9bcd0c91ab7c0dbfa761154b22c",
"name": "mtusi2026lab5-s3-bootstrap-1",
"hostname": "9a802ad7d241",
"service": "s3-bootstrap",
"running": false,
"started_at": "2026-10-26T13:16:16.236792755Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "2d350ddc0288bd874db28476e4aaf52c526efe177a3e3b9322bb772566d80f38",
"name": "mtusi2026lab5-worker-1",
"hostname": "2d350ddc0288",
"service": "worker",
"running": false,
"started_at": "2026-10-26T13:16:22.005089023Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 805306368,
"published_ports": {}
}
]
+8
View File
@@ -0,0 +1,8 @@
{
"redis": "PASS",
"postgres": [
503,
503
],
"old_token_message_original_preserved": true
}
+32
View File
@@ -0,0 +1,32 @@
{
"status": "PASS",
"captured_at": "2026-10-26T13:58:31.163387+00:00",
"checks": {
"public_files_unchanged": true,
"git_diff_check": true,
"no_local_secret_values_in_git_candidates": true,
"no_token_fields_in_evidence_json": true,
"private_paths_ignored": true,
"pipeline_pass_39": true,
"thirteen_cases_three_repeats": true,
"all_case_status_pass": true,
"fault_injection_disabled": true,
"two_api_running": true,
"required_services_running": true,
"instructions_preserved": true,
"git_metadata_preserved": true,
"report_context_present": true
},
"public_files_checked": 16,
"public_mismatches": [],
"secret_match_files": [],
"sensitive_json_fields": [],
"ignored_private_paths": {
".env": true,
".secrets/db_password": true,
".secrets/database_url": true,
".venv/bin/python": true
},
"git_diff_check_output": "",
"git_head": "276dbdad8a34da4c5b57fbf1879ca169b581d75b"
}
+9
View File
@@ -0,0 +1,9 @@
{
"status": "PASS",
"concurrent_requests": 32,
"observed_instances": 2,
"messages_after_race": 1,
"conflict": 409,
"invalid_key": 400,
"logout": 401
}
+98
View File
@@ -0,0 +1,98 @@
{
"added": [
"Dockerfile",
"compose.yaml",
"infra/broker-entrypoint.sh",
"infra/haproxy.cfg",
"infra/minio-entrypoint.sh",
"infra/s3-api-policy.json",
"infra/s3.Dockerfile",
"migrations/001_initial.sql",
"migrations/002_idempotency.sql",
"migrations/003_attachments.sql",
"migrations/004_pipeline.sql",
"requirements-experiment.txt",
"requirements.txt",
"scripts/bootstrap_s3.sh",
"scripts/experiment.py",
"scripts/healthcheck.py",
"scripts/restart.sh",
"scripts/restore-api.sh",
"scripts/setup.sh",
"scripts/stack.py",
"scripts/start.sh",
"scripts/stop-one.sh",
"scripts/test_expiry.sh",
"scripts/wait_ready.py",
"src/__init__.py",
"src/attachments.py",
"src/broker.py",
"src/cleanup.py",
"src/config.py",
"src/dispatcher.py",
"src/errors.py",
"src/faults.py",
"src/image_pipeline.py",
"src/jobs.py",
"src/main.py",
"src/migrate.py",
"src/storage.py",
"src/worker.py",
"student-tests/attachments.py",
"student-tests/checks.py",
"student-tests/database.py",
"student-tests/dependencies.py",
"student-tests/file_failover.py",
"student-tests/idempotency.py",
"student-tests/pipeline_scenario.py",
"student-tests/test_api.py",
"student-tests/variants.py"
],
"changed": [
".dockerignore",
".gitignore",
"Makefile",
"REPORT.md"
],
"same": [
".env.example",
".github/pull_request_template.md",
".github/workflows/contracts.yml",
"CONTRIBUTING.md",
"COURSE.md",
"Dockerfile.example",
"MAINTAINERS.md",
"README.md",
"compose.example.yaml",
"contracts/README.md",
"contracts/attachment-states.md",
"contracts/examples.json",
"contracts/infrastructure.json",
"contracts/jobs.schema.json",
"contracts/openapi.json",
"evidence/README.md",
"examples/requests.http",
"infra/README.md",
"lab.json",
"requirements-dev.txt",
"scripts/check_contract.py",
"scripts/restart.example.sh",
"scripts/stop-one.example.sh",
"scripts/validate_openapi.py",
"tests/README.md",
"tests/client.py",
"tests/fixtures/README.md",
"tests/fixtures/sample.png",
"tests/image_probe.py",
"tests/load.py",
"tests/resilience.py",
"tests/smoke.py"
],
"preserved": [
".git",
"AGENTS.md",
"CODEX_HANDOFF.md"
],
"source_archive_sha256": "434c735cf6f870ed4e462563a192ea7ed82c9517d1411fb6f9d84ed4cd03d863",
"source_archive": "/home/kitsune/visotka/incoming/mtusi2026lab5_solution.zip"
}
+340
View File
@@ -0,0 +1,340 @@
{
"target": "768f094b3536:ba81595e",
"stopped_container": "768f094b3536247e53a7fa69357a507504aa11cd094149723e47ec1758b0805d",
"before": [
{
"id": "6d5ccd7883e55d222f7bcb15064b8a7c0d5722ca54f2c941d4ba35b1e1ef4128",
"name": "mtusi2026lab5-api-1",
"hostname": "6d5ccd7883e5",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:44:11.837673643Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "768f094b3536247e53a7fa69357a507504aa11cd094149723e47ec1758b0805d",
"name": "mtusi2026lab5-api-2",
"hostname": "768f094b3536",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:44:12.329596734Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "926c8de7fdfd9772c439414fc2e468cc0c23c641b68a83b84e4d8cb4e4998548",
"name": "mtusi2026lab5-broker-1",
"hostname": "926c8de7fdfd",
"service": "broker",
"running": true,
"started_at": "2026-10-26T13:44:16.426131982Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "664d5065e4e2057903eaf1e47fe90f099597e81d28324c54f81141d3255a6f63",
"name": "mtusi2026lab5-cache-1",
"hostname": "664d5065e4e2",
"service": "cache",
"running": true,
"started_at": "2026-10-26T13:21:15.687084123Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "a8efd18d965de2c9a1c93cf00e9230cb17f6b769af6446228ded6d262c12f650",
"name": "mtusi2026lab5-db-1",
"hostname": "a8efd18d965d",
"service": "db",
"running": true,
"started_at": "2026-10-26T13:21:23.472099949Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"5432/tcp": null
}
},
{
"id": "9dddbe68f5014a882f21775814a22bff73c2e7afa06aec44f6afaacf862e0938",
"name": "mtusi2026lab5-dispatcher-1",
"hostname": "9dddbe68f501",
"service": "dispatcher",
"running": true,
"started_at": "2026-10-26T13:53:56.773872211Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "17d5d00bd730356064b7324bfb190a5726be5dde524938e43a0e95fda8a097d2",
"name": "mtusi2026lab5-lb-1",
"hostname": "17d5d00bd730",
"service": "lb",
"running": true,
"started_at": "2026-10-26T13:20:11.844174641Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"8080/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "8080"
}
]
}
},
{
"id": "85c2bb372517d143c1bc4f0d62f919c03fcd0b2922f6d80527b5dd967afc87a2",
"name": "mtusi2026lab5-migrate-1",
"hostname": "85c2bb372517",
"service": "migrate",
"running": false,
"started_at": "2026-10-26T13:21:01.323626814Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "a62f7b1a9e058209c3e1c8e99fc418406270224effc82faa4bf1587d1250c18a",
"name": "mtusi2026lab5-reconciler-1",
"hostname": "a62f7b1a9e05",
"service": "reconciler",
"running": true,
"started_at": "2026-10-26T13:53:57.612149851Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "5bd819ea48506fa8a38869e22ddc3607f8f9aeb23348b4b46aa594acdd61466a",
"name": "mtusi2026lab5-s3-1",
"hostname": "5bd819ea4850",
"service": "s3",
"running": true,
"started_at": "2026-10-26T13:52:45.447139686Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "9a802ad7d2417be1c16ff80944bc599eeb8ad9bcd0c91ab7c0dbfa761154b22c",
"name": "mtusi2026lab5-s3-bootstrap-1",
"hostname": "9a802ad7d241",
"service": "s3-bootstrap",
"running": false,
"started_at": "2026-10-26T13:21:01.324968308Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "e1b41eef77857e6216dd324988b41d2a7386ee93c2405dce35e9f22917c914dd",
"name": "mtusi2026lab5-worker-1",
"hostname": "e1b41eef7785",
"service": "worker",
"running": true,
"started_at": "2026-10-26T13:53:56.773642491Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 805306368,
"published_ports": {
"8080/tcp": null
}
}
],
"after": [
{
"id": "6d5ccd7883e55d222f7bcb15064b8a7c0d5722ca54f2c941d4ba35b1e1ef4128",
"name": "mtusi2026lab5-api-1",
"hostname": "6d5ccd7883e5",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:44:11.837673643Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "768f094b3536247e53a7fa69357a507504aa11cd094149723e47ec1758b0805d",
"name": "mtusi2026lab5-api-2",
"hostname": "768f094b3536",
"service": "api",
"running": false,
"started_at": "2026-10-26T13:44:12.329596734Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "926c8de7fdfd9772c439414fc2e468cc0c23c641b68a83b84e4d8cb4e4998548",
"name": "mtusi2026lab5-broker-1",
"hostname": "926c8de7fdfd",
"service": "broker",
"running": true,
"started_at": "2026-10-26T13:44:16.426131982Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "664d5065e4e2057903eaf1e47fe90f099597e81d28324c54f81141d3255a6f63",
"name": "mtusi2026lab5-cache-1",
"hostname": "664d5065e4e2",
"service": "cache",
"running": true,
"started_at": "2026-10-26T13:21:15.687084123Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "a8efd18d965de2c9a1c93cf00e9230cb17f6b769af6446228ded6d262c12f650",
"name": "mtusi2026lab5-db-1",
"hostname": "a8efd18d965d",
"service": "db",
"running": true,
"started_at": "2026-10-26T13:21:23.472099949Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"5432/tcp": null
}
},
{
"id": "9dddbe68f5014a882f21775814a22bff73c2e7afa06aec44f6afaacf862e0938",
"name": "mtusi2026lab5-dispatcher-1",
"hostname": "9dddbe68f501",
"service": "dispatcher",
"running": true,
"started_at": "2026-10-26T13:53:56.773872211Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "17d5d00bd730356064b7324bfb190a5726be5dde524938e43a0e95fda8a097d2",
"name": "mtusi2026lab5-lb-1",
"hostname": "17d5d00bd730",
"service": "lb",
"running": true,
"started_at": "2026-10-26T13:20:11.844174641Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"8080/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "8080"
}
]
}
},
{
"id": "85c2bb372517d143c1bc4f0d62f919c03fcd0b2922f6d80527b5dd967afc87a2",
"name": "mtusi2026lab5-migrate-1",
"hostname": "85c2bb372517",
"service": "migrate",
"running": false,
"started_at": "2026-10-26T13:21:01.323626814Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "a62f7b1a9e058209c3e1c8e99fc418406270224effc82faa4bf1587d1250c18a",
"name": "mtusi2026lab5-reconciler-1",
"hostname": "a62f7b1a9e05",
"service": "reconciler",
"running": true,
"started_at": "2026-10-26T13:53:57.612149851Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "5bd819ea48506fa8a38869e22ddc3607f8f9aeb23348b4b46aa594acdd61466a",
"name": "mtusi2026lab5-s3-1",
"hostname": "5bd819ea4850",
"service": "s3",
"running": true,
"started_at": "2026-10-26T13:52:45.447139686Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "9a802ad7d2417be1c16ff80944bc599eeb8ad9bcd0c91ab7c0dbfa761154b22c",
"name": "mtusi2026lab5-s3-bootstrap-1",
"hostname": "9a802ad7d241",
"service": "s3-bootstrap",
"running": false,
"started_at": "2026-10-26T13:21:01.324968308Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "e1b41eef77857e6216dd324988b41d2a7386ee93c2405dce35e9f22917c914dd",
"name": "mtusi2026lab5-worker-1",
"hostname": "e1b41eef7785",
"service": "worker",
"running": true,
"started_at": "2026-10-26T13:53:56.773642491Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 805306368,
"published_ports": {
"8080/tcp": null
}
}
]
}
+2
View File
@@ -0,0 +1,2 @@
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
+2
View File
@@ -0,0 +1,2 @@
BASE_URL="http://localhost:8080" python3 student-tests/dependencies.py
PASS: Redis fallback, PostgreSQL 503 and recovery, old token/message/original preserved
+21
View File
@@ -0,0 +1,21 @@
{
"captured_at": "2026-10-26T13:16:22.365436+00:00",
"uname": {
"system": "Linux",
"node": "LAPTOP-66HKAM8B",
"release": "5.15.146.1-microsoft-standard-WSL2",
"version": "#1 SMP Thu Jan 11 04:09:03 UTC 2024",
"machine": "x86_64",
"processor": "x86_64"
},
"cpu_model": "12th Gen Intel(R) Core(TM) i5-1240P",
"host_cpus": 16,
"host_python": "3.10.12",
"docker_server": "26.1.1",
"docker_cpus": 16,
"docker_memory_bytes": 8187711488,
"compose": "2.27.0-desktop.2",
"disk": "Filesystem Size Used Avail Use% Mounted on\n/dev/sde 1007G 7.6G 949G 1% /",
"git_head": "276dbdad8a34da4c5b57fbf1879ca169b581d75b",
"upstream_head": "276dbdad8a34da4c5b57fbf1879ca169b581d75b\tHEAD"
}
+41
View File
@@ -0,0 +1,41 @@
BASE_URL="http://localhost:8080" python3 scripts/experiment.py --repeats 3
PASS: accepted_restart_broker_api, repeat 1/3
PASS: before_publish, repeat 1/3
PASS: after_publish, repeat 1/3
PASS: before_effect, repeat 1/3
PASS: after_original, repeat 1/3
PASS: after_effects, repeat 1/3
PASS: after_commit, repeat 1/3
PASS: duplicates_and_invalid_carrier, repeat 1/3
PASS: reorder_new_before_old, repeat 1/3
PASS: stale_after_new_ready, repeat 1/3
PASS: permanent_failure_replay, repeat 1/3
PASS: bounded_retry_and_replay, repeat 1/3
PASS: staging_retention_and_privacy, repeat 1/3
PASS: accepted_restart_broker_api, repeat 2/3
PASS: before_publish, repeat 2/3
PASS: after_publish, repeat 2/3
PASS: before_effect, repeat 2/3
PASS: after_original, repeat 2/3
PASS: after_effects, repeat 2/3
PASS: after_commit, repeat 2/3
PASS: duplicates_and_invalid_carrier, repeat 2/3
PASS: reorder_new_before_old, repeat 2/3
PASS: stale_after_new_ready, repeat 2/3
PASS: permanent_failure_replay, repeat 2/3
PASS: bounded_retry_and_replay, repeat 2/3
PASS: staging_retention_and_privacy, repeat 2/3
PASS: accepted_restart_broker_api, repeat 3/3
PASS: before_publish, repeat 3/3
PASS: after_publish, repeat 3/3
PASS: before_effect, repeat 3/3
PASS: after_original, repeat 3/3
PASS: after_effects, repeat 3/3
PASS: after_commit, repeat 3/3
PASS: duplicates_and_invalid_carrier, repeat 3/3
PASS: reorder_new_before_old, repeat 3/3
PASS: stale_after_new_ready, repeat 3/3
PASS: permanent_failure_replay, repeat 3/3
PASS: bounded_retry_and_replay, repeat 3/3
PASS: staging_retention_and_privacy, repeat 3/3
Experiment completed; results saved in evidence/
+20
View File
@@ -0,0 +1,20 @@
bash scripts/test_expiry.sh
Container mtusi2026lab5-api-2 Recreate
Container mtusi2026lab5-api-1 Recreate
Container mtusi2026lab5-api-2 Recreated
Container mtusi2026lab5-api-1 Recreated
Container mtusi2026lab5-api-1 Starting
Container mtusi2026lab5-api-1 Started
Container mtusi2026lab5-api-2 Starting
Container mtusi2026lab5-api-2 Started
API ready: 2896c7c8071b:d9fb9ed4, 60f92a7fb3ee:50d56ff0
PASS: short TTL expiry
Container mtusi2026lab5-api-1 Recreate
Container mtusi2026lab5-api-2 Recreate
Container mtusi2026lab5-api-2 Recreated
Container mtusi2026lab5-api-1 Recreated
Container mtusi2026lab5-api-2 Starting
Container mtusi2026lab5-api-2 Started
Container mtusi2026lab5-api-1 Starting
Container mtusi2026lab5-api-1 Started
API ready: 10ea4363b2a5:8701cfd9, f0e7bd13e2a9:0fe67afe
+4
View File
@@ -0,0 +1,4 @@
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8080"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 114, "failed_attempts": 3, "first_recovery_seconds": 2.581}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+4
View File
@@ -0,0 +1,4 @@
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8080"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 110, "failed_attempts": 4, "first_recovery_seconds": 2.521}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+2
View File
@@ -0,0 +1,2 @@
BASE_URL="http://localhost:8080" python3 student-tests/file_failover.py
PASS: upload API stopped, original downloaded by other API with existing token
+4
View File
@@ -0,0 +1,4 @@
python3 student-tests/attachments.py --base-url "http://localhost:8080"
PASS: PNG/JPEG, bytes/pixels limits, filename/MIME, ACL, attachment message replay
python3 student-tests/variants.py --base-url "http://localhost:8080"
PASS: thumbnail/crop/WebP bytes, sizes, EXIF orientation, white alpha, no upscaling, ACL
+2
View File
@@ -0,0 +1,2 @@
BASE_URL="http://localhost:8080" python3 scripts/stack.py wait --count 2
API ready: 6d5ccd7883e5:4a86795b, 768f094b3536:7add9f11
+2
View File
@@ -0,0 +1,2 @@
python3 tests/smoke.py --base-url "http://localhost:8080"
PASS: lab5 public API scenario; infrastructure and grading evidence remain separate.
+45
View File
@@ -0,0 +1,45 @@
Collecting openapi-spec-validator==0.7.2
Using cached openapi_spec_validator-0.7.2-py3-none-any.whl (39 kB)
Collecting Pillow==12.0.0
Using cached pillow-12.0.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (7.0 MB)
Collecting jsonschema-path<0.4.0,>=0.3.1
Using cached jsonschema_path-0.3.4-py3-none-any.whl (14 kB)
Collecting openapi-schema-validator<0.7.0,>=0.6.0
Using cached openapi_schema_validator-0.6.3-py3-none-any.whl (8.8 kB)
Collecting lazy-object-proxy<2.0.0,>=1.7.1
Using cached lazy_object_proxy-1.12.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (67 kB)
Collecting jsonschema<5.0.0,>=4.18.0
Using cached jsonschema-4.26.0-py3-none-any.whl (90 kB)
Collecting attrs>=22.2.0
Using cached attrs-26.1.0-py3-none-any.whl (67 kB)
Collecting referencing>=0.28.4
Using cached referencing-0.37.0-py3-none-any.whl (26 kB)
Collecting jsonschema-specifications>=2023.03.6
Using cached jsonschema_specifications-2025.9.1-py3-none-any.whl (18 kB)
Collecting rpds-py>=0.25.0
Using cached rpds_py-0.30.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (390 kB)
Collecting pathable<0.5.0,>=0.4.1
Using cached pathable-0.4.4-py3-none-any.whl (9.6 kB)
Collecting PyYAML>=5.1
Using cached pyyaml-6.0.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (770 kB)
Collecting requests<3.0.0,>=2.31.0
Using cached requests-2.34.2-py3-none-any.whl (73 kB)
Collecting referencing>=0.28.4
Using cached referencing-0.36.2-py3-none-any.whl (26 kB)
Collecting rfc3339-validator
Using cached rfc3339_validator-0.1.4-py2.py3-none-any.whl (3.5 kB)
Collecting typing-extensions>=4.4.0
Using cached typing_extensions-4.16.0-py3-none-any.whl (45 kB)
Collecting certifi>=2023.5.7
Downloading certifi-2026.10.23-py3-none-any.whl (135 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 135.1/135.1 KB 4.4 MB/s eta 0:00:00
Collecting urllib3<3,>=1.26
Using cached urllib3-2.8.0-py3-none-any.whl (135 kB)
Collecting charset_normalizer<4,>=2
Using cached charset_normalizer-3.5.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (271 kB)
Collecting idna<4,>=2.5
Using cached idna-3.20-py3-none-any.whl (69 kB)
Collecting six
Using cached six-1.17.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: urllib3, typing-extensions, six, rpds-py, PyYAML, Pillow, pathable, lazy-object-proxy, idna, charset_normalizer, certifi, attrs, rfc3339-validator, requests, referencing, jsonschema-specifications, jsonschema-path, jsonschema, openapi-schema-validator, openapi-spec-validator
Successfully installed Pillow-12.0.0 PyYAML-6.0.3 attrs-26.1.0 certifi-2026.10.23 charset_normalizer-3.5.2 idna-3.20 jsonschema-4.26.0 jsonschema-path-0.3.4 jsonschema-specifications-2025.9.1 lazy-object-proxy-1.12.0 openapi-schema-validator-0.6.3 openapi-spec-validator-0.7.2 pathable-0.4.4 referencing-0.36.2 requests-2.34.2 rfc3339-validator-0.1.4 rpds-py-0.30.0 six-1.17.0 typing-extensions-4.16.0 urllib3-2.8.0
+3
View File
@@ -0,0 +1,3 @@
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost:8080"
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
@@ -0,0 +1,4 @@
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost:8080"
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
FAIL: restart hook failed (inspect your script locally)
make: *** [Makefile:26: test-persistence] Error 1
@@ -0,0 +1,3 @@
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost:8080"
FAIL: GET /health/live: connection/TLS failure (URLError)
make: *** [Makefile:26: test-persistence] Error 1
+1
View File
@@ -0,0 +1 @@
No broken requirements found.
+2
View File
@@ -0,0 +1,2 @@
BASE_URL="http://localhost:8080" python3 scripts/stack.py wait --count 2
API ready: c754d451d054:f8ee8f14, ca5bb0478ca7:e2d9a089
+40
View File
@@ -0,0 +1,40 @@
Container mtusi2026lab5-dispatcher-1 Stopping
Container mtusi2026lab5-lb-1 Stopping
Container mtusi2026lab5-worker-1 Stopping
Container mtusi2026lab5-reconciler-1 Stopping
Container mtusi2026lab5-dispatcher-1 Stopped
Container mtusi2026lab5-lb-1 Stopped
Container mtusi2026lab5-api-2 Stopping
Container mtusi2026lab5-api-1 Stopping
Container mtusi2026lab5-worker-1 Stopped
Container mtusi2026lab5-broker-1 Stopping
Container mtusi2026lab5-reconciler-1 Stopped
Container mtusi2026lab5-api-1 Stopped
Container mtusi2026lab5-broker-1 Stopped
Container mtusi2026lab5-api-2 Stopped
Container mtusi2026lab5-db-1 Stopping
Container mtusi2026lab5-cache-1 Stopping
Container mtusi2026lab5-s3-1 Stopping
Container mtusi2026lab5-s3-1 Stopped
Container mtusi2026lab5-cache-1 Stopped
Container mtusi2026lab5-db-1 Stopped
Container mtusi2026lab5-db-1 Created
Container mtusi2026lab5-s3-1 Created
Container mtusi2026lab5-cache-1 Created
Container mtusi2026lab5-broker-1 Created
Container mtusi2026lab5-cache-1 Starting
Container mtusi2026lab5-s3-1 Starting
Container mtusi2026lab5-db-1 Starting
Container mtusi2026lab5-broker-1 Starting
Container mtusi2026lab5-db-1 Started
Container mtusi2026lab5-broker-1 Started
Container mtusi2026lab5-s3-1 Started
Container mtusi2026lab5-cache-1 Started
Container mtusi2026lab5-db-1 Waiting
Container mtusi2026lab5-s3-1 Waiting
Container mtusi2026lab5-cache-1 Waiting
Container mtusi2026lab5-broker-1 Waiting
Container mtusi2026lab5-db-1 Healthy
Container mtusi2026lab5-s3-1 Healthy
Container mtusi2026lab5-cache-1 Healthy
container mtusi2026lab5-broker-1 exited (2)
+70
View File
@@ -0,0 +1,70 @@
Container mtusi2026lab5-reconciler-1 Stopping
Container mtusi2026lab5-worker-1 Stopping
Container mtusi2026lab5-lb-1 Stopping
Container mtusi2026lab5-dispatcher-1 Stopping
Container mtusi2026lab5-lb-1 Stopped
Container mtusi2026lab5-api-2 Stopping
Container mtusi2026lab5-api-1 Stopping
Container mtusi2026lab5-reconciler-1 Stopped
Container mtusi2026lab5-dispatcher-1 Stopped
Container mtusi2026lab5-worker-1 Stopped
Container mtusi2026lab5-broker-1 Stopping
Container mtusi2026lab5-api-2 Stopped
Container mtusi2026lab5-api-1 Stopped
Container mtusi2026lab5-cache-1 Stopping
Container mtusi2026lab5-db-1 Stopping
Container mtusi2026lab5-s3-1 Stopping
Container mtusi2026lab5-broker-1 Stopped
Container mtusi2026lab5-s3-1 Stopped
Container mtusi2026lab5-db-1 Stopped
Container mtusi2026lab5-cache-1 Stopped
Container mtusi2026lab5-db-1 Created
Container mtusi2026lab5-cache-1 Created
Container mtusi2026lab5-s3-1 Created
Container mtusi2026lab5-broker-1 Created
Container mtusi2026lab5-s3-1 Starting
Container mtusi2026lab5-cache-1 Starting
Container mtusi2026lab5-db-1 Starting
Container mtusi2026lab5-broker-1 Starting
Container mtusi2026lab5-s3-1 Started
Container mtusi2026lab5-broker-1 Started
Container mtusi2026lab5-db-1 Started
Container mtusi2026lab5-cache-1 Started
Container mtusi2026lab5-cache-1 Waiting
Container mtusi2026lab5-db-1 Waiting
Container mtusi2026lab5-broker-1 Waiting
Container mtusi2026lab5-s3-1 Waiting
Container mtusi2026lab5-broker-1 Healthy
Container mtusi2026lab5-s3-1 Healthy
Container mtusi2026lab5-cache-1 Healthy
Container mtusi2026lab5-db-1 Healthy
Private bucket and limited API credentials ready
Container mtusi2026lab5-api-1 Recreate
Container mtusi2026lab5-api-2 Recreate
Container mtusi2026lab5-api-1 Recreated
Container mtusi2026lab5-api-2 Recreated
Container mtusi2026lab5-api-2 Starting
Container mtusi2026lab5-api-2 Started
Container mtusi2026lab5-api-1 Starting
Container mtusi2026lab5-api-1 Started
Container mtusi2026lab5-api-2 Waiting
Container mtusi2026lab5-api-1 Waiting
Container mtusi2026lab5-api-2 Healthy
Container mtusi2026lab5-api-1 Healthy
Container mtusi2026lab5-worker-1 Recreate
Container mtusi2026lab5-dispatcher-1 Recreate
Container mtusi2026lab5-lb-1 Recreate
Container mtusi2026lab5-reconciler-1 Recreate
Container mtusi2026lab5-lb-1 Recreated
Container mtusi2026lab5-reconciler-1 Recreated
Container mtusi2026lab5-worker-1 Recreated
Container mtusi2026lab5-dispatcher-1 Recreated
Container mtusi2026lab5-dispatcher-1 Starting
Container mtusi2026lab5-worker-1 Starting
Container mtusi2026lab5-lb-1 Starting
Container mtusi2026lab5-reconciler-1 Starting
Container mtusi2026lab5-reconciler-1 Started
Container mtusi2026lab5-dispatcher-1 Started
Container mtusi2026lab5-worker-1 Started
Container mtusi2026lab5-lb-1 Started
API ready: 19035f4f4225:387e2313, 8f4a872818e5:131c6854
+17
View File
@@ -0,0 +1,17 @@
Container mtusi2026lab5-db-1 Waiting
Container mtusi2026lab5-s3-1 Waiting
Container mtusi2026lab5-db-1 Healthy
Container mtusi2026lab5-migrate-1 Starting
Container mtusi2026lab5-s3-1 Healthy
Container mtusi2026lab5-s3-bootstrap-1 Starting
Container mtusi2026lab5-s3-bootstrap-1 Started
Container mtusi2026lab5-migrate-1 Started
Container mtusi2026lab5-s3-bootstrap-1 Waiting
Container mtusi2026lab5-migrate-1 Waiting
Container mtusi2026lab5-cache-1 Waiting
Container mtusi2026lab5-cache-1 Healthy
Container mtusi2026lab5-migrate-1 Exited
Container mtusi2026lab5-s3-bootstrap-1 Exited
Container mtusi2026lab5-api-2 Starting
Container mtusi2026lab5-api-2 Started
API ready: 6d5ccd7883e5:4a86795b, 768f094b3536:7add9f11
+2
View File
@@ -0,0 +1,2 @@
bash scripts/setup.sh
Локальные настройки подготовлены; секреты не выводятся.
+2
View File
@@ -0,0 +1,2 @@
python3 tests/smoke.py --base-url "http://localhost:8080"
PASS: lab5 public API scenario; infrastructure and grading evidence remain separate.
+788
View File
@@ -0,0 +1,788 @@
bash scripts/start.sh
broker Pulling
lb Pulling
cache Pulling
b1badc6e5066 Already exists
93966a25fd29 Pulling fs layer
7fffeaaf8311 Pulling fs layer
4125f09b2efb Pulling fs layer
426458412bd2 Pulling fs layer
4f4fb700ef54 Pulling fs layer
426458412bd2 Waiting
4f4fb700ef54 Waiting
61320b01ae5e Pulling fs layer
f8f9e5369fdd Pulling fs layer
5cf79f4aceb3 Pulling fs layer
698c8d1b3fd1 Pulling fs layer
601d7fdb78f5 Pulling fs layer
98e4482f5fee Pulling fs layer
4f4fb700ef54 Pulling fs layer
0eeb2b86c9b7 Pulling fs layer
61320b01ae5e Waiting
601d7fdb78f5 Waiting
98e4482f5fee Waiting
4f4fb700ef54 Waiting
0eeb2b86c9b7 Waiting
f8f9e5369fdd Waiting
5cf79f4aceb3 Waiting
698c8d1b3fd1 Waiting
7fffeaaf8311 Downloading [==================================================>] 1.159kB/1.159kB
7fffeaaf8311 Verifying Checksum
7fffeaaf8311 Download complete
93966a25fd29 Downloading [> ] 49.15kB/3.51MB
4125f09b2efb Downloading [> ] 96.97kB/9.437MB
93966a25fd29 Downloading [============> ] 863.9kB/3.51MB
4125f09b2efb Downloading [==> ] 391.9kB/9.437MB
93966a25fd29 Downloading [=================================> ] 2.337MB/3.51MB
4125f09b2efb Downloading [=====> ] 980.1kB/9.437MB
61320b01ae5e Pulling fs layer
f8f9e5369fdd Pulling fs layer
5cf79f4aceb3 Pulling fs layer
698c8d1b3fd1 Pulling fs layer
601d7fdb78f5 Pulling fs layer
98e4482f5fee Pulling fs layer
61320b01ae5e Waiting
4f4fb700ef54 Pulling fs layer
0eeb2b86c9b7 Pulling fs layer
0eeb2b86c9b7 Waiting
f8f9e5369fdd Waiting
5cf79f4aceb3 Waiting
698c8d1b3fd1 Waiting
601d7fdb78f5 Waiting
98e4482f5fee Waiting
4f4fb700ef54 Waiting
93966a25fd29 Downloading [==================================================>] 3.51MB/3.51MB
93966a25fd29 Verifying Checksum
93966a25fd29 Download complete
93966a25fd29 Extracting [> ] 65.54kB/3.51MB
4125f09b2efb Downloading [==========> ] 2.061MB/9.437MB
4125f09b2efb Downloading [========================> ] 4.598MB/9.437MB
93966a25fd29 Extracting [===> ] 262.1kB/3.51MB
4125f09b2efb Downloading [===================================> ] 6.758MB/9.437MB
93966a25fd29 Extracting [=========================> ] 1.769MB/3.51MB
426458412bd2 Downloading [==================================================>] 448B/448B
426458412bd2 Verifying Checksum
426458412bd2 Download complete
4125f09b2efb Downloading [===============================================> ] 8.881MB/9.437MB
4125f09b2efb Verifying Checksum
4125f09b2efb Download complete
93966a25fd29 Extracting [============================================> ] 3.146MB/3.51MB
93966a25fd29 Extracting [==================================================>] 3.51MB/3.51MB
93966a25fd29 Extracting [==================================================>] 3.51MB/3.51MB
93966a25fd29 Pull complete
7fffeaaf8311 Extracting [==================================================>] 1.159kB/1.159kB
7fffeaaf8311 Extracting [==================================================>] 1.159kB/1.159kB
7fffeaaf8311 Pull complete
4125f09b2efb Extracting [> ] 98.3kB/9.437MB
4f4fb700ef54 Downloading [==================================================>] 32B/32B
4f4fb700ef54 Verifying Checksum
4f4fb700ef54 Download complete
4125f09b2efb Extracting [=============> ] 2.556MB/9.437MB
4125f09b2efb Extracting [====================================> ] 6.881MB/9.437MB
4125f09b2efb Extracting [==================================================>] 9.437MB/9.437MB
4125f09b2efb Pull complete
426458412bd2 Extracting [==================================================>] 448B/448B
426458412bd2 Extracting [==================================================>] 448B/448B
426458412bd2 Pull complete
4f4fb700ef54 Extracting [==================================================>] 32B/32B
4f4fb700ef54 Extracting [==================================================>] 32B/32B
61320b01ae5e Downloading [> ] 294.2kB/28.23MB
61320b01ae5e Downloading [> ] 294.2kB/28.23MB
4f4fb700ef54 Pull complete
lb Pulled
61320b01ae5e Downloading [===> ] 1.769MB/28.23MB
61320b01ae5e Downloading [===> ] 1.769MB/28.23MB
f8f9e5369fdd Downloading [==================================================>] 1.104kB/1.104kB
f8f9e5369fdd Verifying Checksum
f8f9e5369fdd Download complete
f8f9e5369fdd Downloading [==================================================>] 1.104kB/1.104kB
f8f9e5369fdd Verifying Checksum
f8f9e5369fdd Download complete
61320b01ae5e Downloading [======> ] 3.833MB/28.23MB
61320b01ae5e Downloading [======> ] 3.833MB/28.23MB
5cf79f4aceb3 Verifying Checksum
5cf79f4aceb3 Download complete
5cf79f4aceb3 Downloading [==================================================>] 874B/874B
5cf79f4aceb3 Download complete
61320b01ae5e Downloading [==========> ] 5.898MB/28.23MB
61320b01ae5e Downloading [==========> ] 5.898MB/28.23MB
61320b01ae5e Downloading [==============> ] 8.257MB/28.23MB
61320b01ae5e Downloading [==============> ] 8.257MB/28.23MB
61320b01ae5e Downloading [==================> ] 10.62MB/28.23MB
61320b01ae5e Downloading [==================> ] 10.62MB/28.23MB
61320b01ae5e Downloading [======================> ] 12.68MB/28.23MB
61320b01ae5e Downloading [======================> ] 12.68MB/28.23MB
61320b01ae5e Downloading [==========================> ] 14.74MB/28.23MB
61320b01ae5e Downloading [==========================> ] 14.74MB/28.23MB
61320b01ae5e Downloading [==============================> ] 17.1MB/28.23MB
61320b01ae5e Downloading [==============================> ] 17.1MB/28.23MB
61320b01ae5e Downloading [==================================> ] 19.46MB/28.23MB
61320b01ae5e Downloading [==================================> ] 19.46MB/28.23MB
601d7fdb78f5 Downloading [> ] 162.5kB/15.34MB
601d7fdb78f5 Downloading [> ] 162.5kB/15.34MB
61320b01ae5e Downloading [=====================================> ] 20.94MB/28.23MB
61320b01ae5e Downloading [=====================================> ] 20.94MB/28.23MB
601d7fdb78f5 Downloading [====> ] 1.301MB/15.34MB
601d7fdb78f5 Downloading [====> ] 1.301MB/15.34MB
61320b01ae5e Downloading [=======================================> ] 22.12MB/28.23MB
61320b01ae5e Downloading [=======================================> ] 22.12MB/28.23MB
601d7fdb78f5 Downloading [========> ] 2.613MB/15.34MB
601d7fdb78f5 Downloading [========> ] 2.613MB/15.34MB
61320b01ae5e Downloading [=========================================> ] 23.3MB/28.23MB
61320b01ae5e Downloading [=========================================> ] 23.3MB/28.23MB
601d7fdb78f5 Downloading [============> ] 3.9MB/15.34MB
601d7fdb78f5 Downloading [============> ] 3.9MB/15.34MB
61320b01ae5e Downloading [===========================================> ] 24.48MB/28.23MB
61320b01ae5e Downloading [===========================================> ] 24.48MB/28.23MB
601d7fdb78f5 Downloading [================> ] 5.18MB/15.34MB
601d7fdb78f5 Downloading [================> ] 5.18MB/15.34MB
61320b01ae5e Downloading [=============================================> ] 25.95MB/28.23MB
61320b01ae5e Downloading [=============================================> ] 25.95MB/28.23MB
601d7fdb78f5 Downloading [=====================> ] 6.459MB/15.34MB
601d7fdb78f5 Downloading [=====================> ] 6.459MB/15.34MB
61320b01ae5e Downloading [================================================> ] 27.13MB/28.23MB
61320b01ae5e Downloading [================================================> ] 27.13MB/28.23MB
601d7fdb78f5 Downloading [=========================> ] 7.737MB/15.34MB
601d7fdb78f5 Downloading [=========================> ] 7.737MB/15.34MB
61320b01ae5e Verifying Checksum
61320b01ae5e Download complete
61320b01ae5e Verifying Checksum
61320b01ae5e Download complete
601d7fdb78f5 Downloading [=============================> ] 9.179MB/15.34MB
601d7fdb78f5 Downloading [=============================> ] 9.179MB/15.34MB
698c8d1b3fd1 Downloading [> ] 15.74kB/1.438MB
698c8d1b3fd1 Downloading [> ] 15.74kB/1.438MB
61320b01ae5e Extracting [> ] 294.9kB/28.23MB
61320b01ae5e Extracting [> ] 294.9kB/28.23MB
698c8d1b3fd1 Downloading [===================================> ] 1.013MB/1.438MB
698c8d1b3fd1 Downloading [===================================> ] 1.013MB/1.438MB
601d7fdb78f5 Downloading [==================================> ] 10.46MB/15.34MB
601d7fdb78f5 Downloading [==================================> ] 10.46MB/15.34MB
698c8d1b3fd1 Download complete
698c8d1b3fd1 Download complete
61320b01ae5e Extracting [===> ] 1.769MB/28.23MB
61320b01ae5e Extracting [===> ] 1.769MB/28.23MB
601d7fdb78f5 Downloading [=======================================> ] 12.09MB/15.34MB
601d7fdb78f5 Downloading [=======================================> ] 12.09MB/15.34MB
61320b01ae5e Extracting [======> ] 3.539MB/28.23MB
61320b01ae5e Extracting [======> ] 3.539MB/28.23MB
601d7fdb78f5 Downloading [=============================================> ] 14.02MB/15.34MB
601d7fdb78f5 Downloading [=============================================> ] 14.02MB/15.34MB
601d7fdb78f5 Verifying Checksum
601d7fdb78f5 Download complete
601d7fdb78f5 Verifying Checksum
601d7fdb78f5 Download complete
61320b01ae5e Extracting [=========> ] 5.308MB/28.23MB
61320b01ae5e Extracting [=========> ] 5.308MB/28.23MB
61320b01ae5e Extracting [=============> ] 7.668MB/28.23MB
61320b01ae5e Extracting [=============> ] 7.668MB/28.23MB
98e4482f5fee Download complete
98e4482f5fee Downloading [==================================================>] 97B/97B
98e4482f5fee Download complete
61320b01ae5e Extracting [================> ] 9.142MB/28.23MB
61320b01ae5e Extracting [================> ] 9.142MB/28.23MB
4f4fb700ef54 Download complete
4f4fb700ef54 Downloading [==================================================>] 32B/32B
4f4fb700ef54 Verifying Checksum
4f4fb700ef54 Download complete
61320b01ae5e Extracting [=================> ] 10.03MB/28.23MB
61320b01ae5e Extracting [=================> ] 10.03MB/28.23MB
61320b01ae5e Extracting [===================> ] 11.21MB/28.23MB
61320b01ae5e Extracting [===================> ] 11.21MB/28.23MB
61320b01ae5e Extracting [=========================> ] 14.45MB/28.23MB
61320b01ae5e Extracting [=========================> ] 14.45MB/28.23MB
0eeb2b86c9b7 Download complete
0eeb2b86c9b7 Downloading [==================================================>] 572B/572B
0eeb2b86c9b7 Verifying Checksum
0eeb2b86c9b7 Download complete
61320b01ae5e Extracting [================================> ] 18.58MB/28.23MB
61320b01ae5e Extracting [================================> ] 18.58MB/28.23MB
61320b01ae5e Extracting [======================================> ] 21.82MB/28.23MB
61320b01ae5e Extracting [======================================> ] 21.82MB/28.23MB
61320b01ae5e Extracting [=========================================> ] 23.3MB/28.23MB
61320b01ae5e Extracting [=========================================> ] 23.3MB/28.23MB
61320b01ae5e Extracting [==========================================> ] 23.89MB/28.23MB
61320b01ae5e Extracting [==========================================> ] 23.89MB/28.23MB
61320b01ae5e Extracting [===========================================> ] 24.77MB/28.23MB
61320b01ae5e Extracting [===========================================> ] 24.77MB/28.23MB
61320b01ae5e Extracting [===============================================> ] 26.84MB/28.23MB
61320b01ae5e Extracting [===============================================> ] 26.84MB/28.23MB
61320b01ae5e Extracting [================================================> ] 27.13MB/28.23MB
61320b01ae5e Extracting [================================================> ] 27.13MB/28.23MB
61320b01ae5e Extracting [================================================> ] 27.43MB/28.23MB
61320b01ae5e Extracting [================================================> ] 27.43MB/28.23MB
61320b01ae5e Extracting [=================================================> ] 28.02MB/28.23MB
61320b01ae5e Extracting [=================================================> ] 28.02MB/28.23MB
61320b01ae5e Extracting [==================================================>] 28.23MB/28.23MB
61320b01ae5e Extracting [==================================================>] 28.23MB/28.23MB
61320b01ae5e Pull complete
61320b01ae5e Pull complete
f8f9e5369fdd Extracting [==================================================>] 1.104kB/1.104kB
f8f9e5369fdd Extracting [==================================================>] 1.104kB/1.104kB
f8f9e5369fdd Extracting [==================================================>] 1.104kB/1.104kB
f8f9e5369fdd Extracting [==================================================>] 1.104kB/1.104kB
f8f9e5369fdd Pull complete
f8f9e5369fdd Pull complete
5cf79f4aceb3 Extracting [==================================================>] 874B/874B
5cf79f4aceb3 Extracting [==================================================>] 874B/874B
5cf79f4aceb3 Extracting [==================================================>] 874B/874B
5cf79f4aceb3 Extracting [==================================================>] 874B/874B
5cf79f4aceb3 Pull complete
5cf79f4aceb3 Pull complete
698c8d1b3fd1 Extracting [=> ] 32.77kB/1.438MB
698c8d1b3fd1 Extracting [=> ] 32.77kB/1.438MB
698c8d1b3fd1 Extracting [==================================================>] 1.438MB/1.438MB
698c8d1b3fd1 Extracting [==================================================>] 1.438MB/1.438MB
698c8d1b3fd1 Extracting [==================================================>] 1.438MB/1.438MB
698c8d1b3fd1 Extracting [==================================================>] 1.438MB/1.438MB
698c8d1b3fd1 Pull complete
698c8d1b3fd1 Pull complete
601d7fdb78f5 Extracting [> ] 163.8kB/15.34MB
601d7fdb78f5 Extracting [> ] 163.8kB/15.34MB
601d7fdb78f5 Extracting [=========> ] 2.785MB/15.34MB
601d7fdb78f5 Extracting [=========> ] 2.785MB/15.34MB
601d7fdb78f5 Extracting [=====================> ] 6.717MB/15.34MB
601d7fdb78f5 Extracting [=====================> ] 6.717MB/15.34MB
601d7fdb78f5 Extracting [==================================> ] 10.65MB/15.34MB
601d7fdb78f5 Extracting [==================================> ] 10.65MB/15.34MB
601d7fdb78f5 Extracting [==============================================> ] 14.25MB/15.34MB
601d7fdb78f5 Extracting [==============================================> ] 14.25MB/15.34MB
601d7fdb78f5 Extracting [==================================================>] 15.34MB/15.34MB
601d7fdb78f5 Extracting [==================================================>] 15.34MB/15.34MB
601d7fdb78f5 Pull complete
601d7fdb78f5 Pull complete
98e4482f5fee Extracting [==================================================>] 97B/97B
98e4482f5fee Extracting [==================================================>] 97B/97B
98e4482f5fee Extracting [==================================================>] 97B/97B
98e4482f5fee Extracting [==================================================>] 97B/97B
98e4482f5fee Pull complete
98e4482f5fee Pull complete
4f4fb700ef54 Extracting [==================================================>] 32B/32B
4f4fb700ef54 Extracting [==================================================>] 32B/32B
4f4fb700ef54 Extracting [==================================================>] 32B/32B
4f4fb700ef54 Extracting [==================================================>] 32B/32B
4f4fb700ef54 Pull complete
4f4fb700ef54 Pull complete
0eeb2b86c9b7 Extracting [==================================================>] 572B/572B
0eeb2b86c9b7 Extracting [==================================================>] 572B/572B
0eeb2b86c9b7 Extracting [==================================================>] 572B/572B
0eeb2b86c9b7 Extracting [==================================================>] 572B/572B
0eeb2b86c9b7 Pull complete
0eeb2b86c9b7 Pull complete
cache Pulled
broker Pulled
#0 building with "default" instance using docker driver
#1 [s3 internal] load build definition from s3.Dockerfile
#1 transferring dockerfile: 922B 0.0s done
#1 DONE 0.1s
#2 [migrate internal] load build definition from Dockerfile
#2 transferring dockerfile: 1.04kB done
#2 DONE 0.0s
#3 [migrate internal] load metadata for docker.io/library/python:3.12.10-slim-bookworm
#3 DONE 4.8s
#4 [s3] resolve image config for docker-image://docker.io/docker/dockerfile:1.7.0
#4 DONE 4.9s
#5 [migrate internal] load .dockerignore
#5 transferring context: 206B done
#5 DONE 0.1s
#6 [migrate 1/12] FROM docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db
#6 resolve docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db 0.0s done
#6 ...
#7 [migrate internal] load build context
#7 transferring context: 450.17kB 0.0s done
#7 DONE 0.0s
#6 [migrate 1/12] FROM docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db
#6 sha256:be1274d3cce09d8126f8176203ba1e91f6733a713c1185ba01ee704759b0b62d 0B / 3.51MB 0.1s
#6 sha256:8991c9200d621283b06ae395129d454c998e0f55095e106055240b5956ab2a2a 0B / 13.66MB 0.1s
#6 sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db 9.13kB / 9.13kB done
#6 sha256:97983fa8cc88343512862c62307159a82261c3528dc025f79e5a3f7af43e50b4 1.75kB / 1.75kB done
#6 sha256:acf8897bf01a3a0ea273a50a58fc10b6317a3e360bd29aa7c9246a54d7c63e88 5.57kB / 5.57kB done
#6 sha256:be1274d3cce09d8126f8176203ba1e91f6733a713c1185ba01ee704759b0b62d 1.05MB / 3.51MB 1.0s
#6 sha256:be1274d3cce09d8126f8176203ba1e91f6733a713c1185ba01ee704759b0b62d 2.10MB / 3.51MB 1.1s
#6 extracting sha256:be1274d3cce09d8126f8176203ba1e91f6733a713c1185ba01ee704759b0b62d
#6 sha256:be1274d3cce09d8126f8176203ba1e91f6733a713c1185ba01ee704759b0b62d 3.51MB / 3.51MB 1.2s done
#6 sha256:8991c9200d621283b06ae395129d454c998e0f55095e106055240b5956ab2a2a 1.05MB / 13.66MB 1.2s
#6 sha256:7a1cb8b882211b870d7e639e775f91e423a526092b4b3eadefbab6aa7457910d 0B / 249B 1.2s
#6 sha256:8991c9200d621283b06ae395129d454c998e0f55095e106055240b5956ab2a2a 3.15MB / 13.66MB 1.3s
#6 sha256:8991c9200d621283b06ae395129d454c998e0f55095e106055240b5956ab2a2a 7.34MB / 13.66MB 1.5s
#6 ...
#8 [s3] docker-image://docker.io/docker/dockerfile:1.7.0@sha256:dbbd5e059e8a07ff7ea6233b213b36aa516b4c53c645f1817a4dd18b83cbea56
#8 resolve docker.io/docker/dockerfile:1.7.0@sha256:dbbd5e059e8a07ff7ea6233b213b36aa516b4c53c645f1817a4dd18b83cbea56 0.0s done
#8 sha256:dbbd5e059e8a07ff7ea6233b213b36aa516b4c53c645f1817a4dd18b83cbea56 8.40kB / 8.40kB done
#8 sha256:4611ea7b7d89ce41ec5c63df83076ccec3fe8daa32a2d9c96e5decb72e9a8d67 482B / 482B done
#8 sha256:ab56f6885c985024a40925d2fa322df997655db5f361ad9f221861f9c665a290 1.26kB / 1.26kB done
#8 sha256:ccef65a67ab38a038c615e74c797b11a43d36505710abe93c87b021401bebd81 11.98MB / 11.98MB 1.2s done
#8 extracting sha256:ccef65a67ab38a038c615e74c797b11a43d36505710abe93c87b021401bebd81 0.3s done
#8 DONE 1.6s
#6 [migrate 1/12] FROM docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db
#6 sha256:8991c9200d621283b06ae395129d454c998e0f55095e106055240b5956ab2a2a 9.44MB / 13.66MB 1.6s
#6 extracting sha256:be1274d3cce09d8126f8176203ba1e91f6733a713c1185ba01ee704759b0b62d 0.4s done
#6 sha256:8991c9200d621283b06ae395129d454c998e0f55095e106055240b5956ab2a2a 13.66MB / 13.66MB 1.7s done
#6 sha256:7a1cb8b882211b870d7e639e775f91e423a526092b4b3eadefbab6aa7457910d 249B / 249B 1.8s done
#6 extracting sha256:8991c9200d621283b06ae395129d454c998e0f55095e106055240b5956ab2a2a
#6 ...
#3 [s3 internal] load metadata for docker.io/library/python:3.12.10-slim-bookworm
#3 DONE 5.1s
#6 [migrate 1/12] FROM docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db
#6 ...
#9 [s3 internal] load .dockerignore
#9 transferring context: 206B done
#9 DONE 0.0s
#6 [migrate 1/12] FROM docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db
#6 ...
#10 [s3 internal] load build context
#10 transferring context: 241B done
#10 DONE 0.0s
#6 [s3 1/12] FROM docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db
#6 resolve docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db 0.0s done
#6 sha256:be1274d3cce09d8126f8176203ba1e91f6733a713c1185ba01ee704759b0b62d 3.51MB / 3.51MB 1.2s done
#6 sha256:8991c9200d621283b06ae395129d454c998e0f55095e106055240b5956ab2a2a 13.66MB / 13.66MB 1.7s done
#6 sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db 9.13kB / 9.13kB done
#6 sha256:97983fa8cc88343512862c62307159a82261c3528dc025f79e5a3f7af43e50b4 1.75kB / 1.75kB done
#6 sha256:acf8897bf01a3a0ea273a50a58fc10b6317a3e360bd29aa7c9246a54d7c63e88 5.57kB / 5.57kB done
#6 extracting sha256:be1274d3cce09d8126f8176203ba1e91f6733a713c1185ba01ee704759b0b62d 0.4s done
#6 sha256:7a1cb8b882211b870d7e639e775f91e423a526092b4b3eadefbab6aa7457910d 249B / 249B 1.8s done
#6 extracting sha256:8991c9200d621283b06ae395129d454c998e0f55095e106055240b5956ab2a2a 1.0s done
#6 extracting sha256:7a1cb8b882211b870d7e639e775f91e423a526092b4b3eadefbab6aa7457910d
#6 extracting sha256:7a1cb8b882211b870d7e639e775f91e423a526092b4b3eadefbab6aa7457910d done
#6 DONE 3.1s
#11 [s3 2/3] RUN python - <<'PY'
#11 ...
#12 [migrate 2/12] WORKDIR /app
#12 DONE 0.2s
#13 [migrate 3/12] COPY requirements.txt .
#13 DONE 0.0s
#14 [migrate 4/12] RUN pip install --no-cache-dir --requirement requirements.txt && groupadd --system --gid 10001 app && useradd --system --uid 10001 --gid app --home-dir /nonexistent --shell /usr/sbin/nologin app
#14 1.460 Collecting annotated-types==0.8.0 (from -r requirements.txt (line 1))
#14 1.668 Downloading annotated_types-0.8.0-py3-none-any.whl.metadata (15 kB)
#14 1.771 Collecting anyio==4.15.1 (from -r requirements.txt (line 2))
#14 1.940 Downloading anyio-4.15.1-py3-none-any.whl.metadata (4.7 kB)
#14 2.677 Collecting click==8.5.0 (from -r requirements.txt (line 3))
#14 2.750 Downloading click-8.5.0-py3-none-any.whl.metadata (2.6 kB)
#14 2.899 Collecting fastapi==0.115.12 (from -r requirements.txt (line 4))
#14 2.972 Downloading fastapi-0.115.12-py3-none-any.whl.metadata (27 kB)
#14 3.075 Collecting h11==0.16.0 (from -r requirements.txt (line 5))
#14 3.148 Downloading h11-0.16.0-py3-none-any.whl.metadata (8.3 kB)
#14 3.239 Collecting idna==3.20 (from -r requirements.txt (line 6))
#14 3.313 Downloading idna-3.20-py3-none-any.whl.metadata (7.2 kB)
#14 3.628 Collecting pydantic==2.11.5 (from -r requirements.txt (line 7))
#14 3.697 Downloading pydantic-2.11.5-py3-none-any.whl.metadata (67 kB)
#14 4.742 Collecting pydantic_core==2.33.2 (from -r requirements.txt (line 8))
#14 4.814 Downloading pydantic_core-2.33.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.8 kB)
#14 5.023 Collecting starlette==0.46.2 (from -r requirements.txt (line 9))
#14 5.132 Downloading starlette-0.46.2-py3-none-any.whl.metadata (6.2 kB)
#14 5.664 Collecting typing-inspection==0.4.4 (from -r requirements.txt (line 10))
#14 5.767 Downloading typing_inspection-0.4.4-py3-none-any.whl.metadata (2.6 kB)
#14 6.639 Collecting typing_extensions==4.16.0 (from -r requirements.txt (line 11))
#14 6.712 Downloading typing_extensions-4.16.0-py3-none-any.whl.metadata (3.3 kB)
#14 7.817 Collecting uvicorn==0.34.2 (from -r requirements.txt (line 12))
#14 7.888 Downloading uvicorn-0.34.2-py3-none-any.whl.metadata (6.5 kB)
#14 9.398 Collecting psycopg==3.2.9 (from psycopg[binary]==3.2.9->-r requirements.txt (line 13))
#14 9.476 Downloading psycopg-3.2.9-py3-none-any.whl.metadata (4.5 kB)
#14 9.702 Collecting psycopg-pool==3.3.3 (from -r requirements.txt (line 14))
#14 9.838 Downloading psycopg_pool-3.3.3-py3-none-any.whl.metadata (2.8 kB)
#14 9.949 Collecting redis==5.2.1 (from -r requirements.txt (line 15))
#14 ...
#11 [s3 2/3] RUN python - <<'PY'
#11 DONE 10.3s
#15 [s3 3/3] COPY infra/minio-entrypoint.sh /entrypoint.sh
#15 DONE 0.0s
#14 [migrate 4/12] RUN pip install --no-cache-dir --requirement requirements.txt && groupadd --system --gid 10001 app && useradd --system --uid 10001 --gid app --home-dir /nonexistent --shell /usr/sbin/nologin app
#14 10.03 Downloading redis-5.2.1-py3-none-any.whl.metadata (9.1 kB)
#14 ...
#16 [s3] exporting to image
#16 exporting layers
#16 exporting layers 0.4s done
#16 writing image sha256:5816bd699104d2cd34fc3b5540a48972cb088ef213383ef48b523882868d907f done
#16 naming to docker.io/library/mtusi2026lab5-minio:2025-04-22 done
#16 DONE 0.4s
#14 [migrate 4/12] RUN pip install --no-cache-dir --requirement requirements.txt && groupadd --system --gid 10001 app && useradd --system --uid 10001 --gid app --home-dir /nonexistent --shell /usr/sbin/nologin app
#14 10.33 Collecting argon2-cffi==23.1.0 (from -r requirements.txt (line 16))
#14 10.45 Downloading argon2_cffi-23.1.0-py3-none-any.whl.metadata (5.2 kB)
#14 ...
#17 [s3-bootstrap internal] load build definition from s3.Dockerfile
#17 transferring dockerfile: 922B done
#17 DONE 0.0s
#14 [migrate 4/12] RUN pip install --no-cache-dir --requirement requirements.txt && groupadd --system --gid 10001 app && useradd --system --uid 10001 --gid app --home-dir /nonexistent --shell /usr/sbin/nologin app
#14 11.05 Collecting boto3==1.40.18 (from -r requirements.txt (line 17))
#14 11.19 Downloading boto3-1.40.18-py3-none-any.whl.metadata (6.7 kB)
#14 ...
#4 [s3-bootstrap] resolve image config for docker-image://docker.io/docker/dockerfile:1.7.0
#4 DONE 5.3s
#8 [s3-bootstrap] docker-image://docker.io/docker/dockerfile:1.7.0@sha256:dbbd5e059e8a07ff7ea6233b213b36aa516b4c53c645f1817a4dd18b83cbea56
#8 CACHED
#3 [s3-bootstrap internal] load metadata for docker.io/library/python:3.12.10-slim-bookworm
#3 DONE 5.3s
#14 [migrate 4/12] RUN pip install --no-cache-dir --requirement requirements.txt && groupadd --system --gid 10001 app && useradd --system --uid 10001 --gid app --home-dir /nonexistent --shell /usr/sbin/nologin app
#14 11.63 Collecting Pillow==12.0.0 (from -r requirements.txt (line 18))
#14 11.70 Downloading pillow-12.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.metadata (8.8 kB)
#14 ...
#6 [s3-bootstrap 1/12] FROM docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db
#6 resolve docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db 0.0s done
#6 sha256:be1274d3cce09d8126f8176203ba1e91f6733a713c1185ba01ee704759b0b62d 3.51MB / 3.51MB 1.2s done
#6 sha256:8991c9200d621283b06ae395129d454c998e0f55095e106055240b5956ab2a2a 13.66MB / 13.66MB 1.7s done
#6 sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db 9.13kB / 9.13kB done
#6 sha256:97983fa8cc88343512862c62307159a82261c3528dc025f79e5a3f7af43e50b4 1.75kB / 1.75kB done
#6 sha256:acf8897bf01a3a0ea273a50a58fc10b6317a3e360bd29aa7c9246a54d7c63e88 5.57kB / 5.57kB done
#6 extracting sha256:be1274d3cce09d8126f8176203ba1e91f6733a713c1185ba01ee704759b0b62d 0.4s done
#6 sha256:7a1cb8b882211b870d7e639e775f91e423a526092b4b3eadefbab6aa7457910d 249B / 249B 1.8s done
#6 extracting sha256:8991c9200d621283b06ae395129d454c998e0f55095e106055240b5956ab2a2a 1.0s done
#6 extracting sha256:7a1cb8b882211b870d7e639e775f91e423a526092b4b3eadefbab6aa7457910d done
#6 DONE 3.1s
#18 [s3-bootstrap internal] load .dockerignore
#18 transferring context: 206B done
#18 DONE 0.0s
#19 [s3-bootstrap internal] load build context
#19 transferring context: 72B done
#19 DONE 0.0s
#14 [migrate 4/12] RUN pip install --no-cache-dir --requirement requirements.txt && groupadd --system --gid 10001 app && useradd --system --uid 10001 --gid app --home-dir /nonexistent --shell /usr/sbin/nologin app
#14 12.02 Collecting argon2-cffi-bindings (from argon2-cffi==23.1.0->-r requirements.txt (line 16))
#14 12.09 Downloading argon2_cffi_bindings-26.1.0-cp310-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.metadata (7.5 kB)
#14 12.88 Collecting botocore<1.41.0,>=1.40.18 (from boto3==1.40.18->-r requirements.txt (line 17))
#14 12.96 Downloading botocore-1.40.76-py3-none-any.whl.metadata (5.9 kB)
#14 13.03 Collecting jmespath<2.0.0,>=0.7.1 (from boto3==1.40.18->-r requirements.txt (line 17))
#14 13.11 Downloading jmespath-1.1.0-py3-none-any.whl.metadata (7.6 kB)
#14 13.19 Collecting s3transfer<0.14.0,>=0.13.0 (from boto3==1.40.18->-r requirements.txt (line 17))
#14 13.26 Downloading s3transfer-0.13.1-py3-none-any.whl.metadata (1.7 kB)
#14 13.58 Collecting psycopg-binary==3.2.9 (from psycopg[binary]==3.2.9->-r requirements.txt (line 13))
#14 13.70 Downloading psycopg_binary-3.2.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.9 kB)
#14 14.44 Collecting python-dateutil<3.0.0,>=2.1 (from botocore<1.41.0,>=1.40.18->boto3==1.40.18->-r requirements.txt (line 17))
#14 14.51 Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl.metadata (8.4 kB)
#14 14.92 Collecting urllib3!=2.2.0,<3,>=1.25.4 (from botocore<1.41.0,>=1.40.18->boto3==1.40.18->-r requirements.txt (line 17))
#14 ...
#20 [s3-bootstrap 2/3] RUN python - <<'PY'
#20 DONE 3.2s
#14 [migrate 4/12] RUN pip install --no-cache-dir --requirement requirements.txt && groupadd --system --gid 10001 app && useradd --system --uid 10001 --gid app --home-dir /nonexistent --shell /usr/sbin/nologin app
#14 15.00 Downloading urllib3-2.8.0-py3-none-any.whl.metadata (7.4 kB)
#14 ...
#21 [s3-bootstrap 3/3] COPY infra/minio-entrypoint.sh /entrypoint.sh
#21 DONE 0.0s
#22 [s3-bootstrap] exporting to image
#22 exporting layers 0.1s done
#22 writing image sha256:fb106f2cfb8c434ddc7dd0f668013cf6421f7ec382eb71f151ccdd6b1b8ff2b4 done
#22 naming to docker.io/library/mtusi2026lab5-mc:2025-04-16 done
#22 DONE 0.2s
#14 [migrate 4/12] RUN pip install --no-cache-dir --requirement requirements.txt && groupadd --system --gid 10001 app && useradd --system --uid 10001 --gid app --home-dir /nonexistent --shell /usr/sbin/nologin app
#14 15.74 Collecting cffi>=1.0.1 (from argon2-cffi-bindings->argon2-cffi==23.1.0->-r requirements.txt (line 16))
#14 15.81 Downloading cffi-2.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.metadata (2.5 kB)
#14 15.91 Collecting pycparser (from cffi>=1.0.1->argon2-cffi-bindings->argon2-cffi==23.1.0->-r requirements.txt (line 16))
#14 15.98 Downloading pycparser-3.12-py3-none-any.whl.metadata (9.7 kB)
#14 16.07 Collecting six>=1.5 (from python-dateutil<3.0.0,>=2.1->botocore<1.41.0,>=1.40.18->boto3==1.40.18->-r requirements.txt (line 17))
#14 16.15 Downloading six-1.17.0-py2.py3-none-any.whl.metadata (1.7 kB)
#14 16.28 Downloading annotated_types-0.8.0-py3-none-any.whl (13 kB)
#14 16.36 Downloading anyio-4.15.1-py3-none-any.whl (132 kB)
#14 16.46 Downloading click-8.5.0-py3-none-any.whl (125 kB)
#14 16.54 Downloading fastapi-0.115.12-py3-none-any.whl (95 kB)
#14 16.63 Downloading h11-0.16.0-py3-none-any.whl (37 kB)
#14 16.71 Downloading idna-3.20-py3-none-any.whl (69 kB)
#14 16.79 Downloading pydantic-2.11.5-py3-none-any.whl (444 kB)
#14 16.90 Downloading pydantic_core-2.33.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB)
#14 16.99 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.0/2.0 MB 30.8 MB/s eta 0:00:00
#14 17.06 Downloading starlette-0.46.2-py3-none-any.whl (72 kB)
#14 17.13 Downloading typing_inspection-0.4.4-py3-none-any.whl (14 kB)
#14 17.21 Downloading typing_extensions-4.16.0-py3-none-any.whl (45 kB)
#14 17.29 Downloading uvicorn-0.34.2-py3-none-any.whl (62 kB)
#14 17.37 Downloading psycopg-3.2.9-py3-none-any.whl (202 kB)
#14 17.48 Downloading psycopg_pool-3.3.3-py3-none-any.whl (40 kB)
#14 17.55 Downloading redis-5.2.1-py3-none-any.whl (261 kB)
#14 17.82 Downloading argon2_cffi-23.1.0-py3-none-any.whl (15 kB)
#14 17.89 Downloading boto3-1.40.18-py3-none-any.whl (140 kB)
#14 17.98 Downloading pillow-12.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (7.0 MB)
#14 18.22 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.0/7.0 MB 30.7 MB/s eta 0:00:00
#14 18.29 Downloading psycopg_binary-3.2.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB)
#14 18.45 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.4/4.4 MB 29.6 MB/s eta 0:00:00
#14 18.52 Downloading botocore-1.40.76-py3-none-any.whl (14.2 MB)
#14 18.98 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.2/14.2 MB 33.2 MB/s eta 0:00:00
#14 19.05 Downloading jmespath-1.1.0-py3-none-any.whl (20 kB)
#14 19.13 Downloading s3transfer-0.13.1-py3-none-any.whl (85 kB)
#14 19.22 Downloading argon2_cffi_bindings-26.1.0-cp310-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (26 kB)
#14 19.30 Downloading cffi-2.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (221 kB)
#14 19.40 Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
#14 19.49 Downloading urllib3-2.8.0-py3-none-any.whl (135 kB)
#14 19.58 Downloading six-1.17.0-py2.py3-none-any.whl (11 kB)
#14 19.65 Downloading pycparser-3.12-py3-none-any.whl (62 kB)
#14 19.84 Installing collected packages: urllib3, typing_extensions, six, redis, pycparser, psycopg-binary, Pillow, jmespath, idna, h11, click, annotated-types, uvicorn, typing-inspection, python-dateutil, pydantic_core, psycopg-pool, psycopg, cffi, anyio, starlette, pydantic, botocore, argon2-cffi-bindings, s3transfer, fastapi, argon2-cffi, boto3
#14 24.24 Successfully installed Pillow-12.0.0 annotated-types-0.8.0 anyio-4.15.1 argon2-cffi-23.1.0 argon2-cffi-bindings-26.1.0 boto3-1.40.18 botocore-1.40.76 cffi-2.1.1 click-8.5.0 fastapi-0.115.12 h11-0.16.0 idna-3.20 jmespath-1.1.0 psycopg-3.2.9 psycopg-binary-3.2.9 psycopg-pool-3.3.3 pycparser-3.12 pydantic-2.11.5 pydantic_core-2.33.2 python-dateutil-2.9.0.post0 redis-5.2.1 s3transfer-0.13.1 six-1.17.0 starlette-0.46.2 typing-inspection-0.4.4 typing_extensions-4.16.0 urllib3-2.8.0 uvicorn-0.34.2
#14 24.25 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
#14 24.83
#14 24.83 [notice] A new release of pip is available: 25.0.1 -> 26.2.2
#14 24.83 [notice] To update, run: pip install --upgrade pip
#14 25.27 useradd warning: app's uid 10001 is greater than SYS_UID_MAX 999
#14 DONE 25.6s
#23 [migrate 5/12] COPY --chown=app:app src ./src
#23 DONE 0.1s
#24 [migrate 6/12] COPY --chown=app:app migrations ./migrations
#24 DONE 0.1s
#25 [migrate 7/12] COPY --chown=app:app scripts ./scripts
#25 DONE 0.1s
#26 [migrate 8/12] COPY --chown=app:app student-tests ./student-tests
#26 DONE 0.1s
#27 [migrate 9/12] COPY --chown=app:app tests ./tests
#27 DONE 0.1s
#28 [migrate 10/12] COPY --chown=app:app contracts ./contracts
#28 DONE 0.1s
#29 [migrate 11/12] COPY --chown=app:app lab.json ./lab.json
#29 DONE 0.1s
#30 [migrate 12/12] RUN mkdir -p evidence && chown app:app evidence
#30 DONE 0.4s
#31 [migrate] exporting to image
#31 exporting layers
#31 exporting layers 0.8s done
#31 writing image sha256:d4d240b899fecf1f585ce789cdead97f4fb5a7e6a8ded25dacd68b99673631c8 done
#31 naming to docker.io/library/mtusi2026lab5-app:1 0.0s done
#31 DONE 0.9s
#32 [api internal] load build definition from Dockerfile
#32 transferring dockerfile: 1.04kB done
#32 DONE 0.0s
#33 [worker internal] load build definition from Dockerfile
#33 transferring dockerfile: 1.04kB done
#33 DONE 0.0s
#34 [reconciler internal] load build definition from Dockerfile
#34 transferring dockerfile: 1.04kB done
#34 DONE 0.0s
#35 [dispatcher internal] load build definition from Dockerfile
#35 transferring dockerfile: 1.04kB done
#35 DONE 0.0s
#3 [dispatcher internal] load metadata for docker.io/library/python:3.12.10-slim-bookworm
#3 DONE 5.8s
#36 [dispatcher internal] load .dockerignore
#36 transferring context: 206B done
#36 DONE 0.0s
#37 [api internal] load .dockerignore
#37 transferring context: 206B done
#37 DONE 0.0s
#6 [dispatcher 1/12] FROM docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db
#6 DONE 3.1s
#38 [dispatcher internal] load build context
#38 transferring context: 450.17kB 0.0s done
#38 DONE 0.1s
#6 [reconciler 1/12] FROM docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db
#6 DONE 3.1s
#39 [worker internal] load .dockerignore
#39 transferring context: 206B done
#39 DONE 0.1s
#40 [reconciler internal] load .dockerignore
#40 transferring context: 206B done
#40 DONE 0.1s
#41 [api internal] load build context
#41 transferring context: 2.56kB done
#41 DONE 0.1s
#42 [api 3/12] COPY requirements.txt .
#42 CACHED
#43 [api 5/12] COPY --chown=app:app src ./src
#43 CACHED
#44 [api 6/12] COPY --chown=app:app migrations ./migrations
#44 CACHED
#45 [api 7/12] COPY --chown=app:app scripts ./scripts
#45 CACHED
#12 [api 2/12] WORKDIR /app
#12 CACHED
#46 [api 9/12] COPY --chown=app:app tests ./tests
#46 CACHED
#47 [api 8/12] COPY --chown=app:app student-tests ./student-tests
#47 CACHED
#48 [api 4/12] RUN pip install --no-cache-dir --requirement requirements.txt && groupadd --system --gid 10001 app && useradd --system --uid 10001 --gid app --home-dir /nonexistent --shell /usr/sbin/nologin app
#48 CACHED
#49 [api 11/12] COPY --chown=app:app lab.json ./lab.json
#49 CACHED
#50 [api 10/12] COPY --chown=app:app contracts ./contracts
#50 CACHED
#51 [dispatcher 12/12] RUN mkdir -p evidence && chown app:app evidence
#51 CACHED
#52 [worker internal] load build context
#52 transferring context: 450.17kB 0.0s done
#52 DONE 0.1s
#53 [reconciler internal] load build context
#53 transferring context: 450.17kB 0.0s done
#53 DONE 0.1s
#54 [dispatcher] exporting to image
#54 exporting layers done
#54 writing image sha256:8fa38e90348237d1270d416add296597851602705c0dd9131fe6985cb6d32355 done
#54 naming to docker.io/library/mtusi2026lab5-app:1 0.0s done
#54 DONE 0.1s
#51 [worker 12/12] RUN mkdir -p evidence && chown app:app evidence
#51 CACHED
#55 [api] exporting to image
#55 exporting layers done
#55 writing image sha256:f2874ab605053a9472f855c42418f0bce879324625d189413e4b1663f644d077 done
#55 naming to docker.io/library/mtusi2026lab5-app:1 0.0s done
#55 DONE 0.1s
#56 [reconciler] exporting to image
#56 exporting layers done
#56 writing image sha256:43b0177bf9d4adfbe14dd5e03bdf2deb916755ccf7f12e7a03697bc53c381ff8 done
#56 naming to docker.io/library/mtusi2026lab5-app:1 0.0s done
#56 DONE 0.1s
#57 [worker] exporting to image
#57 exporting layers done
#57 writing image sha256:4a85fcc4882db2f88339832df15fb6c6806da842209445bdcfc56500a1d32c0b done
#57 naming to docker.io/library/mtusi2026lab5-app:1 0.0s done
#57 DONE 0.1s
Network mtusi2026lab5_default Creating
Network mtusi2026lab5_default Created
Volume "mtusi2026lab5_s3_data" Creating
Volume "mtusi2026lab5_s3_data" Created
Volume "mtusi2026lab5_postgres_data" Creating
Volume "mtusi2026lab5_postgres_data" Created
Volume "mtusi2026lab5_redis_data" Creating
Volume "mtusi2026lab5_redis_data" Created
Volume "mtusi2026lab5_broker_data" Creating
Volume "mtusi2026lab5_broker_data" Created
Container mtusi2026lab5-s3-1 Creating
Container mtusi2026lab5-cache-1 Creating
Container mtusi2026lab5-db-1 Creating
Container mtusi2026lab5-broker-1 Creating
Container mtusi2026lab5-s3-1 Created
Container mtusi2026lab5-s3-bootstrap-1 Creating
Container mtusi2026lab5-cache-1 Created
Container mtusi2026lab5-broker-1 Created
Container mtusi2026lab5-db-1 Created
Container mtusi2026lab5-migrate-1 Creating
Container mtusi2026lab5-s3-bootstrap-1 Created
Container mtusi2026lab5-migrate-1 Created
Container mtusi2026lab5-api-2 Creating
Container mtusi2026lab5-dispatcher-1 Creating
Container mtusi2026lab5-reconciler-1 Creating
Container mtusi2026lab5-api-1 Creating
Container mtusi2026lab5-worker-1 Creating
Container mtusi2026lab5-dispatcher-1 Created
Container mtusi2026lab5-api-2 Created
Container mtusi2026lab5-api-1 Created
Container mtusi2026lab5-lb-1 Creating
Container mtusi2026lab5-worker-1 Created
Container mtusi2026lab5-reconciler-1 Created
Container mtusi2026lab5-lb-1 Created
Container mtusi2026lab5-broker-1 Starting
Container mtusi2026lab5-s3-1 Starting
Container mtusi2026lab5-cache-1 Starting
Container mtusi2026lab5-db-1 Starting
Container mtusi2026lab5-db-1 Started
Container mtusi2026lab5-db-1 Waiting
Container mtusi2026lab5-cache-1 Started
Container mtusi2026lab5-broker-1 Started
Container mtusi2026lab5-s3-1 Started
Container mtusi2026lab5-s3-1 Waiting
Container mtusi2026lab5-db-1 Healthy
Container mtusi2026lab5-migrate-1 Starting
Container mtusi2026lab5-s3-1 Healthy
Container mtusi2026lab5-s3-bootstrap-1 Starting
Container mtusi2026lab5-migrate-1 Started
Container mtusi2026lab5-s3-bootstrap-1 Started
Container mtusi2026lab5-migrate-1 Waiting
Container mtusi2026lab5-s3-bootstrap-1 Waiting
Container mtusi2026lab5-broker-1 Waiting
Container mtusi2026lab5-migrate-1 Waiting
Container mtusi2026lab5-migrate-1 Waiting
Container mtusi2026lab5-s3-bootstrap-1 Waiting
Container mtusi2026lab5-s3-bootstrap-1 Waiting
Container mtusi2026lab5-broker-1 Waiting
Container mtusi2026lab5-migrate-1 Waiting
Container mtusi2026lab5-cache-1 Waiting
Container mtusi2026lab5-s3-bootstrap-1 Waiting
Container mtusi2026lab5-cache-1 Healthy
Container mtusi2026lab5-broker-1 Healthy
Container mtusi2026lab5-broker-1 Healthy
Container mtusi2026lab5-migrate-1 Exited
Container mtusi2026lab5-migrate-1 Exited
Container mtusi2026lab5-migrate-1 Exited
Container mtusi2026lab5-migrate-1 Exited
Container mtusi2026lab5-s3-bootstrap-1 Exited
Container mtusi2026lab5-api-1 Starting
Container mtusi2026lab5-s3-bootstrap-1 Exited
Container mtusi2026lab5-worker-1 Starting
Container mtusi2026lab5-s3-bootstrap-1 Exited
Container mtusi2026lab5-dispatcher-1 Starting
Container mtusi2026lab5-s3-bootstrap-1 Exited
Container mtusi2026lab5-reconciler-1 Starting
Container mtusi2026lab5-api-1 Started
Container mtusi2026lab5-api-2 Starting
Container mtusi2026lab5-reconciler-1 Started
Container mtusi2026lab5-worker-1 Started
Container mtusi2026lab5-dispatcher-1 Started
Container mtusi2026lab5-api-2 Started
Container mtusi2026lab5-api-1 Waiting
Container mtusi2026lab5-api-2 Waiting
Container mtusi2026lab5-api-1 Healthy
Container mtusi2026lab5-api-2 Healthy
Container mtusi2026lab5-lb-1 Starting
Container mtusi2026lab5-lb-1 Started
API ready: c754d451d054:f8ee8f14, ca5bb0478ca7:e2d9a089
+10
View File
@@ -0,0 +1,10 @@
python3 student-tests/test_api.py --base-url "http://localhost:8080"
PASS: malformed JSON/media type, duplicate username, blank message, outsider access, pagination
PASS: 10 clients created exactly 100 unique messages
python3 student-tests/checks.py --base-url "http://localhost:8080"
PASS: registration race, invalid input, cursor scope/types on two API, read-after-write, logout
python3 student-tests/idempotency.py --base-url "http://localhost:8080"
PASS: shared idempotency, scope, conflict and auth on replay
docker exec "$(docker compose ps --status running -q api | head -n 1)" python student-tests/database.py
PASS: rollback of chat + members; migration reapplied twice
PASS: persisted key expiry, atomic message/result rollback
+2
View File
@@ -0,0 +1,2 @@
python3 scripts/validate_openapi.py
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
+37
View File
@@ -0,0 +1,37 @@
{
"status": "PASS",
"services": [
{
"service": "db",
"id_before": "a8efd18d965de2c9a1c93cf00e9230cb17f6b769af6446228ded6d262c12f650",
"id_after": "a8efd18d965de2c9a1c93cf00e9230cb17f6b769af6446228ded6d262c12f650",
"started_before": "2026-10-26T13:18:36.751584245Z",
"started_after": "2026-10-26T13:19:58.562034277Z",
"running_after": true
},
{
"service": "cache",
"id_before": "664d5065e4e2057903eaf1e47fe90f099597e81d28324c54f81141d3255a6f63",
"id_after": "664d5065e4e2057903eaf1e47fe90f099597e81d28324c54f81141d3255a6f63",
"started_before": "2026-10-26T13:18:36.846503039Z",
"started_after": "2026-10-26T13:19:58.561302804Z",
"running_after": true
},
{
"service": "s3",
"id_before": "5bd819ea48506fa8a38869e22ddc3607f8f9aeb23348b4b46aa594acdd61466a",
"id_after": "5bd819ea48506fa8a38869e22ddc3607f8f9aeb23348b4b46aa594acdd61466a",
"started_before": "2026-10-26T13:18:36.673896353Z",
"started_after": "2026-10-26T13:19:58.541630268Z",
"running_after": true
},
{
"service": "broker",
"id_before": "926c8de7fdfd9772c439414fc2e468cc0c23c641b68a83b84e4d8cb4e4998548",
"id_after": "926c8de7fdfd9772c439414fc2e468cc0c23c641b68a83b84e4d8cb4e4998548",
"started_before": "2026-10-26T13:18:36.75300028Z",
"started_after": "2026-10-26T13:19:58.542392464Z",
"running_after": true
}
]
}
+183
View File
@@ -0,0 +1,183 @@
{
"docker": "26.1.1",
"compose": "2.27.0-desktop.2",
"containers": [
{
"id": "10ea4363b2a5f35e57da2eadac37541d1fb79292374a094a91916dc915812413",
"name": "mtusi2026lab5-api-1",
"hostname": "10ea4363b2a5",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:21:35.945103161Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "f0e7bd13e2a91cd0f56b2b81ec96311b7a062799bde37df093e6262530b8233e",
"name": "mtusi2026lab5-api-2",
"hostname": "f0e7bd13e2a9",
"service": "api",
"running": true,
"started_at": "2026-10-26T13:21:35.516908782Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "926c8de7fdfd9772c439414fc2e468cc0c23c641b68a83b84e4d8cb4e4998548",
"name": "mtusi2026lab5-broker-1",
"hostname": "926c8de7fdfd",
"service": "broker",
"running": true,
"started_at": "2026-10-26T13:19:58.542392464Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "664d5065e4e2057903eaf1e47fe90f099597e81d28324c54f81141d3255a6f63",
"name": "mtusi2026lab5-cache-1",
"hostname": "664d5065e4e2",
"service": "cache",
"running": true,
"started_at": "2026-10-26T13:21:15.687084123Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"6379/tcp": null
}
},
{
"id": "a8efd18d965de2c9a1c93cf00e9230cb17f6b769af6446228ded6d262c12f650",
"name": "mtusi2026lab5-db-1",
"hostname": "a8efd18d965d",
"service": "db",
"running": true,
"started_at": "2026-10-26T13:21:23.472099949Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {
"5432/tcp": null
}
},
{
"id": "006c11ae2e2c025877906965f955d50a070e03dcefdf10251219d986aa951287",
"name": "mtusi2026lab5-dispatcher-1",
"hostname": "006c11ae2e2c",
"service": "dispatcher",
"running": true,
"started_at": "2026-10-26T13:20:11.830304855Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "17d5d00bd730356064b7324bfb190a5726be5dde524938e43a0e95fda8a097d2",
"name": "mtusi2026lab5-lb-1",
"hostname": "17d5d00bd730",
"service": "lb",
"running": true,
"started_at": "2026-10-26T13:20:11.844174641Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {
"8080/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "8080"
}
]
}
},
{
"id": "85c2bb372517d143c1bc4f0d62f919c03fcd0b2922f6d80527b5dd967afc87a2",
"name": "mtusi2026lab5-migrate-1",
"hostname": "85c2bb372517",
"service": "migrate",
"running": false,
"started_at": "2026-10-26T13:21:01.323626814Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "a62f7b1a9e058209c3e1c8e99fc418406270224effc82faa4bf1587d1250c18a",
"name": "mtusi2026lab5-reconciler-1",
"hostname": "a62f7b1a9e05",
"service": "reconciler",
"running": true,
"started_at": "2026-10-26T13:20:11.405575488Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 268435456,
"published_ports": {
"8080/tcp": null
}
},
{
"id": "5bd819ea48506fa8a38869e22ddc3607f8f9aeb23348b4b46aa594acdd61466a",
"name": "mtusi2026lab5-s3-1",
"hostname": "5bd819ea4850",
"service": "s3",
"running": true,
"started_at": "2026-10-26T13:19:58.541630268Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 536870912,
"published_ports": {}
},
{
"id": "9a802ad7d2417be1c16ff80944bc599eeb8ad9bcd0c91ab7c0dbfa761154b22c",
"name": "mtusi2026lab5-s3-bootstrap-1",
"hostname": "9a802ad7d241",
"service": "s3-bootstrap",
"running": false,
"started_at": "2026-10-26T13:21:01.324968308Z",
"restart_count": 0,
"cpu_limit": 0.5,
"memory_limit_bytes": 134217728,
"published_ports": {}
},
{
"id": "8f8673d67ca93d49031a9e5f55cd6fbf532142965a466de61353b15112472775",
"name": "mtusi2026lab5-worker-1",
"hostname": "8f8673d67ca9",
"service": "worker",
"running": true,
"started_at": "2026-10-26T13:20:11.799525654Z",
"restart_count": 0,
"cpu_limit": 1.0,
"memory_limit_bytes": 805306368,
"published_ports": {
"8080/tcp": null
}
}
],
"client_cpus": 16,
"pipeline": {
"job_max_attempts": 5,
"job_timeout_seconds": 30,
"job_lease_seconds": 15,
"staging_retention_seconds": 86400,
"max_pending_jobs": 1000,
"worker_concurrency": 1,
"prefetch_per_consumer": 1
}
}
File diff suppressed because it is too large Load Diff
+94
View File
@@ -0,0 +1,94 @@
{
"status": "PASS",
"track": 2,
"cases": [
{
"case": "accepted_restart_broker_api",
"repetitions": 3,
"status": "PASS",
"median_seconds": 62.692
},
{
"case": "before_publish",
"repetitions": 3,
"status": "PASS",
"median_seconds": 45.89
},
{
"case": "after_publish",
"repetitions": 3,
"status": "PASS",
"median_seconds": 44.544
},
{
"case": "before_effect",
"repetitions": 3,
"status": "PASS",
"median_seconds": 45.35
},
{
"case": "after_original",
"repetitions": 3,
"status": "PASS",
"median_seconds": 43.115
},
{
"case": "after_effects",
"repetitions": 3,
"status": "PASS",
"median_seconds": 46.272
},
{
"case": "after_commit",
"repetitions": 3,
"status": "PASS",
"median_seconds": 36.306
},
{
"case": "duplicates_and_invalid_carrier",
"repetitions": 3,
"status": "PASS",
"median_seconds": 36.795
},
{
"case": "reorder_new_before_old",
"repetitions": 3,
"status": "PASS",
"median_seconds": 57.728
},
{
"case": "stale_after_new_ready",
"repetitions": 3,
"status": "PASS",
"median_seconds": 54.823
},
{
"case": "permanent_failure_replay",
"repetitions": 3,
"status": "PASS",
"median_seconds": 56.23
},
{
"case": "bounded_retry_and_replay",
"repetitions": 3,
"status": "PASS",
"median_seconds": 75.655
},
{
"case": "staging_retention_and_privacy",
"repetitions": 3,
"status": "PASS",
"median_seconds": 37.404
}
],
"checks": 39,
"invariants": [
"accepted work preserved",
"one ready commit per job",
"exactly three named variants",
"original checksum preserved",
"stale version cannot replace current metadata/bytes",
"bounded retries and explicit replay",
"staging cleanup protects active jobs"
]
}
+145
View File
@@ -0,0 +1,145 @@
{
"db": "postgres (PostgreSQL) 16.9 (Debian 16.9-1.pgdg120+1)",
"cache": "Redis server v=7.4.3 sha=00000000:0 malloc=jemalloc-5.3.0 bits=64 build=33b32145ce3464c9",
"broker": "Redis server v=7.4.3 sha=00000000:0 malloc=jemalloc-5.3.0 bits=64 build=33b32145ce3464c9",
"s3": "minio version RELEASE.2025-04-22T22-12-26Z (commit-id=0d7408fc9969caf07de6a8c3a84f9fbb10a6739e)\nRuntime: go1.24.2 linux/amd64\nLicense: GNU AGPLv3 - https://www.gnu.org/licenses/agpl-3.0.html\nCopyright: 2015-2025 MinIO, Inc.",
"api": "Python 3.12.10",
"lb": "HAProxy version 3.0.11-9e587df 2025/06/02 - https://haproxy.org/\nStatus: long-term supported branch - will stop receiving fixes around Q2 2029.\nKnown bugs: http://www.haproxy.org/bugs/bugs-3.0.11.html\nRunning on: Linux 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64",
"application_dependencies": [
"annotated-types==0.8.0",
"anyio==4.15.1",
"argon2-cffi==23.1.0",
"argon2-cffi-bindings==26.1.0",
"boto3==1.40.18",
"botocore==1.40.76",
"cffi==2.1.1",
"click==8.5.0",
"fastapi==0.115.12",
"h11==0.16.0",
"idna==3.20",
"jmespath==1.1.0",
"pillow==12.0.0",
"psycopg==3.2.9",
"psycopg-binary==3.2.9",
"psycopg-pool==3.3.3",
"pycparser==3.12",
"pydantic==2.11.5",
"pydantic_core==2.33.2",
"python-dateutil==2.9.0.post0",
"redis==5.2.1",
"s3transfer==0.13.1",
"six==1.17.0",
"starlette==0.46.2",
"typing-inspection==0.4.4",
"typing_extensions==4.16.0",
"urllib3==2.8.0",
"uvicorn==0.34.2"
],
"images_mounts": [
{
"service": "api",
"image": "mtusi2026lab5-app:1",
"image_id": "sha256:4a85fcc4882db2f88339832df15fb6c6806da842209445bdcfc56500a1d32c0b",
"mounts": []
},
{
"service": "api",
"image": "mtusi2026lab5-app:1",
"image_id": "sha256:4a85fcc4882db2f88339832df15fb6c6806da842209445bdcfc56500a1d32c0b",
"mounts": []
},
{
"service": "broker",
"image": "redis:7.4.3-bookworm",
"image_id": "sha256:ce466e2d8c6f3332d781ad10c4cb3e0b97df2b0c5c2be2e930e8367c4e3b3fba",
"mounts": [
{
"type": "volume",
"name": "mtusi2026lab5_broker_data",
"destination": "/data",
"rw": true
}
]
},
{
"service": "cache",
"image": "redis:7.4.3-bookworm",
"image_id": "sha256:ce466e2d8c6f3332d781ad10c4cb3e0b97df2b0c5c2be2e930e8367c4e3b3fba",
"mounts": [
{
"type": "volume",
"name": "mtusi2026lab5_redis_data",
"destination": "/data",
"rw": true
}
]
},
{
"service": "db",
"image": "postgres:16.9-bookworm",
"image_id": "sha256:00d06ace1e0b51d5ef8170bbc38557092c83253c9f21ad68a85a49d46c825ce0",
"mounts": [
{
"type": "volume",
"name": "mtusi2026lab5_postgres_data",
"destination": "/var/lib/postgresql/data",
"rw": true
}
]
},
{
"service": "dispatcher",
"image": "mtusi2026lab5-app:1",
"image_id": "sha256:4a85fcc4882db2f88339832df15fb6c6806da842209445bdcfc56500a1d32c0b",
"mounts": []
},
{
"service": "lb",
"image": "haproxy:3.0.11-bookworm",
"image_id": "sha256:1b8bb9f4c3dde476fb1cfd2875ff1fa694d6224c4b7e4adbdba7de5a79d80b23",
"mounts": []
},
{
"service": "migrate",
"image": "mtusi2026lab5-app:1",
"image_id": "sha256:4a85fcc4882db2f88339832df15fb6c6806da842209445bdcfc56500a1d32c0b",
"mounts": []
},
{
"service": "reconciler",
"image": "mtusi2026lab5-app:1",
"image_id": "sha256:4a85fcc4882db2f88339832df15fb6c6806da842209445bdcfc56500a1d32c0b",
"mounts": []
},
{
"service": "s3",
"image": "mtusi2026lab5-minio:2025-04-22",
"image_id": "sha256:5816bd699104d2cd34fc3b5540a48972cb088ef213383ef48b523882868d907f",
"mounts": [
{
"type": "volume",
"name": "mtusi2026lab5_s3_data",
"destination": "/data",
"rw": true
}
]
},
{
"service": "s3-bootstrap",
"image": "mtusi2026lab5-mc:2025-04-16",
"image_id": "sha256:fb106f2cfb8c434ddc7dd0f668013cf6421f7ec382eb71f151ccdd6b1b8ff2b4",
"mounts": []
},
{
"service": "worker",
"image": "mtusi2026lab5-app:1",
"image_id": "sha256:4a85fcc4882db2f88339832df15fb6c6806da842209445bdcfc56500a1d32c0b",
"mounts": []
}
],
"fault_flags": {
"dispatcher": "0",
"reconciler": "0",
"worker": "0"
}
}
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
set -eu
# Пароль не передаётся аргументом процесса и не печатается в лог.
# Root-owned directory avoids sticky /tmp protected_regular on container restart.
mkdir -p /run/broker
chmod 755 /run/broker
{
echo 'dir /data'
echo 'appendonly yes'
echo 'appendfsync always'
echo 'save ""'
echo 'maxmemory 192mb'
echo 'maxmemory-policy noeviction'
printf 'requirepass %s\n' "$(cat /run/secrets/broker_password)"
} > /run/broker/broker.conf
chmod 600 /run/broker/broker.conf
chown redis:redis /run/broker/broker.conf
exec /usr/local/bin/docker-entrypoint.sh redis-server /run/broker/broker.conf
+37
View File
@@ -0,0 +1,37 @@
global
log stdout format raw local0
maxconn 2048
defaults
mode http
log global
option httplog
timeout connect 500ms
timeout client 30s
timeout server 50s
timeout check 1s
retries 0
resolvers docker
nameserver dns 127.0.0.11:53
resolve_retries 1
timeout resolve 1s
timeout retry 1s
hold valid 1s
hold nx 1s
hold other 1s
hold refused 1s
hold timeout 1s
hold obsolete 1s
frontend public
bind :8080
http-request deny if { path_beg /internal/ }
default_backend messenger
backend messenger
balance roundrobin
option httpchk GET /health/ready
http-check expect status 200
default-server inter 1s fastinter 500ms downinter 1s fall 2 rise 1
server-template api 1-4 api:8080 check resolvers docker init-addr none resolve-prefer ipv4
+5
View File
@@ -0,0 +1,5 @@
#!/bin/sh
set -eu
export MINIO_ROOT_USER="$(cat /run/secrets/s3_root_user)"
export MINIO_ROOT_PASSWORD="$(cat /run/secrets/s3_root_password)"
exec minio "$@"
+45
View File
@@ -0,0 +1,45 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation"
],
"Resource": [
"arn:aws:s3:::messenger-attachments"
]
},
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::messenger-attachments"
],
"Condition": {
"StringLike": {
"s3:prefix": [
"originals/*",
"staging/*",
"variants/*"
]
}
}
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::messenger-attachments/originals/*",
"arn:aws:s3:::messenger-attachments/staging/*",
"arn:aws:s3:::messenger-attachments/variants/*"
]
}
]
}
+27
View File
@@ -0,0 +1,27 @@
# syntax=docker/dockerfile:1.7.0
FROM python:3.12.10-slim-bookworm
ARG COMPONENT
ARG RELEASE
ARG SHA256
RUN python - <<'PY'
import hashlib
import os
from pathlib import Path
import shutil
import urllib.request
component = os.environ['COMPONENT']
release = os.environ['RELEASE']
assert component in {'minio', 'mc'}
name = f'{component}.linux-amd64.{release}'
url = f'https://github.com/minio/{component}/releases/download/{release}/{name}'
target = Path('/usr/local/bin') / component
with urllib.request.urlopen(url, timeout=180) as response, target.open('wb') as file:
shutil.copyfileobj(response, file)
with target.open('rb') as file:
digest = hashlib.file_digest(file, 'sha256').hexdigest()
assert digest == os.environ['SHA256'], 'Unexpected binary checksum'
target.chmod(0o755)
PY
COPY infra/minio-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
+36
View File
@@ -0,0 +1,36 @@
-- Сначала схема и ограничения, затем запросы приложения.
CREATE TABLE users (
id uuid PRIMARY KEY,
username varchar(32) NOT NULL UNIQUE CHECK (username ~ '^[a-z0-9_]{3,32}$'),
display_name varchar(100) NOT NULL CHECK (length(btrim(display_name)) > 0),
password_hash text NOT NULL,
created_at timestamptz NOT NULL DEFAULT clock_timestamp()
);
CREATE TABLE chats (
id uuid PRIMARY KEY,
title varchar(100) NOT NULL CHECK (length(btrim(title)) > 0),
created_at timestamptz NOT NULL DEFAULT clock_timestamp()
);
CREATE TABLE chat_members (
chat_id uuid NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
user_id uuid NOT NULL REFERENCES users(id),
PRIMARY KEY (chat_id, user_id)
);
CREATE INDEX chat_members_user_idx ON chat_members(user_id, chat_id);
CREATE INDEX chats_order_idx ON chats(created_at, id);
CREATE TABLE messages (
id uuid PRIMARY KEY,
chat_id uuid NOT NULL REFERENCES chats(id),
sender_id uuid NOT NULL,
text varchar(4000) NOT NULL CHECK (length(btrim(text)) > 0),
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
FOREIGN KEY (chat_id, sender_id) REFERENCES chat_members(chat_id, user_id)
);
-- Equality по chat_id и range/order по двум полям курсора.
CREATE INDEX messages_history_idx ON messages(chat_id, created_at, id);
CREATE TABLE sessions (
token_hash char(64) PRIMARY KEY,
user_id uuid NOT NULL REFERENCES users(id),
expires_at timestamptz NOT NULL
);
CREATE INDEX sessions_expiry_idx ON sessions(expires_at);
+10
View File
@@ -0,0 +1,10 @@
CREATE TABLE message_requests (
user_id uuid NOT NULL REFERENCES users(id),
chat_id uuid NOT NULL REFERENCES chats(id),
request_key varchar(128) NOT NULL,
body_hash char(64) NOT NULL,
response jsonb NOT NULL,
expires_at timestamptz NOT NULL,
PRIMARY KEY (user_id, chat_id, request_key)
);
CREATE INDEX message_requests_expiry_idx ON message_requests(expires_at);
+41
View File
@@ -0,0 +1,41 @@
CREATE TABLE attachments (
id uuid PRIMARY KEY,
chat_id uuid NOT NULL REFERENCES chats(id),
owner_id uuid NOT NULL REFERENCES users(id),
filename varchar(255) NOT NULL,
content_type text NOT NULL CHECK (content_type IN ('image/png', 'image/jpeg')),
size_bytes integer NOT NULL CHECK (size_bytes BETWEEN 1 AND 10485760),
sha256 char(64) NOT NULL,
object_key text NOT NULL UNIQUE,
status text NOT NULL CHECK (status IN ('uploading', 'ready', 'missing')),
lease_until timestamptz NOT NULL,
error_code text,
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
updated_at timestamptz NOT NULL DEFAULT clock_timestamp()
);
CREATE INDEX attachments_chat_idx ON attachments(chat_id, created_at, id);
CREATE TABLE message_attachments (
message_id uuid NOT NULL REFERENCES messages(id) ON DELETE CASCADE,
attachment_id uuid NOT NULL REFERENCES attachments(id),
position smallint NOT NULL CHECK (position BETWEEN 0 AND 9),
PRIMARY KEY (message_id, position),
UNIQUE (message_id, attachment_id)
);
ALTER TABLE messages DROP CONSTRAINT messages_text_check;
CREATE FUNCTION check_message_content() RETURNS trigger LANGUAGE plpgsql AS $$
BEGIN
IF length(btrim(NEW.text))=0 AND NOT EXISTS (
SELECT 1 FROM message_attachments WHERE message_id=NEW.id
) THEN
RAISE EXCEPTION 'message needs text or attachment' USING ERRCODE='23514';
END IF;
RETURN NEW;
END;
$$;
-- Проверяем в конце транзакции, когда связи вложений уже вставлены.
CREATE CONSTRAINT TRIGGER message_content
AFTER INSERT OR UPDATE ON messages DEFERRABLE INITIALLY DEFERRED
FOR EACH ROW EXECUTE FUNCTION check_message_content();
-- Прежние текстовые повторы остаются совместимыми с расширенной схемой Message.
UPDATE message_requests SET response=response || '{"attachment_ids": []}'::jsonb
WHERE NOT response ? 'attachment_ids';
+57
View File
@@ -0,0 +1,57 @@
ALTER TABLE attachments DROP CONSTRAINT attachments_status_check;
UPDATE attachments SET status='failed',error_code='legacy_incomplete' WHERE status IN ('uploading','missing');
ALTER TABLE attachments ADD CONSTRAINT attachments_status_check CHECK (status IN ('queued','processing','ready','failed'));
ALTER TABLE attachments ADD COLUMN pipeline_version integer NOT NULL DEFAULT 1 CHECK (pipeline_version>0);
ALTER TABLE attachments ADD COLUMN variants jsonb NOT NULL DEFAULT '[]';
ALTER TABLE attachments ADD COLUMN variant_keys jsonb NOT NULL DEFAULT '{}';
CREATE TABLE jobs (
id uuid PRIMARY KEY,
attachment_id uuid NOT NULL REFERENCES attachments(id),
pipeline_version integer NOT NULL CHECK (pipeline_version>0),
status text NOT NULL CHECK (status IN ('queued','processing','ready','failed','superseded')),
staging_key text NOT NULL UNIQUE,
attempts integer NOT NULL DEFAULT 0,
budget_start integer NOT NULL DEFAULT 0,
available_at timestamptz NOT NULL DEFAULT clock_timestamp(),
lease_until timestamptz,
lease_token uuid,
error_code text,
staged_deleted_at timestamptz,
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
updated_at timestamptz NOT NULL DEFAULT clock_timestamp(),
UNIQUE (attachment_id,pipeline_version)
);
ALTER TABLE attachments ADD COLUMN current_job_id uuid REFERENCES jobs(id);
CREATE INDEX jobs_schedule_idx ON jobs(status,available_at);
CREATE TABLE job_outbox (
id bigserial PRIMARY KEY,
job_id uuid NOT NULL REFERENCES jobs(id),
attempt integer NOT NULL CHECK (attempt>0),
published_at timestamptz,
stream_id text,
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
UNIQUE (job_id,attempt)
);
CREATE INDEX job_outbox_pending_idx ON job_outbox(id) WHERE published_at IS NULL;
CREATE TABLE job_events (
id bigserial PRIMARY KEY,
job_id uuid NOT NULL REFERENCES jobs(id),
event text NOT NULL,
details jsonb NOT NULL DEFAULT '{}',
created_at timestamptz NOT NULL DEFAULT clock_timestamp()
);
-- Точечные одноразовые сбои нужны для воспроизводимого эксперимента трека 2.
-- Исполнение разрешено только с ALLOW_FAULT_INJECTION=1; UUID конкретной job обязателен.
CREATE TABLE pipeline_faults (
job_id uuid NOT NULL REFERENCES jobs(id),
phase text NOT NULL,
fired_at timestamptz,
PRIMARY KEY (job_id,phase)
);
CREATE TABLE broker_rejections (
stream_id text PRIMARY KEY,
sha256 char(64) NOT NULL,
error_code text NOT NULL,
created_at timestamptz NOT NULL DEFAULT clock_timestamp()
);
+1
View File
@@ -0,0 +1 @@
Pillow==12.0.0
+18
View File
@@ -0,0 +1,18 @@
annotated-types==0.8.0
anyio==4.15.1
click==8.5.0
fastapi==0.115.12
h11==0.16.0
idna==3.20
pydantic==2.11.5
pydantic_core==2.33.2
starlette==0.46.2
typing-inspection==0.4.4
typing_extensions==4.16.0
uvicorn==0.34.2
psycopg[binary]==3.2.9
psycopg-pool==3.3.3
redis==5.2.1
argon2-cffi==23.1.0
boto3==1.40.18
Pillow==12.0.0
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
set -eu
endpoint="${S3_ENDPOINT:-http://s3:9000}"
bucket="messenger-attachments"
export MC_CONFIG_DIR=/tmp/mc-config
attempt=0
until mc alias set local "$endpoint" "$(cat /run/secrets/s3_root_user)" \
"$(cat /run/secrets/s3_root_password)" >/dev/null 2>&1; do
attempt=$((attempt + 1))
test "$attempt" -lt 60 || exit 1
sleep 1
done
mc mb --ignore-existing "local/$bucket" >/dev/null
mc anonymous set none "local/$bucket" >/dev/null
mc admin policy create local messenger-api /policies/s3-api-policy.json >/dev/null
mc admin user add local "$(cat /run/secrets/s3_access_key_id)" \
"$(cat /run/secrets/s3_secret_access_key)" >/dev/null
mc admin policy attach local messenger-api --user "$(cat /run/secrets/s3_access_key_id)" >/dev/null
echo 'Private bucket and limited API credentials ready'
+163
View File
@@ -0,0 +1,163 @@
"""Трек 2: повторяемые реальные crashes, дубли, reorder, версии и восстановление."""
import argparse
import json
import os
from pathlib import Path
import statistics
import sys
import time
ROOT=Path(__file__).resolve().parents[1]
sys.path.insert(0,str(ROOT))
from scripts.stack import command,containers,wait,save
class Runner:
def __init__(self):
self.env=dict(os.environ,ALLOW_FAULT_INJECTION='1',WORKER_CONCURRENCY='1')
self.base=os.getenv('BASE_URL','http://localhost:8080')
def call(self,mode,ctx=None,**options):
arguments=['docker','compose','run','--rm','--no-deps','-T','-e','BASE_URL=http://lb:8080',
'dispatcher','python','student-tests/pipeline_scenario.py',mode]
for key,value in options.items():arguments.extend(['--'+key.replace('_','-'),str(value)])
# Контекст с Bearer остаётся в памяти клиента и stdin, не в argv/evidence.
return json.loads(command(arguments,env=self.env,input=json.dumps(ctx or {}),timeout=150))
def service(self,action,name):
if action=='stop':command(['docker','compose','stop',name],env=self.env)
elif action=='restart':
command(['docker','compose','stop',name],env=self.env)
command(['docker','compose','up','-d','--no-deps','--wait',name],env=self.env)
else:
args=['docker','compose','up','-d','--no-deps']
if action=='recreate':args.append('--force-recreate')
command([*args,name],env=self.env)
if name in {'api','s3'} and action!='stop':wait(2,self.base)
def infrastructure(self):return containers()
def finish(self):
normal=dict(os.environ,ALLOW_FAULT_INJECTION='0')
command(['docker','compose','up','-d','--no-deps','--force-recreate','worker','dispatcher'],env=normal)
command(['docker','compose','up','-d','--no-deps','reconciler'],env=normal)
wait(2,self.base)
def same_effect(before,after):
assert before['attachment']==after['attachment'],'Duplicate altered public metadata'
assert before['current_keys']==after['current_keys'],'Duplicate multiplied variants'
assert before['variants_sha256']==after['variants_sha256'],'Duplicate changed bytes'
assert before['original_sha256']==after['original_sha256']
def run_suite(runner,repeats,on_result):
results=[]
def ready(ctx):
runner.call('wait',ctx)
return runner.call('snapshot',ctx)
def record(name,repeat,started,**values):
row=dict(case=name,repetition=repeat,status='PASS',elapsed_seconds=round(time.monotonic()-started,3),**values)
results.append(row);on_result(results)
print(f'PASS: {name}, repeat {repeat}/{repeats}',flush=True)
runner.service('stop','reconciler')
for repeat in range(1,repeats+1):
started=time.monotonic();runner.service('stop','worker');runner.service('start','dispatcher')
ctx=runner.call('create');queued=runner.call('queued',ctx)
published=runner.call('published',ctx)
runner.service('stop','dispatcher');runner.service('recreate','api');runner.service('restart','broker')
restored=runner.call('published',ctx);assert restored['stream_ids']==published['stream_ids']
runner.service('start','dispatcher');runner.service('recreate','worker')
record('accepted_restart_broker_api',repeat,started,queued=queued,broker_preserved=restored,result=ready(ctx),infrastructure=runner.infrastructure())
for phase in ['before_publish','after_publish']:
started=time.monotonic();runner.service('stop','worker');runner.service('stop','dispatcher')
ctx=runner.call('create');runner.call('arm',ctx,phase=phase)
runner.service('recreate','dispatcher');fired=runner.call('fault-fired',ctx,phase=phase)
runner.service('recreate','worker');result=ready(ctx)
record(phase,repeat,started,fault=fired,result=result,infrastructure=runner.infrastructure())
for phase in ['before_effect','after_original','after_effects','after_commit']:
started=time.monotonic();runner.service('stop','worker')
ctx=runner.call('create');runner.call('arm',ctx,phase=phase)
runner.service('recreate','worker');fired=runner.call('fault-fired',ctx,phase=phase)
result=ready(ctx)
if phase=='after_commit':assert result['attempts']==1,'Committed result was processed again'
else:assert result['attempts']>=2,'Abandoned lease was not recovered'
record(phase,repeat,started,fault=fired,result=result,infrastructure=runner.infrastructure())
started=time.monotonic();ctx=runner.call('create');before=ready(ctx)
copies=runner.call('duplicate',dict(ctx,copies=16))
acked=runner.call('drained',dict(ctx,stream_ids=copies['stream_ids']))
after=runner.call('snapshot',ctx);same_effect(before,after)
rejected=runner.call('invalid-job',ctx)
assert len([r for r in after['events'] if r['event']=='duplicate_ready'])>=16
record('duplicates_and_invalid_carrier',repeat,started,duplicates=acked,invalid_carrier=rejected,result=after)
# Новая job приходит первой, старая после неё: контролируемый reorder.
started=time.monotonic();runner.service('stop','worker');runner.service('stop','dispatcher')
old=runner.call('create');new=runner.call('version',old)
first=runner.call('duplicate',new);second=runner.call('duplicate',old)
runner.service('recreate','worker')
runner.call('drained',dict(new,stream_ids=first['stream_ids']+second['stream_ids']))
result=ready(new);old_audit=runner.call('audit',old)
assert any(r['event']=='stale_ignored' for r in old_audit['events'])
assert result['pipeline_version']==2
record('reorder_new_before_old',repeat,started,result=result,old_job=old_audit)
runner.service('start','dispatcher')
# Теперь старая версия уже имела ready; её поздний дубль не меняет v2.
started=time.monotonic();old=runner.call('create');v1=ready(old)
new=runner.call('version',old);before=ready(new)
assert before['variants_sha256']!=v1['variants_sha256'],'Pipeline version did not change actual output'
copies=runner.call('duplicate',dict(old,copies=3));runner.call('drained',dict(old,stream_ids=copies['stream_ids']))
after=runner.call('snapshot',new);same_effect(before,after)
record('stale_after_new_ready',repeat,started,result=after,old_job=runner.call('audit',old))
started=time.monotonic();runner.service('stop','worker');ctx=runner.call('create')
runner.call('missing-stage',ctx);runner.service('recreate','worker');runner.call('wait',ctx,state='failed')
failed=runner.call('failed',ctx);assert failed['error_code']=='staging_missing'
runner.call('restore-stage',ctx);runner.call('replay',ctx);result=ready(ctx)
noop=runner.call('replay',ctx);assert noop['status']=='noop'
record('permanent_failure_replay',repeat,started,failed=failed,ready_replay=noop,result=result)
# Физический stop S3, а не подмена ответа или бесконечная retry-петля.
started=time.monotonic();runner.service('stop','worker');ctx=runner.call('create')
runner.service('stop','s3')
try:
time.sleep(4);unready=runner.call('unready',ctx)
runner.service('recreate','worker');runner.call('wait',ctx,state='failed',timeout=120)
finally:runner.service('start','s3')
failed=runner.call('failed',ctx);assert failed['error_code']=='retry_exhausted'
assert failed['attempts']==5
runner.call('replay',ctx);result=ready(ctx)
record('bounded_retry_and_replay',repeat,started,unready=unready,failed=failed,result=result)
started=time.monotonic();runner.service('stop','worker');ctx=runner.call('create')
cleaned=runner.call('cleanup',ctx);runner.service('recreate','worker');result=ready(ctx)
privacy=runner.call('privacy',ctx)
record('staging_retention_and_privacy',repeat,started,cleanup=cleaned,privacy=privacy,result=result)
return results
def main():
p=argparse.ArgumentParser();p.add_argument('--repeats',type=int,default=3);args=p.parse_args()
if not 1<=args.repeats<=5:p.error('repeats must be 1..5')
runner=Runner()
save('pipeline_environment.json',dict(docker=command(['docker','version','--format','{{.Server.Version}}']),
compose=command(['docker','compose','version','--short']),containers=containers(),client_cpus=os.cpu_count(),
pipeline=runner.call('config')))
def persist(rows):save('pipeline_raw.json',dict(status='RUNNING',track=2,repeats=args.repeats,cases=rows))
persist([]);save('pipeline_summary.json',dict(status='RUNNING',expected_checks=13*args.repeats))
try:
try:rows=run_suite(runner,args.repeats,persist)
finally:runner.finish()
except Exception as exc:
save('pipeline_summary.json',dict(status='FAILED',reason=type(exc).__name__))
raise
save('pipeline_raw.json',dict(status='PASS',track=2,repeats=args.repeats,cases=rows))
summary=[]
for case in dict.fromkeys(r['case'] for r in rows):
subset=[r for r in rows if r['case']==case]
summary.append(dict(case=case,repetitions=len(subset),status='PASS',
median_seconds=statistics.median(r['elapsed_seconds'] for r in subset)))
save('pipeline_summary.json',dict(status='PASS',track=2,cases=summary,checks=len(rows),
invariants=['accepted work preserved','one ready commit per job','exactly three named variants',
'original checksum preserved','stale version cannot replace current metadata/bytes',
'bounded retries and explicit replay','staging cleanup protects active jobs']))
print('Experiment completed; results saved in evidence/',flush=True)
if __name__=='__main__':main()
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env python3
import json
import os
import urllib.request
host = "127.0.0.1"
port = os.getenv("APP_PORT", "8080")
with urllib.request.urlopen(f"http://{host}:{port}/health/ready", timeout=2) as response:
payload = json.load(response)
if response.status != 200 or payload != {"status": "ok"}:
raise SystemExit(1)
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
docker compose stop worker dispatcher reconciler lb api cache db s3 broker
docker compose up -d --wait db cache s3 broker
docker compose run --rm --no-deps migrate
docker compose run --rm --no-deps s3-bootstrap
docker compose up -d --no-deps --wait api
docker compose up -d --no-deps lb dispatcher worker reconciler
python3 scripts/stack.py wait --count 2
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
docker compose start api
python3 scripts/stack.py wait --count 2
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
mkdir -p .secrets
chmod 700 .secrets
python3 - <<'PY'
from pathlib import Path
import secrets
password_file = Path('.secrets/db_password')
if not password_file.exists():
password_file.write_text(secrets.token_hex(24))
password = password_file.read_text().strip()
Path('.secrets/database_url').write_text(f'postgresql://messenger:{password}@db:5432/messenger')
for name in ['s3_root_user', 's3_root_password', 's3_access_key_id', 's3_secret_access_key']:
file = Path('.secrets') / name
if not file.exists():
file.write_text(secrets.token_hex(16 if name.endswith(('user', 'id')) else 32))
broker_password=Path('.secrets/broker_password')
if not broker_password.exists(): broker_password.write_text(secrets.token_hex(24))
Path('.secrets/broker_url').write_text('redis://:'+broker_password.read_text().strip()+'@broker:6379/0')
for file in Path('.secrets').iterdir():
file.chmod(0o644 if file.name in {'database_url', 's3_access_key_id', 's3_secret_access_key', 'broker_url'} else 0o600)
if not Path('.env').exists():
Path('.env').write_text('APP_PORT=8080\nSESSION_TTL_SECONDS=3600\nDB_POOL_MAX=8\nAPI_CPU=1.0\nAPI_MEMORY=512m\nWORKER_CONCURRENCY=1\nJOB_MAX_ATTEMPTS=5\nJOB_TIMEOUT_SECONDS=30\nJOB_LEASE_SECONDS=15\nSTAGING_RETENTION_SECONDS=86400\nMAX_PENDING_JOBS=1000\nALLOW_FAULT_INJECTION=0\n')
print('Локальные настройки подготовлены; секреты не выводятся.')
PY
+129
View File
@@ -0,0 +1,129 @@
"""Небольшие операции со стендом: состояние, ожидание, масштабирование и замена."""
import argparse
import json
import os
from pathlib import Path
import subprocess
import time
import urllib.request
ROOT = Path(__file__).resolve().parents[1]
def command(args, env=None, timeout=120, input=None):
result = subprocess.run(args, cwd=ROOT, env=env, text=True, capture_output=True, timeout=timeout, input=input)
if result.returncode:
raise RuntimeError(result.stderr[-2000:])
return result.stdout.strip()
def containers(service=None):
args = ['docker', 'compose', 'ps', '-a', '-q']
if service:
args.append(service)
ids = command(args).split()
if not ids:
return []
# Сохраняем только нужные поля, без environment с возможными секретами.
rows = json.loads(command(['docker', 'inspect', *ids]))
return [dict(id=r['Id'], name=r['Name'].lstrip('/'), hostname=r['Config']['Hostname'],
service=r['Config']['Labels']['com.docker.compose.service'],
running=r['State']['Running'], started_at=r['State']['StartedAt'], restart_count=r.get('RestartCount',0),
cpu_limit=r['HostConfig']['NanoCpus'] / 1e9,
memory_limit_bytes=r['HostConfig']['Memory'],
published_ports=r['NetworkSettings']['Ports']) for r in rows]
def save(name, data):
path = ROOT / 'evidence' / name
path.parent.mkdir(exist_ok=True)
path.write_text(json.dumps(data, ensure_ascii=False, indent=2) + '\n')
def wait(count, base=None):
base = base or os.getenv('BASE_URL', 'http://localhost:8080')
deadline = time.monotonic() + 75
while time.monotonic() < deadline:
observed = set()
for _ in range(max(12, count * 8)):
try:
with urllib.request.urlopen(base + '/health/ready', timeout=3) as response:
observed.add(response.headers['X-Instance-Id'])
except (OSError, ValueError):
break
if len(observed) == count and None not in observed:
return sorted(observed)
time.sleep(.5)
raise RuntimeError(f'Не дождались {count} готовых API через LB')
def stop(instance):
hostname = instance.split(':')[0]
found = [r for r in containers('api') if r['hostname'] == hostname and r['running']]
if len(found) != 1:
raise RuntimeError('Instance alias не соответствует одной работающей API-реплике')
before = containers()
command(['docker', 'stop', '--time', '3', found[0]['id']])
result = dict(target=instance, stopped_container=found[0]['id'], before=before, after=containers())
save('last_stop.json', result)
return result
def scale(count, cpu, memory, pool):
env = dict(os.environ, API_CPU=str(cpu), API_MEMORY=memory, DB_POOL_MAX=str(pool))
command(['docker', 'compose', 'up', '-d', '--no-deps', '--force-recreate',
'--scale', f'api={count}', 'api'], env)
instances = wait(count)
rows = containers('api')
if len(rows) != count or not all(r['running'] for r in rows):
raise RuntimeError('Фактическое число контейнеров отличается от запрошенного')
for row in rows:
if abs(row['cpu_limit'] - cpu) > .001:
raise RuntimeError('Docker не применил CPU limit')
if row['memory_limit_bytes'] != int(memory.rstrip('m')) * 1024 * 1024:
raise RuntimeError('Docker не применил RAM limit')
return dict(instances=instances, containers=rows)
def rolling():
old = [r['id'] for r in containers('api') if r['running']]
if len(old) != 2:
raise RuntimeError('Rolling проверяется на двух репликах обычного стенда')
before = containers()
command(['docker', 'compose', 'build', 'api'])
steps = []
for container in old:
# Не пересоздаём одновременно старые контейнеры при изменении image.
command(['docker', 'compose', 'up', '-d', '--no-deps', '--no-recreate', '--scale', 'api=3', 'api'])
wait(3)
command(['docker', 'stop', '--time', '10', container])
command(['docker', 'rm', container])
wait(2)
steps.append(containers('api'))
save('rolling_containers.json', dict(before=before, steps=steps, after=containers()))
def main():
p = argparse.ArgumentParser()
p.add_argument('action', choices=['wait', 'snapshot', 'stop', 'rolling'])
p.add_argument('--count', type=int, default=2)
p.add_argument('--instance')
p.add_argument('--output', default='containers.json')
args = p.parse_args()
if args.action == 'wait':
print('API ready:', ', '.join(wait(args.count)))
elif args.action == 'snapshot':
save(args.output, containers())
print('Container identities and limits saved')
elif args.action == 'stop':
if not args.instance:
p.error('--instance required')
stop(args.instance)
print('Selected API stopped')
else:
rolling()
print('API replaced one at a time')
if __name__ == '__main__':
main()
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
docker compose up -d --build
python3 scripts/stack.py wait --count 2
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
: "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID is required}"
python3 scripts/stack.py stop --instance "$TARGET_INSTANCE_ID"
+11
View File
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
restore() {
docker compose up -d --no-deps --force-recreate --scale api=2 api
python3 scripts/stack.py wait --count 2
}
trap restore EXIT
SESSION_TTL_SECONDS=2 docker compose up -d --no-deps --force-recreate --scale api=2 api
python3 scripts/stack.py wait --count 2
python3 student-tests/checks.py --expiry
+17
View File
@@ -0,0 +1,17 @@
"""Ожидание готовности API без сторонних библиотек."""
import os
import time
import urllib.request
url = os.getenv('BASE_URL', 'http://localhost:8080') + '/health/ready'
for attempt in range(90):
try:
with urllib.request.urlopen(url, timeout=2) as response:
if response.status == 200:
print('API ready')
break
except OSError:
pass
time.sleep(1)
else:
raise SystemExit('API не стал готов за 90 попыток')
View File
+175
View File
@@ -0,0 +1,175 @@
"""Ограниченный upload в staging; обработка и публикация выполняются worker."""
import asyncio
import base64
from datetime import datetime
import hashlib
import os
import tempfile
import threading
import unicodedata
import uuid
import warnings
from fastapi import Request
from fastapi.responses import StreamingResponse
from PIL import Image, ImageFile, PngImagePlugin, UnidentifiedImageError
from pydantic import BaseModel, ConfigDict, Field
from starlette.concurrency import run_in_threadpool
from starlette.requests import ClientDisconnect
from src.config import MAX_UPLOAD_BYTES, MAX_IMAGE_PIXELS, UPLOAD_TIMEOUT, MAX_PENDING_JOBS
from src.errors import ApiProblem
from src.storage import ObjectStore, unlock_attachment
from src.jobs import enqueue, event
Image.MAX_IMAGE_PIXELS = MAX_IMAGE_PIXELS
ImageFile.LOAD_TRUNCATED_IMAGES = False
PngImagePlugin.MAX_TEXT_CHUNK = 1024 * 1024
PngImagePlugin.MAX_TEXT_MEMORY = 2 * 1024 * 1024
storage = ObjectStore()
upload_slots = asyncio.Semaphore(4)
validation_slots = threading.Semaphore(1)
class Attachment(BaseModel):
model_config = ConfigDict(extra='ignore')
id: uuid.UUID
chat_id: uuid.UUID
owner_id: uuid.UUID
filename: str
content_type: str
size_bytes: int
sha256: str
status: str
variants: list = Field(default_factory=list)
error_code: str | None = None
created_at: datetime
updated_at: datetime
def public_attachment(row):
return Attachment(**row).model_dump(mode='json')
def filename_valid(name):
if (not 1 <= len(name) <= 255 or not name.strip() or name in {'.', '..'} or
any(c in '/\\' or unicodedata.category(c) == 'Cc' for c in name)):
raise ApiProblem(400, 'invalid_request', 'Некорректное отображаемое имя файла')
def validate_image(file, declared_type):
# В API только ограниченная проверка структуры; полное декодирование — в worker.
with validation_slots, warnings.catch_warnings():
warnings.simplefilter('error', Image.DecompressionBombWarning)
try:
file.seek(0)
# Pillow может закрыть свой file object. Дубликат FD сохраняет исходный spool.
with os.fdopen(os.dup(file.fileno()), 'rb') as probe, Image.open(probe, formats=['PNG', 'JPEG']) as image:
if image.width * image.height > MAX_IMAGE_PIXELS:
raise ApiProblem(413, 'payload_too_large', 'Слишком много пикселей')
detected = {'PNG': 'image/png', 'JPEG': 'image/jpeg'}[image.format]
if detected != declared_type:
raise ApiProblem(415, 'unsupported_media_type', 'MIME не совпадает с содержимым')
image.verify()
if declared_type == 'image/jpeg':
# Обрыв JPEG с отсутствующим EOI заметен без декодирования всех пикселей.
file.seek(0); previous=b''; ended=False
while chunk:=file.read(64*1024):
if b'\xff\xd9' in previous+chunk: ended=True
previous=chunk[-1:]
if not ended:raise OSError('truncated JPEG')
except (Image.DecompressionBombError, Image.DecompressionBombWarning):
raise ApiProblem(413, 'payload_too_large', 'Слишком много пикселей') from None
except (UnidentifiedImageError, OSError, ValueError, SyntaxError):
raise ApiProblem(415, 'unsupported_media_type', 'Повреждённое или неподдерживаемое изображение') from None
file.seek(0)
def persist(file, pool, chat_id, owner_id, filename, mime, size, sha256, md5):
attachment_id,job_id=uuid.uuid4(),uuid.uuid4()
stage=f'staging/{attachment_id}/{job_id}'
final=f'originals/{attachment_id}/v1/original'
with pool.connection() as db:
db.execute('SELECT pg_advisory_lock(hashtextextended(%s,0))',('attachment:'+str(attachment_id),));db.commit()
try:
storage.put(file,stage,size,mime,sha256,md5)
# Общая точка admission предотвращает переполнение при двух API.
db.execute("SELECT pg_advisory_xact_lock(hashtextextended('pipeline-admission',0))")
pending=db.execute("SELECT count(*) AS count FROM jobs WHERE status IN ('queued','processing')").fetchone()['count']
if pending>=MAX_PENDING_JOBS:
raise ApiProblem(503,'unavailable','Очередь заполнена, повторите позже')
db.execute("INSERT INTO attachments(id,chat_id,owner_id,filename,content_type,size_bytes,sha256,object_key,"
"status,lease_until) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,'queued',clock_timestamp())",
(attachment_id,chat_id,owner_id,filename,mime,size,sha256,final))
job=db.execute("INSERT INTO jobs(id,attachment_id,pipeline_version,status,staging_key) "
"VALUES (%s,%s,1,'queued',%s) RETURNING *",(job_id,attachment_id,stage)).fetchone()
row=db.execute('UPDATE attachments SET current_job_id=%s WHERE id=%s RETURNING *',
(job_id,attachment_id)).fetchone()
enqueue(db,job);event(db,job_id,'accepted')
db.commit() # Staging уже устойчив, attachment/job/outbox фиксируются вместе.
return public_attachment(row) # Снимок queued, даже если worker очень быстрый.
finally:
# При неопределённом COMMIT ничего немедленно не удаляем.
db.rollback();unlock_attachment(db,attachment_id);db.commit()
def check_capacity(pool):
with pool.connection() as db:
count=db.execute("SELECT count(*) AS count FROM jobs WHERE status IN ('queued','processing')").fetchone()['count']
if count>=MAX_PENDING_JOBS:raise ApiProblem(503,'unavailable','Очередь заполнена, повторите позже')
async def receive(request: Request, pool, chat_id, owner_id, filename):
await run_in_threadpool(check_capacity,pool)
filename_valid(filename)
mime = request.headers.get('content-type', '').split(';', 1)[0].strip().lower()
if mime not in {'image/png', 'image/jpeg'}:
raise ApiProblem(415, 'unsupported_media_type', 'Нужен PNG или JPEG')
length = request.headers.get('content-length')
if length is not None:
if not length.isdecimal():
raise ApiProblem(400, 'invalid_request', 'Некорректный Content-Length')
if int(length) > MAX_UPLOAD_BYTES:
raise ApiProblem(413, 'payload_too_large', 'Лимит файла 10 MiB')
try:
async with asyncio.timeout(UPLOAD_TIMEOUT), upload_slots:
# На диске только временный bounded spool, не оригинал для будущего download.
with tempfile.TemporaryFile() as file:
size, sha, md5 = 0, hashlib.sha256(), hashlib.md5()
async for chunk in request.stream():
size += len(chunk)
if size > MAX_UPLOAD_BYTES:
raise ApiProblem(413, 'payload_too_large', 'Лимит файла 10 MiB')
await run_in_threadpool(file.write, chunk)
sha.update(chunk); md5.update(chunk)
if not size:
raise ApiProblem(415, 'unsupported_media_type', 'Пустой файл')
await run_in_threadpool(validate_image, file, mime)
return await run_in_threadpool(persist, file, pool, chat_id, owner_id, filename,
mime, size, sha.hexdigest(), base64.b64encode(md5.digest()).decode())
except TimeoutError:
raise ApiProblem(503, 'unavailable', 'Время загрузки истекло') from None
except ClientDisconnect:
raise ApiProblem(400, 'invalid_request', 'Передача файла прервана') from None
def download(row, variant='original'):
if variant=='original':key,mime,size=row['object_key'],row['content_type'],row['size_bytes']
else:
info=next((v for v in row['variants'] if v['name']==variant),None)
if info is None:raise ApiProblem(404,'not_found','Вариант отсутствует')
key,mime,size=row['variant_keys'][variant],info['content_type'],info['size_bytes']
result = storage.get(key)
body = result['Body']
if result['ContentLength'] != size:
body.close()
raise ApiProblem(503, 'unavailable', 'Оригинал временно недоступен')
def chunks():
try:
while data := body.read(64 * 1024):
yield data
finally:
body.close()
return StreamingResponse(chunks(), media_type=mime,
headers={'Content-Length': str(size)})
+37
View File
@@ -0,0 +1,37 @@
"""Redis Streams: отдельный persistent broker, consumer group и явный ack."""
import json
import redis
from src.config import BROKER_URL, JOB_LEASE
STREAM = 'attachments.jobs'
GROUP = 'image-workers'
def connect():
return redis.Redis.from_url(BROKER_URL, decode_responses=True, socket_connect_timeout=2,
socket_timeout=3, health_check_interval=10)
def ensure_group(client):
try:
client.xgroup_create(STREAM, GROUP, id='0-0', mkstream=True)
except redis.ResponseError as exc:
if 'BUSYGROUP' not in str(exc):
raise
def publish(client, payload):
return client.xadd(STREAM, {'job': json.dumps(payload, separators=(',', ':'))})
def receive(client, consumer):
# Сначала забираем брошенные pending, затем новую работу; prefetch ровно 1.
claimed = client.xautoclaim(STREAM, GROUP, consumer, JOB_LEASE*1000, '0-0', count=1)
if claimed[1]:
return claimed[1][0]
rows = client.xreadgroup(GROUP, consumer, {STREAM: '>'}, count=1, block=500)
return rows[0][1][0] if rows else None
def acknowledge(client, identifier):
client.xack(STREAM, GROUP, identifier)
+59
View File
@@ -0,0 +1,59 @@
"""Удаляет только безопасно завершённый staging или старые бесхозные исходники."""
import argparse
from datetime import datetime,timezone
import json
import time
import uuid
from src.config import STAGING_RETENTION
from src.jobs import connection,event
from src.storage import ObjectStore,lock_attachment,unlock_attachment
def run(retention=STAGING_RETENTION,apply=False):
storage=ObjectStore();actions=[];now=datetime.now(timezone.utc)
try:
objects=list(storage.objects('staging/'))
with connection() as db:
for obj in objects:
parts=obj['Key'].split('/')
try:attachment_id=uuid.UUID(parts[1]);job_id=uuid.UUID(parts[2])
except (ValueError,IndexError):continue
if len(parts)!=3:continue
if not lock_attachment(db,attachment_id,wait=False):db.commit();continue
db.commit()
try:
job=db.execute('SELECT * FROM jobs WHERE id=%s',(job_id,)).fetchone()
current=storage.head(obj['Key'])
if current is None:continue
object_old=(now-current['LastModified']).total_seconds()>=retention
safe=False
if not job:safe=object_old
elif job['status']=='ready':safe=True
elif job['status'] in {'failed','superseded'}:
safe=object_old and (now-job['updated_at']).total_seconds()>=retention
if not safe:continue
actions.append(dict(key=obj['Key'],reason='committed_ready' if job and job['status']=='ready' else 'retention',applied=apply))
if apply:
storage.delete(obj['Key'])
if job:
db.execute('UPDATE jobs SET staged_deleted_at=clock_timestamp() WHERE id=%s',(job_id,))
event(db,job_id,'staging_cleaned');db.commit()
finally:db.rollback();unlock_attachment(db,attachment_id);db.commit()
finally:storage.client.close()
return dict(mode='apply' if apply else 'dry-run',retention_seconds=retention,objects_scanned=len(objects),actions=actions)
def main():
p=argparse.ArgumentParser();p.add_argument('--apply',action='store_true');p.add_argument('--loop',action='store_true')
p.add_argument('--retention',type=int,default=STAGING_RETENTION);args=p.parse_args()
if args.retention<1:p.error('Positive retention required')
while True:
try:print(json.dumps(run(args.retention,args.apply)),flush=True)
except Exception as exc:
print(json.dumps(dict(status='FAILED',reason=type(exc).__name__)),flush=True)
if not args.loop:raise SystemExit(1)
if not args.loop:break
time.sleep(60)
if __name__=='__main__':main()
+32
View File
@@ -0,0 +1,32 @@
"""Настройки из окружения или Docker secrets; секреты не печатаем."""
import os
from pathlib import Path
def setting(name, default=None):
file = os.getenv(name + '_FILE')
return Path(file).read_text().strip() if file else os.getenv(name, default)
DATABASE_URL = setting('DATABASE_URL')
CACHE_URL = setting('CACHE_URL', 'redis://localhost:6379/0')
SESSION_TTL = int(os.getenv('SESSION_TTL_SECONDS', '3600'))
POOL_MAX = int(os.getenv('DB_POOL_MAX', '8'))
S3_ENDPOINT = setting('S3_ENDPOINT', 'http://s3:9000')
S3_REGION = setting('S3_REGION', 'us-east-1')
S3_BUCKET = setting('S3_BUCKET', 'messenger-attachments')
S3_ACCESS_KEY = setting('S3_ACCESS_KEY_ID')
S3_SECRET_KEY = setting('S3_SECRET_ACCESS_KEY')
MAX_UPLOAD_BYTES = min(int(os.getenv('MAX_UPLOAD_BYTES', '10485760')), 10485760)
MAX_IMAGE_PIXELS = min(int(os.getenv('MAX_IMAGE_PIXELS', '40000000')), 40000000)
UPLOAD_TIMEOUT = int(os.getenv('UPLOAD_TIMEOUT_SECONDS', '45'))
BROKER_URL = setting('BROKER_URL', 'redis://localhost:6380/0')
WORKER_CONCURRENCY = int(os.getenv('WORKER_CONCURRENCY', '1'))
JOB_MAX_ATTEMPTS = int(os.getenv('JOB_MAX_ATTEMPTS', '5'))
JOB_TIMEOUT = int(os.getenv('JOB_TIMEOUT_SECONDS', '30'))
JOB_LEASE = int(os.getenv('JOB_LEASE_SECONDS', '15'))
STAGING_RETENTION = int(os.getenv('STAGING_RETENTION_SECONDS', '86400'))
MAX_PENDING_JOBS = int(os.getenv('MAX_PENDING_JOBS', '1000'))
ALLOW_FAULTS = os.getenv('ALLOW_FAULT_INJECTION', '0') == '1'
WORKER_MEMORY_BYTES = int(os.getenv('WORKER_IMAGE_MEMORY_MIB', '512')) * 1024 * 1024
+39
View File
@@ -0,0 +1,39 @@
"""Публикует transactional outbox и возвращает брошенные processing в очередь."""
import json
import time
from src.broker import connect, ensure_group, publish
from src.jobs import connection, event, payload, recover_leases
from src.faults import checkpoint
def dispatch_once(client):
with connection() as db:
row = db.execute("SELECT o.id AS outbox_id,o.attempt,j.* FROM job_outbox o JOIN jobs j ON j.id=o.job_id "
'JOIN attachments a ON a.current_job_id=j.id '
"WHERE o.published_at IS NULL AND j.status='queued' AND j.available_at<=clock_timestamp() "
'AND o.attempt=j.attempts+1 ORDER BY o.id FOR UPDATE OF o SKIP LOCKED LIMIT 1').fetchone()
if not row:return False
checkpoint(row['id'],'before_publish')
stream_id=publish(client,payload(row,row['attempt']))
checkpoint(row['id'],'after_publish')
db.execute('UPDATE job_outbox SET published_at=clock_timestamp(),stream_id=%s WHERE id=%s',
(stream_id,row['outbox_id']))
event(db,row['id'],'published',attempt=row['attempt'],stream_id=stream_id)
# XADD ответил до фиксации published_at. Crash даёт повтор, а не потерю.
return True
def main():
client=connect();last_recovery=0
while True:
try:
ensure_group(client)
if time.monotonic()-last_recovery>=1:
recover_leases();last_recovery=time.monotonic()
if not dispatch_once(client):time.sleep(.2)
except Exception as exc:
print(json.dumps(dict(role='dispatcher',status='retry',reason=type(exc).__name__)),flush=True)
time.sleep(1)
if __name__=='__main__':main()
+6
View File
@@ -0,0 +1,6 @@
class ApiProblem(Exception):
def __init__(self, status, code, message, challenge=None):
self.status = status
self.code = code
self.message = message
self.challenge = challenge
+19
View File
@@ -0,0 +1,19 @@
"""Одноразовый crash в заданном окне; выключен в обычном стенде."""
import os
import psycopg
from src.config import ALLOW_FAULTS, DATABASE_URL
PHASES = {'before_publish', 'after_publish', 'before_effect', 'after_original',
'after_effects', 'after_commit'}
def checkpoint(job_id, phase):
if not ALLOW_FAULTS:
return
with psycopg.connect(DATABASE_URL, connect_timeout=2) as db:
row = db.execute('UPDATE pipeline_faults SET fired_at=clock_timestamp() '
'WHERE job_id=%s AND phase=%s AND fired_at IS NULL RETURNING job_id',
(job_id, phase)).fetchone()
if row:
# Имитирует внезапную смерть процесса: finally/ack намеренно не выполняются.
os._exit(91)
+72
View File
@@ -0,0 +1,72 @@
"""Изолированная обработка: stdin/сеть не нужны, только файлы одного задания."""
import argparse
import hashlib
import json
from pathlib import Path
import resource
import warnings
from PIL import Image, ImageFile, ImageOps, PngImagePlugin
from src.config import MAX_IMAGE_PIXELS, WORKER_MEMORY_BYTES
Image.MAX_IMAGE_PIXELS=MAX_IMAGE_PIXELS
ImageFile.LOAD_TRUNCATED_IMAGES=False
PngImagePlugin.MAX_TEXT_CHUNK=1024*1024
PngImagePlugin.MAX_TEXT_MEMORY=2*1024*1024
def fit_size(width,height,limit):
if max(width,height)<=limit:return width,height
if width>=height:return limit,max(1,height*limit//width)
return max(1,width*limit//height),limit
def transform(source,destination,version):
destination=Path(destination)
with warnings.catch_warnings():
warnings.simplefilter('error',Image.DecompressionBombWarning)
image=Image.open(source,formats=['PNG','JPEG'])
if image.width*image.height>MAX_IMAGE_PIXELS:
image.close();raise ValueError('pixel limit')
image.load()
ImageOps.exif_transpose(image,in_place=True)
if image.mode=='RGBA' or 'transparency' in image.info or image.mode in {'LA','P'}:
rgba=image if image.mode=='RGBA' else image.convert('RGBA')
if rgba is not image:image.close()
background=Image.new('RGB',rgba.size,'white');alpha=rgba.getchannel('A')
background.paste(rgba,mask=alpha);alpha.close();rgba.close();image=background
elif image.mode!='RGB':
converted=image.convert('RGB');image.close();image=converted
# Новый RGB объект не переносит EXIF/ICC/XMP в варианты.
image.info.clear()
quality=82 if version==1 else 86
outputs=[]
for name,limit,fmt,mime in [('thumbnail',256,'JPEG','image/jpeg'),('crop',128,'JPEG','image/jpeg'),
('optimized',1280,'WEBP','image/webp')]:
if name=='crop':
side=min(image.size);left=(image.width-side)//2;top=(image.height-side)//2
square=image.crop((left,top,left+side,top+side))
result=square.resize((128,128),Image.Resampling.LANCZOS);square.close()
else:result=image.resize(fit_size(*image.size,limit),Image.Resampling.LANCZOS)
file=destination/(name+('.jpg' if fmt=='JPEG' else '.webp'))
result.save(file,format=fmt,quality=quality,**({'method':4} if fmt=='WEBP' else {'optimize':True}))
data=file.read_bytes()
outputs.append(dict(name=name,content_type=mime,size_bytes=len(data),width=result.width,height=result.height,
sha256=hashlib.sha256(data).hexdigest(),file=file.name))
result.close()
image.close()
return outputs
def main():
p=argparse.ArgumentParser();p.add_argument('source');p.add_argument('destination');p.add_argument('version',type=int)
args=p.parse_args()
resource.setrlimit(resource.RLIMIT_AS,(WORKER_MEMORY_BYTES,WORKER_MEMORY_BYTES))
try:
values=transform(args.source,args.destination,args.version)
Path(args.destination,'variants.json').write_text(json.dumps(values))
except MemoryError:raise SystemExit(12)
except Exception:raise SystemExit(10)
if __name__=='__main__':main()
+186
View File
@@ -0,0 +1,186 @@
"""Состояния задания, outbox и явные команды оператора. Без публичного admin API."""
import argparse
from contextlib import contextmanager
import json
import random
import uuid
import psycopg
from psycopg.rows import dict_row
from psycopg.types.json import Jsonb
from src.config import DATABASE_URL, JOB_MAX_ATTEMPTS
from src.storage import lock_attachment, unlock_attachment
@contextmanager
def connection():
with psycopg.connect(DATABASE_URL, row_factory=dict_row, connect_timeout=2,
options='-c statement_timeout=10000 -c lock_timeout=2000') as db:
yield db
def event(db, job_id, name, **details):
db.execute('INSERT INTO job_events(job_id,event,details) VALUES (%s,%s,%s)',
(job_id, name, Jsonb(details)))
def enqueue(db, job):
db.execute('INSERT INTO job_outbox(job_id,attempt) VALUES (%s,%s) ON CONFLICT DO NOTHING',
(job['id'], job['attempts']+1))
def payload(job, attempt):
return dict(schema_version=1, job_id=str(job['id']), type='attachment.process.v1',
attachment_id=str(job['attachment_id']), pipeline_version=job['pipeline_version'],
attempt=attempt, created_at=job['created_at'].isoformat().replace('+00:00', 'Z'))
def retry_or_fail(db, job, code, permanent=False):
exhausted = job['attempts']-job['budget_start'] >= JOB_MAX_ATTEMPTS
if permanent or exhausted:
final_code = code if permanent else 'retry_exhausted'
db.execute("UPDATE jobs SET status='failed',error_code=%s,lease_token=NULL,lease_until=NULL,"
"updated_at=clock_timestamp() WHERE id=%s", (final_code, job['id']))
db.execute("UPDATE attachments SET status='failed',error_code=%s,updated_at=clock_timestamp() "
'WHERE current_job_id=%s', (final_code, job['id']))
event(db, job['id'], 'failed', code=final_code, attempt=job['attempts'])
else:
# Ограниченный exponential backoff + jitter, максимум 10 секунд.
delay = min(10, 2**min(job['attempts']-1, 4)) + random.uniform(0, .5)
db.execute("UPDATE jobs SET status='queued',error_code=%s,lease_token=NULL,lease_until=NULL,"
"available_at=clock_timestamp()+%s*interval '1 second',updated_at=clock_timestamp() WHERE id=%s",
(code, delay, job['id']))
db.execute("UPDATE attachments SET status='queued',error_code=NULL,updated_at=clock_timestamp() "
'WHERE current_job_id=%s', (job['id'],))
enqueue(db, job)
event(db, job['id'], 'retry_scheduled', code=code, attempt=job['attempts'], delay_seconds=round(delay, 3))
def recover_leases():
recovered = []
with connection() as db:
rows = db.execute("SELECT id,attachment_id FROM jobs WHERE status='processing' AND lease_until<clock_timestamp()").fetchall()
db.commit()
for candidate in rows:
if not lock_attachment(db, candidate['attachment_id'], wait=False):
db.commit(); continue
db.commit()
try:
job = db.execute("SELECT * FROM jobs WHERE id=%s AND status='processing' "
'AND lease_until<clock_timestamp() FOR UPDATE', (candidate['id'],)).fetchone()
if job:
retry_or_fail(db, job, 'lease_expired')
event(db, job['id'], 'lease_recovered')
db.commit(); recovered.append(str(job['id']))
finally:
db.rollback(); unlock_attachment(db, candidate['attachment_id']); db.commit()
return recovered
def replay(identifier):
with connection() as db:
job = db.execute('SELECT * FROM jobs WHERE id=%s', (identifier,)).fetchone()
if not job: raise ValueError('Unknown job')
lock_attachment(db, job['attachment_id']); db.commit()
try:
job = db.execute('SELECT * FROM jobs WHERE id=%s FOR UPDATE', (identifier,)).fetchone()
att = db.execute('SELECT * FROM attachments WHERE id=%s FOR UPDATE', (job['attachment_id'],)).fetchone()
if job['status']=='ready': return dict(status='noop', reason='already_ready')
if att['current_job_id'] != job['id'] or job['status']!='failed':
raise ValueError('Only current failed job can be replayed')
from src.storage import ObjectStore
storage=ObjectStore()
try:
if storage.head(job['staging_key']) is None: raise ValueError('Staging expired; original must be restored first')
finally: storage.client.close()
db.execute("UPDATE jobs SET status='queued',budget_start=attempts,error_code=NULL,"
'available_at=clock_timestamp(),updated_at=clock_timestamp() WHERE id=%s', (identifier,))
db.execute("UPDATE attachments SET status='queued',error_code=NULL,updated_at=clock_timestamp() WHERE id=%s",
(att['id'],))
enqueue(db, job); event(db, identifier, 'operator_replay', next_attempt=job['attempts']+1)
db.commit()
return dict(status='queued', job_id=str(identifier))
finally:
db.rollback(); unlock_attachment(db, job['attachment_id']); db.commit()
def new_version(attachment_id, version):
if version not in {1,2}: raise ValueError('Supported pipeline versions: 1,2')
from src.storage import ObjectStore
storage=ObjectStore()
with connection() as db:
lock_attachment(db, attachment_id);db.commit()
try:
att=db.execute('SELECT * FROM attachments WHERE id=%s FOR UPDATE', (attachment_id,)).fetchone()
if not att or version<=att['pipeline_version']:raise ValueError('Version must increase')
# Для queued ещё есть staging; для ready источником служит прежний original.
old=db.execute('SELECT * FROM jobs WHERE id=%s',(att['current_job_id'],)).fetchone()
source=att['object_key'] if att['status']=='ready' else old['staging_key']
identifier=uuid.uuid4();stage=f'staging/{attachment_id}/{identifier}'
storage.copy(source,stage)
if old and old['status'] not in {'ready','failed'}:
db.execute("UPDATE jobs SET status='superseded',updated_at=clock_timestamp() WHERE id=%s",(old['id'],))
job=db.execute("INSERT INTO jobs(id,attachment_id,pipeline_version,status,staging_key) "
"VALUES (%s,%s,%s,'queued',%s) RETURNING *",(identifier,attachment_id,version,stage)).fetchone()
final=f'originals/{attachment_id}/v{version}/original'
db.execute("UPDATE attachments SET current_job_id=%s,pipeline_version=%s,status='queued',"
"object_key=%s,variants='[]',variant_keys='{}',error_code=NULL,updated_at=clock_timestamp() WHERE id=%s",
(identifier,version,final,attachment_id))
enqueue(db,job);event(db,identifier,'version_created',pipeline_version=version)
db.commit()
return dict(job_id=str(identifier),pipeline_version=version)
finally:
db.rollback();unlock_attachment(db,attachment_id);db.commit();storage.client.close()
def inspect(identifier):
with connection() as db:
job=db.execute('SELECT * FROM jobs WHERE id=%s',(identifier,)).fetchone()
if not job:raise ValueError('Unknown job')
att=db.execute('SELECT status,pipeline_version,current_job_id,object_key,variants,variant_keys,sha256,size_bytes '
'FROM attachments WHERE id=%s',(job['attachment_id'],)).fetchone()
events=db.execute('SELECT event,details,created_at FROM job_events WHERE job_id=%s ORDER BY id',(identifier,)).fetchall()
outbox=db.execute('SELECT attempt,published_at,stream_id FROM job_outbox WHERE job_id=%s ORDER BY id',(identifier,)).fetchall()
faults=db.execute('SELECT phase,fired_at FROM pipeline_faults WHERE job_id=%s',(identifier,)).fetchall()
return dict(job=job,attachment=att,events=events,outbox=outbox,faults=faults)
def main():
p=argparse.ArgumentParser()
sub=p.add_subparsers(dest='action',required=True)
for name in ['inspect','replay','duplicate','fault']:
cmd=sub.add_parser(name);cmd.add_argument('job_id',type=uuid.UUID)
if name=='fault':
from src.faults import PHASES
cmd.add_argument('phase',choices=sorted(PHASES))
if name=='duplicate':cmd.add_argument('--attempt',type=int)
cmd=sub.add_parser('version');cmd.add_argument('attachment_id',type=uuid.UUID);cmd.add_argument('version',type=int)
cmd=sub.add_parser('find');cmd.add_argument('attachment_id',type=uuid.UUID)
sub.add_parser('failed')
args=p.parse_args()
if args.action=='inspect':result=inspect(args.job_id)
elif args.action=='replay':result=replay(args.job_id)
elif args.action=='version':result=new_version(args.attachment_id,args.version)
else:
with connection() as db:
if args.action=='find':
row=db.execute('SELECT current_job_id FROM attachments WHERE id=%s',(args.attachment_id,)).fetchone()
result=dict(job_id=str(row['current_job_id']))
elif args.action=='failed':
result=db.execute("SELECT id,attachment_id,pipeline_version,attempts,error_code FROM jobs WHERE status='failed' ORDER BY updated_at DESC").fetchall()
elif args.action=='fault':
db.execute('INSERT INTO pipeline_faults(job_id,phase) VALUES (%s,%s) '
'ON CONFLICT (job_id,phase) DO UPDATE SET fired_at=NULL',(args.job_id,args.phase))
result=dict(armed=True,job_id=str(args.job_id),phase=args.phase)
else:
from src.broker import connect,publish
job=db.execute('SELECT * FROM jobs WHERE id=%s',(args.job_id,)).fetchone()
client=connect()
try:stream_id=publish(client,payload(job,args.attempt or max(1,job['attempts'])))
finally:client.close()
event(db,job['id'],'operator_duplicate',stream_id=stream_id)
result=dict(stream_id=stream_id,job_id=str(job['id']))
print(json.dumps(result,default=str,ensure_ascii=False))
if __name__=='__main__':main()
+633
View File
@@ -0,0 +1,633 @@
from __future__ import annotations
import base64
import json
import logging
import os
import re
import time
import uuid
from datetime import datetime, timedelta, timezone
from contextlib import asynccontextmanager
import hashlib
import secrets
import socket
import resource
import psycopg
from psycopg.rows import dict_row
from psycopg.types.json import Jsonb
from psycopg_pool import ConnectionPool, PoolTimeout
import redis
from argon2 import PasswordHasher
from argon2.exceptions import VerificationError, InvalidHashError
from starlette.exceptions import HTTPException
from src.config import DATABASE_URL, CACHE_URL, SESSION_TTL, POOL_MAX
from src.errors import ApiProblem
from src import attachments
from botocore.exceptions import BotoCoreError, ClientError
from typing import Annotated
from fastapi import Depends, FastAPI, Header, Query, Request
from fastapi.exceptions import RequestValidationError
from fastapi.responses import JSONResponse, Response
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
from starlette.concurrency import run_in_threadpool
logging.basicConfig(
level=os.getenv("LOG_LEVEL", "INFO").upper(),
format="%(asctime)s %(levelname)s %(message)s",
)
logger = logging.getLogger("messenger")
def utc_now() -> datetime:
return datetime.now(timezone.utc)
def as_json(value: BaseModel) -> dict:
return value.model_dump(mode="json")
class StrictModel(BaseModel):
model_config = ConfigDict(extra="forbid")
class User(StrictModel):
id: uuid.UUID
username: str
display_name: str
created_at: datetime
class CreateUser(StrictModel):
username: str = Field(pattern=r"^[a-z0-9_]{3,32}$")
display_name: str = Field(min_length=1, max_length=100)
password: str = Field(min_length=12, max_length=128)
@field_validator("password")
@classmethod
def password_has_visible_characters(cls, value: str) -> str:
if not value.strip():
raise ValueError("password must not contain only whitespace")
return value
@field_validator("display_name")
@classmethod
def display_name_has_visible_characters(cls, value: str) -> str:
if not value.strip():
raise ValueError("display_name must not contain only whitespace")
return value
class Chat(StrictModel):
id: uuid.UUID
title: str
member_ids: list[uuid.UUID]
created_at: datetime
class CreateChat(StrictModel):
title: str = Field(min_length=1, max_length=100)
member_ids: list[uuid.UUID] = Field(min_length=1, max_length=100)
@field_validator("title")
@classmethod
def title_has_visible_characters(cls, value: str) -> str:
if not value.strip():
raise ValueError("title must not contain only whitespace")
return value
@field_validator("member_ids")
@classmethod
def member_ids_are_unique(cls, value: list[uuid.UUID]) -> list[uuid.UUID]:
if len(value) != len(set(value)):
raise ValueError("member_ids must be unique")
return value
class Message(StrictModel):
id: uuid.UUID
chat_id: uuid.UUID
sender_id: uuid.UUID
text: str
created_at: datetime
attachment_ids: list[uuid.UUID] = Field(default_factory=list)
class CreateMessage(StrictModel):
text: str = Field(max_length=4000)
attachment_ids: list[uuid.UUID] = Field(default_factory=list, max_length=10)
@model_validator(mode='after')
def valid_message(self):
if not self.text.strip() and not self.attachment_ids:
raise ValueError('Нужен текст или вложение')
if len(self.attachment_ids) != len(set(self.attachment_ids)):
raise ValueError('Повторяющиеся attachment_ids')
return self
class Store:
"""Сессии и метаданные в PostgreSQL; Redis — только кеш профилей."""
def __init__(self) -> None:
self.pool = ConnectionPool(
DATABASE_URL, min_size=1, max_size=POOL_MAX, timeout=2, open=False,
kwargs={"row_factory": dict_row, "connect_timeout": 2,
"options": "-c statement_timeout=3000 -c lock_timeout=2000 -c timezone=UTC"},
)
self.cache = redis.Redis.from_url(
CACHE_URL, decode_responses=True, socket_connect_timeout=0.25, socket_timeout=0.25,
)
def start(self) -> None:
self.pool.open()
self.pool.wait(timeout=10)
def close(self) -> None:
self.pool.close()
self.cache.close()
def chat(self, db, chat_id: uuid.UUID) -> Chat | None:
row = db.execute("SELECT * FROM chats WHERE id=%s", (chat_id,)).fetchone()
if row is None:
return None
members = db.execute("SELECT user_id FROM chat_members WHERE chat_id=%s ORDER BY user_id",
(chat_id,)).fetchall()
return Chat(**row, member_ids=[member["user_id"] for member in members])
def chat_messages(self, db, chat_id: uuid.UUID, limit: int, after) -> list[Message]:
# В lab1 здесь были общий список/список чата и bisect_right.
# Теперь границу ищет B-tree PostgreSQL (chat_id, created_at, id).
query = ("SELECT m.*, COALESCE((SELECT array_agg(a.attachment_id ORDER BY a.position) "
"FROM message_attachments a WHERE a.message_id=m.id),'{}'::uuid[]) AS attachment_ids "
"FROM messages m WHERE chat_id=%s")
params = [chat_id]
if after is not None:
query += " AND (created_at,id)>(%s,%s)"
params.extend(after)
rows = db.execute(query + " ORDER BY created_at,id LIMIT %s", params + [limit + 1]).fetchall()
return [Message(**row) for row in rows]
INSTANCE_ID = os.getenv("INSTANCE_ID") or f"{socket.gethostname()}:{uuid.uuid4().hex[:8]}"
store = Store()
passwords = PasswordHasher(time_cost=2, memory_cost=19456, parallelism=1)
dummy_hash = passwords.hash(secrets.token_urlsafe(32))
@asynccontextmanager
async def lifespan(app):
store.start()
yield
store.close()
app = FastAPI(title="MTUCI PostgreSQL messenger", version="5.0.0", lifespan=lifespan,
docs_url=None, redoc_url=None, openapi_url=None)
def request_id(request: Request) -> str:
return request.state.request_id
def error_response(request: Request, status: int, code: str, message: str, challenge: str | None = None) -> JSONResponse:
rid = getattr(request.state, "request_id", str(uuid.uuid4()))
headers = {"X-Request-Id": rid, "X-Instance-Id": INSTANCE_ID}
if challenge:
headers["WWW-Authenticate"] = challenge
return JSONResponse(
status_code=status,
content={"error": {"code": code, "message": message, "request_id": rid}},
headers=headers,
)
@app.middleware("http")
async def request_context(request: Request, call_next):
request.state.request_id = str(uuid.uuid4())
started = time.perf_counter()
status = 500
try:
# Без токена отказываем ДО обращения к БД и проверки JSON.
if request.url.path.startswith("/api/v1/") and request.url.path not in {
"/api/v1/users", "/api/v1/auth/sessions"
}:
scheme, _, token = request.headers.get("authorization", "").partition(" ")
if scheme.lower() != "bearer" or not token or len(token) > 256:
status = 401
return error_response(request, 401, "unauthorized", "Требуется Bearer",
'Bearer realm="messenger"')
json_endpoints = {
"/api/v1/users",
"/api/v1/chats",
}
requires_json = request.method == "POST" and (
request.url.path in json_endpoints
or re.fullmatch(r"/api/v1/chats/[^/]+/messages", request.url.path) is not None
)
media_type = request.headers.get("content-type", "").split(";", 1)[0].strip().lower()
if requires_json and media_type != "application/json":
status = 415
return error_response(
request,
415,
"unsupported_media_type",
"Требуется Content-Type: application/json",
)
if requires_json:
# Ограниченный JSON; после body() Starlette повторно отдаёт его маршруту.
raw = await request.body()
if len(raw) > 65536:
status = 413
return error_response(request, 413, "payload_too_large", "Запрос слишком большой")
response = await call_next(request)
status = response.status_code
response.headers["X-Request-Id"] = request.state.request_id
response.headers["X-Instance-Id"] = INSTANCE_ID
return response
finally:
logger.info(
"request method=%s path=%s status=%s duration_ms=%.3f request_id=%s",
request.method,
request.url.path,
status,
(time.perf_counter() - started) * 1000,
request.state.request_id,
)
@app.exception_handler(ApiProblem)
async def api_problem_handler(request: Request, exc: ApiProblem):
return error_response(request, exc.status, exc.code, exc.message, exc.challenge)
@app.exception_handler(RequestValidationError)
async def validation_handler(request: Request, exc: RequestValidationError):
return error_response(request, 400, "invalid_request", "Запрос не соответствует контракту")
@app.exception_handler(Exception)
async def unexpected_error_handler(request: Request, exc: Exception):
logger.error("unexpected_error request_id=%s", request_id(request))
return error_response(request, 500, "internal_error", "Внутренняя ошибка сервера")
@app.exception_handler(psycopg.Error)
@app.exception_handler(PoolTimeout)
async def database_error_handler(request: Request, exc: Exception):
return error_response(request, 503, "unavailable", "Хранилище временно недоступно")
@app.exception_handler(BotoCoreError)
@app.exception_handler(ClientError)
async def object_store_error_handler(request: Request, exc: Exception):
return error_response(request, 503, 'unavailable', 'Объектное хранилище временно недоступно')
@app.exception_handler(HTTPException)
async def http_error_handler(request: Request, exc: HTTPException):
code = "not_found" if exc.status_code == 404 else "invalid_request"
return error_response(request, exc.status_code, code, "Неверный маршрут или метод")
def unauthorized(basic=False):
challenge = 'Basic realm="messenger", charset="UTF-8"' if basic else 'Bearer realm="messenger"'
raise ApiProblem(401, "unauthorized", "Нужна действительная идентификация", challenge)
def token_hash(token: str) -> str:
return hashlib.sha256(token.encode()).hexdigest()
def current_user(authorization: Annotated[str | None, Header()] = None) -> User:
scheme, _, token = (authorization or "").partition(" ")
if scheme.lower() != "bearer" or not token or len(token) > 256:
unauthorized()
with store.pool.connection() as db:
session = db.execute("SELECT user_id FROM sessions WHERE token_hash=%s AND expires_at>now()",
(token_hash(token),)).fetchone()
if session is None:
unauthorized()
key = "user:" + str(session["user_id"])
cache_available = True
try:
cached = store.cache.get(key)
if cached:
user = User.model_validate_json(cached)
if user.id == session["user_id"]:
return user
except (redis.RedisError, ValueError):
cache_available = False
row = db.execute("SELECT id,username,display_name,created_at FROM users WHERE id=%s",
(session["user_id"],)).fetchone()
user = User(**row)
if cache_available:
try:
store.cache.setex(key, 60, user.model_dump_json())
except redis.RedisError:
pass
return user
def decode_cursor(cursor: str, expected_scope: str) -> tuple[datetime, uuid.UUID]:
try:
if not cursor or len(cursor) > 1024:
raise ValueError
padded = cursor + "=" * (-len(cursor) % 4)
payload = json.loads(base64.b64decode(padded.encode(), altchars=b"-_", validate=True).decode())
if not isinstance(payload, dict) or set(payload) != {"scope", "created_at", "id"}:
raise ValueError
if payload["scope"] != expected_scope:
raise ValueError
if not isinstance(payload["created_at"], str) or not isinstance(payload["id"], str):
raise ValueError
created_at = datetime.fromisoformat(payload["created_at"].replace("Z", "+00:00"))
item_id = uuid.UUID(payload["id"])
if created_at.tzinfo is None:
raise ValueError
return created_at, item_id
except (ValueError, TypeError, KeyError, json.JSONDecodeError, UnicodeError):
raise ApiProblem(400, "invalid_request", "Некорректный cursor") from None
def encode_cursor(scope: str, created_at: datetime, item_id: uuid.UUID) -> str:
payload = {
"scope": scope,
"created_at": created_at.isoformat().replace("+00:00", "Z"),
"id": str(item_id),
}
return base64.urlsafe_b64encode(json.dumps(payload, separators=(",", ":")).encode()).decode().rstrip("=")
def page(items: list, limit: int, scope: str) -> dict:
# SQL уже выбрал limit+1 строк после курсора; весь список не загружаем.
selected = items[:limit]
next_cursor = None
if len(items) > limit and selected:
last = selected[-1]
next_cursor = encode_cursor(scope, last.created_at, last.id)
return {"items": [as_json(item) for item in selected], "next_cursor": next_cursor}
def visible_chat(chat_id: uuid.UUID, user: User) -> Chat:
with store.pool.connection() as db:
member = db.execute("SELECT 1 FROM chat_members WHERE chat_id=%s AND user_id=%s",
(chat_id, user.id)).fetchone()
if member is None:
raise ApiProblem(404, "not_found", "Объект не найден")
return store.chat(db, chat_id)
def page_parameters(request: Request, scope: str, limit: int, cursor: str | None):
# Query(ge/le) сохранён из lab1, добавлена проверка дублей и формы limit.
if set(request.query_params) - {"limit", "cursor"} or any(
len(request.query_params.getlist(k)) > 1 for k in request.query_params
):
raise ApiProblem(400, "invalid_request", "Некорректные параметры страницы")
if not re.fullmatch(r"[0-9]{1,3}", request.query_params.get("limit", "50")):
raise ApiProblem(400, "invalid_request", "Некорректный limit")
return decode_cursor(cursor, scope) if cursor is not None else None
@app.get("/health/live")
def liveness():
return {"status": "ok"}
@app.get("/health/ready")
def readiness():
with store.pool.connection() as db:
db.execute("SELECT 1")
attachments.storage.ready()
return {"status": "ok"}
@app.get("/internal/pool")
def pool_statistics():
# Диагностика доступна только внутри Docker network: LB закрывает этот путь.
return store.pool.get_stats()
@app.get('/internal/memory')
def memory_statistics():
result = {'process_peak_rss_bytes': resource.getrusage(resource.RUSAGE_SELF).ru_maxrss * 1024}
from pathlib import Path
for name in ['/sys/fs/cgroup/memory.peak', '/sys/fs/cgroup/memory/memory.max_usage_in_bytes']:
path = Path(name)
if path.is_file():
result['container_peak_bytes'] = int(path.read_text().strip())
result['container_peak_source'] = name
break
return result
@app.post("/api/v1/users", status_code=201)
def register_user(body: CreateUser):
# Синхронные маршруты FastAPI исполняет в worker thread, не в event loop.
hashed = passwords.hash(body.password)
try:
with store.pool.connection() as db:
row = db.execute(
"INSERT INTO users(id,username,display_name,password_hash) VALUES (%s,%s,%s,%s) "
"RETURNING id,username,display_name,created_at",
(uuid.uuid4(), body.username, body.display_name, hashed),
).fetchone()
except psycopg.errors.UniqueViolation:
raise ApiProblem(409, "conflict", "Username уже занят") from None
return as_json(User(**row))
@app.post("/api/v1/auth/sessions", status_code=201)
def create_session(request: Request, authorization: Annotated[str | None, Header()] = None):
if request.headers.get("content-length", "0") != "0" or "transfer-encoding" in request.headers:
raise ApiProblem(400, "invalid_request", "Вход не принимает тело запроса")
scheme, _, encoded = (authorization or "").partition(" ")
try:
if scheme.lower() != "basic" or len(encoded) > 2048:
raise ValueError
username, password = base64.b64decode(encoded, validate=True).decode("utf-8").split(":", 1)
if not re.fullmatch(r"[a-z0-9_]{3,32}", username) or not 12 <= len(password) <= 128:
raise ValueError
except (ValueError, UnicodeError):
unauthorized(basic=True)
with store.pool.connection() as db:
row = db.execute("SELECT * FROM users WHERE username=%s", (username,)).fetchone()
try:
passwords.verify(row["password_hash"] if row else dummy_hash, password)
except (VerificationError, InvalidHashError):
unauthorized(basic=True)
if row is None:
unauthorized(basic=True)
token = secrets.token_urlsafe(32)
expires_at = utc_now() + timedelta(seconds=SESSION_TTL)
with store.pool.connection() as db:
db.execute("INSERT INTO sessions(token_hash,user_id,expires_at) VALUES (%s,%s,%s)",
(token_hash(token), row["id"], expires_at))
user = User(**{k: row[k] for k in ("id", "username", "display_name", "created_at")})
return {"token": token, "token_type": "Bearer", "user": as_json(user),
"expires_at": expires_at.isoformat().replace("+00:00", "Z")}
@app.delete("/api/v1/auth/sessions/current", status_code=204)
def delete_session(user: Annotated[User, Depends(current_user)],
authorization: Annotated[str, Header()]):
token = authorization.partition(" ")[2]
with store.pool.connection() as db:
db.execute("DELETE FROM sessions WHERE token_hash=%s", (token_hash(token),))
return Response(status_code=204)
@app.get("/api/v1/users/me")
def get_current_user(user: Annotated[User, Depends(current_user)]):
return as_json(user)
@app.post("/api/v1/chats", status_code=201)
def create_chat(body: CreateChat, user: Annotated[User, Depends(current_user)]):
if user.id not in body.member_ids:
raise ApiProblem(400, "invalid_request", "Текущий пользователь должен быть участником")
with store.pool.connection() as db:
found = db.execute("SELECT id FROM users WHERE id=ANY(%s)", (body.member_ids,)).fetchall()
if len(found) != len(body.member_ids):
raise ApiProblem(400, "invalid_request", "Указан неизвестный участник")
row = db.execute("INSERT INTO chats(id,title) VALUES (%s,%s) RETURNING *",
(uuid.uuid4(), body.title)).fetchone()
with db.cursor() as cur:
cur.executemany("INSERT INTO chat_members(chat_id,user_id) VALUES (%s,%s)",
[(row["id"], member) for member in body.member_ids])
chat = store.chat(db, row["id"])
return as_json(chat) # COMMIT уже выполнен для чата и всех участников.
@app.get("/api/v1/chats")
def list_chats(
request: Request,
user: Annotated[User, Depends(current_user)],
limit: Annotated[int, Query(ge=1, le=100)] = 50,
cursor: Annotated[str | None, Query(min_length=1)] = None,
):
scope = f"chats:{user.id}"
after = page_parameters(request, scope, limit, cursor)
query = "SELECT c.* FROM chats c JOIN chat_members m ON m.chat_id=c.id WHERE m.user_id=%s"
params = [user.id]
if after is not None:
query += " AND (c.created_at,c.id)>(%s,%s)"
params.extend(after)
with store.pool.connection() as db:
rows = db.execute(query + " ORDER BY c.created_at,c.id LIMIT %s", params + [limit + 1]).fetchall()
chats = [store.chat(db, row["id"]) for row in rows]
return page(chats, limit, scope)
@app.get("/api/v1/chats/{chat_id}")
def get_chat(chat_id: uuid.UUID, user: Annotated[User, Depends(current_user)]):
return as_json(visible_chat(chat_id, user))
@app.post("/api/v1/chats/{chat_id}/messages", status_code=201)
def create_message(
request: Request,
chat_id: uuid.UUID,
body: CreateMessage,
user: Annotated[User, Depends(current_user)],
idempotency_key: Annotated[str | None, Header()] = None,
):
if (not idempotency_key or
not re.fullmatch(r"[A-Za-z0-9._:-]{1,128}", idempotency_key) or
len(request.headers.getlist("idempotency-key")) != 1):
raise ApiProblem(400, "invalid_request", "Нужен корректный Idempotency-Key")
visible_chat(chat_id, user) # Повтор тоже проверяет сессию и участие.
canonical = {'text': body.text}
if body.attachment_ids:
canonical['attachment_ids'] = [str(value) for value in body.attachment_ids]
payload = json.dumps(canonical, ensure_ascii=False, sort_keys=True,
separators=(",", ":"))
digest = hashlib.sha256(payload.encode()).hexdigest()
lock_scope = f"{user.id}:POST:{chat_id}:{idempotency_key}"
with store.pool.connection() as db:
# Общая блокировка в PostgreSQL, а не локальный Lock одной реплики.
# Коллизия хеша только сериализует независимые запросы; ключи сравниваются полностью.
db.execute("SELECT pg_advisory_xact_lock(hashtextextended(%s,0))", (lock_scope,))
previous = db.execute(
"SELECT * FROM message_requests WHERE user_id=%s AND chat_id=%s AND request_key=%s",
(user.id, chat_id, idempotency_key),
).fetchone()
if previous and previous["expires_at"] > utc_now():
if previous["body_hash"] != digest:
raise ApiProblem(409, "conflict", "Ключ уже использован с другим сообщением")
result = previous["response"]
else:
for attachment_id in body.attachment_ids:
found = db.execute('SELECT chat_id,status FROM attachments WHERE id=%s FOR KEY SHARE',
(attachment_id,)).fetchone()
if not found or found['chat_id'] != chat_id:
raise ApiProblem(404, 'not_found', 'Вложение недоступно')
if found['status'] not in {'queued','processing','ready'}:
raise ApiProblem(409, 'conflict', 'Вложение ещё недоступно')
if previous:
db.execute("DELETE FROM message_requests WHERE user_id=%s AND chat_id=%s AND request_key=%s",
(user.id, chat_id, idempotency_key))
row = db.execute(
"INSERT INTO messages(id,chat_id,sender_id,text) VALUES (%s,%s,%s,%s) RETURNING *",
(uuid.uuid4(), chat_id, user.id, body.text),
).fetchone()
for position, attachment_id in enumerate(body.attachment_ids):
db.execute('INSERT INTO message_attachments(message_id,attachment_id,position) VALUES (%s,%s,%s)',
(row['id'], attachment_id, position))
result = as_json(Message(**row, attachment_ids=body.attachment_ids))
db.execute(
"INSERT INTO message_requests(user_id,chat_id,request_key,body_hash,response,expires_at) "
"VALUES (%s,%s,%s,%s,%s,clock_timestamp()+interval '24 hours')",
(user.id, chat_id, idempotency_key, digest, Jsonb(result)),
)
# Сообщение и результат повтора зафиксированы одной транзакцией до ответа.
return result
@app.get("/api/v1/chats/{chat_id}/messages")
def list_messages(
request: Request,
chat_id: uuid.UUID,
user: Annotated[User, Depends(current_user)],
limit: Annotated[int, Query(ge=1, le=100)] = 50,
cursor: Annotated[str | None, Query(min_length=1)] = None,
):
visible_chat(chat_id, user)
scope = f"messages:{chat_id}"
after = page_parameters(request, scope, limit, cursor)
with store.pool.connection() as db:
messages = store.chat_messages(db, chat_id, limit, after)
return page(messages, limit, scope)
@app.post('/api/v1/chats/{chat_id}/attachments', status_code=202)
async def upload_attachment(request: Request, chat_id: uuid.UUID,
user: Annotated[User, Depends(current_user)], filename: str = Query()):
await run_in_threadpool(visible_chat, chat_id, user)
return await attachments.receive(request, store.pool, chat_id, user.id, filename)
def accessible_attachment(attachment_id, user):
with store.pool.connection() as db:
row = db.execute('SELECT a.* FROM attachments a JOIN chat_members m ON m.chat_id=a.chat_id '
'WHERE a.id=%s AND m.user_id=%s', (attachment_id, user.id)).fetchone()
if not row:
raise ApiProblem(404, 'not_found', 'Вложение недоступно')
return row
@app.get('/api/v1/attachments/{attachment_id}')
def attachment_metadata(attachment_id: uuid.UUID, user: Annotated[User, Depends(current_user)]):
row = accessible_attachment(attachment_id, user)
return attachments.public_attachment(row)
@app.get('/api/v1/attachments/{attachment_id}/content')
def attachment_content(attachment_id: uuid.UUID, user: Annotated[User, Depends(current_user)],
variant: str = Query('original')):
row = accessible_attachment(attachment_id, user)
if row['status'] != 'ready':
raise ApiProblem(409, 'conflict', 'Вложение ещё не готово или обработка завершилась ошибкой')
return attachments.download(row,variant)
+26
View File
@@ -0,0 +1,26 @@
"""Версионируемые миграции: один файл = одна атомарная транзакция."""
from pathlib import Path
import psycopg
from src.config import DATABASE_URL
def migrate():
with psycopg.connect(DATABASE_URL) as db:
# Миграции запускает отдельный сервис. Lock защищает от второго запуска оператором.
db.execute('SELECT pg_advisory_lock(20260002)')
db.execute('CREATE TABLE IF NOT EXISTS schema_migrations '
'(version text PRIMARY KEY, applied_at timestamptz DEFAULT now())')
db.commit()
for file in sorted(Path('migrations').glob('*.sql')):
with db.transaction():
applied = db.execute('SELECT 1 FROM schema_migrations WHERE version=%s',
(file.name,)).fetchone()
if not applied:
db.execute(file.read_text())
db.execute('INSERT INTO schema_migrations(version) VALUES (%s)', (file.name,))
print('Applied', file.name)
db.execute('SELECT pg_advisory_unlock(20260002)')
if __name__ == '__main__':
migrate()
+60
View File
@@ -0,0 +1,60 @@
"""S3-клиент с ограниченными credentials; ключи назначаются приложением."""
import boto3
from botocore.config import Config
from botocore.exceptions import ClientError
from src.config import S3_ENDPOINT, S3_REGION, S3_BUCKET, S3_ACCESS_KEY, S3_SECRET_KEY
PREFIX = 'originals/'
class ObjectStore:
def __init__(self):
self.client = boto3.client(
's3', endpoint_url=S3_ENDPOINT, region_name=S3_REGION,
aws_access_key_id=S3_ACCESS_KEY, aws_secret_access_key=S3_SECRET_KEY,
config=Config(connect_timeout=2, read_timeout=5, retries={'total_max_attempts': 1},
s3={'addressing_style': 'path'}, request_checksum_calculation='when_required',
response_checksum_validation='when_required'))
def ready(self):
self.client.list_objects_v2(Bucket=S3_BUCKET, Prefix=PREFIX, MaxKeys=1)
def put(self, file, key, size, mime, sha256, content_md5):
file.seek(0)
self.client.put_object(Bucket=S3_BUCKET, Key=key, Body=file, ContentLength=size,
ContentType=mime, Metadata={'sha256': sha256}, ContentMD5=content_md5)
def copy(self, source, target):
self.client.copy_object(Bucket=S3_BUCKET,Key=target,CopySource={'Bucket':S3_BUCKET,'Key':source})
def head(self, key):
try:
return self.client.head_object(Bucket=S3_BUCKET, Key=key)
except ClientError as exc:
if exc.response['Error']['Code'] in {'404', 'NoSuchKey', 'NotFound'}:
return None
raise
def get(self, key):
return self.client.get_object(Bucket=S3_BUCKET, Key=key)
def delete(self, key):
self.client.delete_object(Bucket=S3_BUCKET, Key=key)
def objects(self, prefix=PREFIX, counters=None):
pages = self.client.get_paginator('list_objects_v2')
for page in pages.paginate(Bucket=S3_BUCKET, Prefix=prefix):
if counters is not None:
counters['list_requests'] += 1
yield from page.get('Contents', [])
def lock_attachment(db, attachment_id, wait=True):
function = 'pg_advisory_lock' if wait else 'pg_try_advisory_lock'
return db.execute(f'SELECT {function}(hashtextextended(%s,0)) AS locked',
('attachment:' + str(attachment_id),)).fetchone()['locked']
def unlock_attachment(db, attachment_id):
db.execute('SELECT pg_advisory_unlock(hashtextextended(%s,0))',
('attachment:' + str(attachment_id),))
+213
View File
@@ -0,0 +1,213 @@
"""Отдельный consumer: обработка с lease, fencing и ack после устойчивого результата."""
from concurrent.futures import ThreadPoolExecutor
import base64
import hashlib
import json
import os
from pathlib import Path
import socket
import subprocess
import sys
import tempfile
import time
from typing import Literal
import uuid
from botocore.exceptions import ClientError
from pydantic import AwareDatetime,BaseModel,ConfigDict,Field,field_validator
from src import broker
from src.config import WORKER_CONCURRENCY,JOB_TIMEOUT,JOB_LEASE,MAX_UPLOAD_BYTES
from src.jobs import connection,event,retry_or_fail
from src.storage import ObjectStore,lock_attachment,unlock_attachment
from src.faults import checkpoint
class JobMessage(BaseModel):
model_config=ConfigDict(extra='forbid',strict=True)
schema_version:Literal[1]
job_id:uuid.UUID
type:Literal['attachment.process.v1']
attachment_id:uuid.UUID
pipeline_version:int=Field(ge=1)
attempt:int=Field(ge=1)
created_at:AwareDatetime
traceparent:str|None=Field(default=None,pattern=r'^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$')
tracestate:str|None=Field(default=None,max_length=512)
@field_validator('schema_version',mode='before')
@classmethod
def integer_schema_version(cls,value):
if type(value) is not int:raise ValueError('schema_version must be an integer')
return value
@field_validator('traceparent','tracestate',mode='before')
@classmethod
def trace_is_string_when_present(cls,value):
if not isinstance(value,str):raise ValueError('trace field must be a string')
return value
class PermanentError(Exception):pass
class JobTimeout(TimeoutError):pass
def check_deadline(deadline):
if time.monotonic()>=deadline:raise JobTimeout()
def reject(db,stream_id,raw,code):
db.execute('INSERT INTO broker_rejections(stream_id,sha256,error_code) VALUES (%s,%s,%s) ON CONFLICT DO NOTHING',
(stream_id,hashlib.sha256(raw.encode()).hexdigest(),code));db.commit()
def read_source(storage,job,attachment,file,deadline):
response=storage.get(job['staging_key']);body=response['Body'];size=0;digest=hashlib.sha256()
try:
if response['ContentLength']>MAX_UPLOAD_BYTES:raise PermanentError('source_mismatch')
while chunk:=body.read(64*1024):
check_deadline(deadline)
size+=len(chunk)
if size>MAX_UPLOAD_BYTES:raise PermanentError('source_mismatch')
file.write(chunk);digest.update(chunk)
finally:body.close()
if size!=attachment['size_bytes'] or digest.hexdigest()!=attachment['sha256']:
raise PermanentError('source_mismatch')
file.seek(0)
def put_file(storage,file,key,mime):
with Path(file).open('rb') as stream:
sha=hashlib.sha256();md5=hashlib.md5();size=0
while chunk:=stream.read(64*1024):sha.update(chunk);md5.update(chunk);size+=len(chunk)
storage.put(stream,key,size,mime,sha.hexdigest(),base64.b64encode(md5.digest()).decode())
def effects_exist(storage,attachment):
values=[(attachment['object_key'],attachment['size_bytes'],attachment['sha256'])]
for variant in attachment['variants']:
values.append((attachment['variant_keys'][variant['name']],variant['size_bytes'],variant['sha256']))
if len(values)!=4:return False
for key,size,sha in values:
head=storage.head(key)
if head is None or head['ContentLength']!=size or head.get('Metadata',{}).get('sha256')!=sha:return False
return True
def clean_ready_staging(db,storage,job):
if job['staged_deleted_at'] is not None:return
storage.delete(job['staging_key'])
db.execute('UPDATE jobs SET staged_deleted_at=clock_timestamp() WHERE id=%s',(job['id'],));db.commit()
def process(client,identifier,fields,alias):
raw=fields.get('job','')
try:message=JobMessage.model_validate_json(raw)
except ValueError:
with connection() as db:reject(db,identifier,raw,'invalid_job')
return True
with connection() as db:
job=db.execute('SELECT * FROM jobs WHERE id=%s',(message.job_id,)).fetchone();db.commit()
if not job:
reject(db,identifier,raw,'unknown_job');return True
if job['attachment_id']!=message.attachment_id or job['pipeline_version']!=message.pipeline_version:
reject(db,identifier,raw,'job_mismatch');return True
if not lock_attachment(db,job['attachment_id'],wait=False):
db.commit();return False
db.commit();storage=ObjectStore();token=None
try:
job=db.execute('SELECT * FROM jobs WHERE id=%s FOR UPDATE',(message.job_id,)).fetchone()
att=db.execute('SELECT * FROM attachments WHERE id=%s FOR UPDATE',(job['attachment_id'],)).fetchone()
if att['current_job_id']!=job['id'] or att['pipeline_version']!=job['pipeline_version']:
event(db,job['id'],'stale_ignored',current_version=att['pipeline_version'],stream_id=identifier)
db.commit();return True
if job['status']=='ready':
db.commit()
if not effects_exist(storage,att):return False
event(db,job['id'],'duplicate_ready',stream_id=identifier)
db.commit();clean_ready_staging(db,storage,job);return True
if job['status'] in {'failed','superseded'}:
event(db,job['id'],'terminal_ignored',stream_id=identifier);db.commit();return True
if job['status']=='processing':return False
if message.attempt!=job['attempts']+1:
event(db,job['id'],'old_attempt_ignored',attempt=message.attempt);db.commit();return True
if db.execute('SELECT available_at>clock_timestamp() AS waiting FROM jobs WHERE id=%s',(job['id'],)).fetchone()['waiting']:
return False
token=uuid.uuid4()
job=db.execute("UPDATE jobs SET status='processing',attempts=attempts+1,lease_token=%s,"
"lease_until=clock_timestamp()+%s*interval '1 second',updated_at=clock_timestamp() "
'WHERE id=%s RETURNING *',(token,JOB_LEASE,job['id'])).fetchone()
db.execute("UPDATE attachments SET status='processing',updated_at=clock_timestamp() WHERE id=%s",(att['id'],))
event(db,job['id'],'processing',attempt=job['attempts'],worker=alias,stream_id=identifier)
db.commit();checkpoint(job['id'],'before_effect')
if job['pipeline_version'] not in {1,2}:raise PermanentError('unsupported_pipeline')
deadline=time.monotonic()+JOB_TIMEOUT
with tempfile.TemporaryDirectory(prefix='image-job-') as directory:
source=Path(directory)/'original'
with source.open('w+b') as file:read_source(storage,job,att,file,deadline)
check_deadline(deadline)
result=subprocess.run([sys.executable,'-m','src.image_pipeline',str(source),directory,
str(job['pipeline_version'])],timeout=max(.1,deadline-time.monotonic()),capture_output=True)
if result.returncode==12:raise PermanentError('image_memory_limit')
if result.returncode:raise PermanentError('invalid_image')
variants=json.loads(Path(directory,'variants.json').read_text())
check_deadline(deadline)
put_file(storage,source,att['object_key'],att['content_type'])
checkpoint(job['id'],'after_original')
keys={}
for variant in variants:
file=variant.pop('file');key=f"variants/{att['id']}/v{job['pipeline_version']}/{file}"
check_deadline(deadline)
put_file(storage,Path(directory)/file,key,variant['content_type']);keys[variant['name']]=key
checkpoint(job['id'],'after_effects')
check_deadline(deadline)
# Fencing: опубликован может быть только результат текущей версии и lease-token.
fresh=db.execute("SELECT id FROM jobs WHERE id=%s AND status='processing' AND lease_token=%s FOR UPDATE",
(job['id'],token)).fetchone()
from psycopg.types.json import Jsonb
if not fresh:raise RuntimeError('Lease superseded')
updated=db.execute("UPDATE attachments SET status='ready',error_code=NULL,variants=%s,variant_keys=%s,"
'updated_at=clock_timestamp() WHERE id=%s AND current_job_id=%s AND pipeline_version=%s',
(Jsonb(variants),Jsonb(keys),att['id'],job['id'],job['pipeline_version']))
if updated.rowcount!=1:raise RuntimeError('Version superseded')
db.execute("UPDATE jobs SET status='ready',lease_token=NULL,lease_until=NULL,error_code=NULL,"
'updated_at=clock_timestamp() WHERE id=%s',(job['id'],))
event(db,job['id'],'ready',attempt=job['attempts'],pipeline_version=job['pipeline_version'])
db.commit();checkpoint(job['id'],'after_commit')
clean_ready_staging(db,storage,job)
return True
except Exception as exc:
db.rollback()
fresh=db.execute("SELECT * FROM jobs WHERE id=%s AND status='processing' AND lease_token=%s FOR UPDATE",
(job['id'],token)).fetchone() if token else None
if fresh:
code='processing_timeout' if isinstance(exc,(subprocess.TimeoutExpired,JobTimeout)) else 'storage_unavailable'
if isinstance(exc,PermanentError):code=str(exc)
if isinstance(exc,ClientError) and exc.response['Error']['Code'] in {'NoSuchKey','404'}:
code='staging_missing';exc=PermanentError(code)
if isinstance(exc,ClientError) and exc.response['Error']['Code'] in {'AccessDenied','InvalidAccessKeyId','SignatureDoesNotMatch'}:
code='storage_forbidden';exc=PermanentError(code)
retry_or_fail(db,fresh,code,permanent=isinstance(exc,PermanentError));db.commit()
return True # Следующая попытка уже устойчиво записана в outbox либо failed.
raise
finally:
storage.client.close();db.rollback();unlock_attachment(db,job['attachment_id']);db.commit()
def consume(index):
alias=f'{socket.gethostname()}:{uuid.uuid4().hex[:8]}:{index}';client=broker.connect()
while True:
try:
broker.ensure_group(client);delivery=broker.receive(client,alias)
if delivery and process(client,*delivery,alias):broker.acknowledge(client,delivery[0])
except Exception as exc:
print(json.dumps(dict(role='worker',worker=alias,status='retry',reason=type(exc).__name__)),flush=True)
time.sleep(1)
def main():
if not 1<=WORKER_CONCURRENCY<=4:raise SystemExit('WORKER_CONCURRENCY must be 1..4')
with ThreadPoolExecutor(max_workers=WORKER_CONCURRENCY) as pool:
list(pool.map(consume,range(WORKER_CONCURRENCY)))
if __name__=='__main__':main()
+89
View File
@@ -0,0 +1,89 @@
"""Контракт файлов: реальные изображения, лимиты, ACL и ключи сообщений."""
from concurrent.futures import ThreadPoolExecutor
import hashlib
import http.client
import io
from pathlib import Path
import struct
import sys
from urllib.parse import quote, urlsplit
import uuid
import zlib
from PIL import Image
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tests'))
from client import Client, arguments, check, run
def main():
args = arguments('Attachment negative and concurrent checks')
c = Client(args.base_url, args.ca_file)
alice, bob, eve, chat = c.bootstrap()
path = '/api/v1/chats/'+chat['id']+'/attachments?filename='
png = (Path(__file__).resolve().parents[1] / 'tests/fixtures/sample.png').read_bytes()
headers = {'Content-Type': 'image/png'}
att = c.call('POST', path+'sample.png', 202, actor=alice, raw=png, headers=headers, schema='Attachment')['json']
check('object_key' not in att and 'url' not in att, 'private storage details leaked')
for filename in ['../a.png', 'a\\b.png', 'x\x00.png', 'x\n.png', '..', ' ']:
c.call('POST', path+quote(filename, safe=''), 400, actor=alice, raw=png, headers=headers)
for data, mime in [(b'not an image', 'image/png'), (png[:30], 'image/png'),
(png[:-12], 'image/png'), (png, 'image/jpeg'), (png, 'application/octet-stream')]:
c.call('POST', path+'invalid.png', 415, actor=alice, raw=data, headers={'Content-Type': mime})
jpeg = io.BytesIO()
Image.new('RGB', (64, 64), 'red').save(jpeg, format='JPEG')
data = jpeg.getvalue()
j = c.call('POST', path+'real.jpg', 202, actor=alice, raw=data,
headers={'Content-Type': 'image/jpeg'}, schema='Attachment')['json']
j = c.wait_ready(alice,j)
downloaded = c.call('GET', '/api/v1/attachments/'+j['id']+'/content', actor=bob)
check(downloaded['bytes'] == data, 'JPEG bytes changed')
c.call('POST', path+'broken.jpg', 415, actor=alice, raw=data[:-20], headers={'Content-Type': 'image/jpeg'})
# Валидный IHDR заявляет >40M пикселей. Отклонение происходит до декодирования.
ihdr = struct.pack('>IIBBBBB', 9000, 5000, 8, 2, 0, 0, 0)
header = b'\x89PNG\r\n\x1a\n' + struct.pack('>I', len(ihdr)) + b'IHDR' + ihdr
header += struct.pack('>I', zlib.crc32(b'IHDR'+ihdr))
header += png[33:]
c.call('POST', path+'huge-pixels.png', 413, actor=alice, raw=header, headers=headers)
# Отправляем только headers заведомо большого файла: доказываем ранний byte limit.
base = urlsplit(c.base)
connection = http.client.HTTPConnection(base.hostname, base.port or 80, timeout=10)
connection.putrequest('POST', path+'too-big.png')
connection.putheader('Authorization', 'Bearer '+alice['token'])
connection.putheader('Content-Type', 'image/png')
connection.putheader('Content-Length', str(10485761))
connection.endheaders()
response = connection.getresponse()
check(response.status == 413, 'oversized body was not rejected before reading')
response.read(); connection.close()
c.call('POST', path+'outsider.png', 404, actor=eve, raw=png, headers=headers)
for suffix in ['', '/content']:
c.call('GET', '/api/v1/attachments/'+att['id']+suffix, 404, actor=eve)
ready = c.wait_ready(alice,att)
c.call('GET', '/api/v1/attachments/'+att['id']+'/content?variant=unknown', 404, actor=bob)
other_chat = c.call('POST', '/api/v1/chats', 201, actor=alice,
body={'title': 'Другой чат', 'member_ids': [alice['id']]}, schema='Chat')['json']
message_path = '/api/v1/chats/'+other_chat['id']+'/messages'
c.call('POST', message_path, 404, actor=alice, body={'text': '', 'attachment_ids': [att['id']]},
headers={'Idempotency-Key': uuid.uuid4().hex})
message_path = '/api/v1/chats/'+chat['id']+'/messages'
for ids, code in [([str(uuid.uuid4())], 404), ([att['id'], att['id']], 400), ([att['id']]*11, 400)]:
c.call('POST', message_path, code, actor=alice, body={'text': '', 'attachment_ids': ids},
headers={'Idempotency-Key': uuid.uuid4().hex})
key = uuid.uuid4().hex
def send(_):
return Client(args.base_url).message(bob, chat, '', key=key, attachments=[att['id']])
with ThreadPoolExecutor(max_workers=8) as pool:
replies = list(pool.map(send, range(16)))
check(all(r['json'] == replies[0]['json'] for r in replies), 'attachment replay created different messages')
check(len({r['headers']['X-Instance-Id'] for r in replies}) >= 2, 'attachment race did not cross replicas')
# Отсутствие attachment_ids и [] одинаковы и для хеша повтора.
text_key = uuid.uuid4().hex
text_message = c.message(alice, chat, 'Только текст', key=text_key)['json']
check(c.message(alice, chat, 'Только текст', key=text_key, attachments=[])['json'] == text_message,
'default [] changes key semantics')
check(att['sha256'] == hashlib.sha256(png).hexdigest(), 'wrong original checksum')
print('PASS: PNG/JPEG, bytes/pixels limits, filename/MIME, ACL, attachment message replay')
if __name__ == '__main__':
run(main)
+90
View File
@@ -0,0 +1,90 @@
"""Дополнения к публичному smoke. Не печатает и не сохраняет tokens."""
import base64
import concurrent.futures
import json
import sys
import time
from pathlib import Path
from uuid import uuid4
from urllib.parse import quote
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tests'))
from client import Client, arguments, check, run
def check_cursor_types(c, actor, path, cursor, schema):
check(bool(cursor), 'test requires a real pagination cursor')
payload = json.loads(base64.urlsafe_b64decode(cursor + '=' * (-len(cursor) % 4)))
c.call('GET', path + '?cursor=' + quote(cursor, safe=''), actor=actor, schema=schema)
invalid = []
for field in ['created_at', 'id']:
for value in [1, 1.5, None, True, [], {}, '', 'invalid']:
invalid.append({**payload, field: value})
invalid.extend([None, 1, True, [], 'cursor'])
for value in invalid:
encoded = base64.urlsafe_b64encode(json.dumps(value).encode()).decode().rstrip('=')
instances = set()
# Проверяем один и тот же cursor на обеих API за round-robin LB.
for _ in range(8):
response = c.call('GET', path + '?cursor=' + quote(encoded, safe=''), 400, actor=actor)
check(response['json']['error']['code'] == 'invalid_request', 'incorrect cursor error code')
instances.add(response['headers']['X-Instance-Id'])
if len(instances) >= 2:
break
check(len(instances) >= 2, 'invalid cursor was not checked on two API instances')
def main():
def configure(p):
p.add_argument('--expiry', action='store_true', help='API must run with TTL=2')
args = arguments('Student API checks', configure)
c = Client(args.base_url)
alice, bob, eve, chat = c.bootstrap()
if args.expiry:
time.sleep(2.2)
c.call('GET', '/api/v1/users/me', 401, actor=alice)
print('PASS: short TTL expiry')
return
registration = {'username': 'race_' + uuid4().hex[:12], 'display_name': 'Гонка',
'password': 'Synthetic-password-42'}
# Для гонки регистрируем оба допустимых исхода через urllib.
import urllib.request
import urllib.error
def register(_):
req = urllib.request.Request(c.base + '/api/v1/users',
data=json.dumps(registration).encode(),
headers={'Content-Type': 'application/json'})
try:
with urllib.request.urlopen(req, timeout=10) as response:
return response.status
except urllib.error.HTTPError as error:
return error.code
with concurrent.futures.ThreadPoolExecutor(max_workers=8) as executor:
codes = list(executor.map(register, range(8)))
check(codes.count(201) == 1 and codes.count(409) == 7, 'username race failed')
path = '/api/v1/chats/' + chat['id']
c.call('POST', '/api/v1/chats', 400, actor=alice,
body={'title': 'unknown member', 'member_ids': [alice['id'], str(uuid4())]})
for body in [{'text': 'x', 'sender_id': eve['id']}, {'text': 4}, {'text': ' '}]:
c.call('POST', path + '/messages', 400, actor=alice, body=body)
c.call('GET', path + '/messages?limit=true', 400, actor=alice)
c.call('GET', path + '/messages?cursor=not-a-cursor', 400, actor=alice)
for n in range(3):
c.message(alice, chat, 'read-after-write ' + str(n))
page = c.call('GET', path + '/messages?limit=1', actor=alice, schema='MessagePage')['json']
other = c.call('POST', '/api/v1/chats', 201, actor=alice,
body={'title': 'other', 'member_ids': [alice['id']]}, schema='Chat')['json']
c.call('GET', '/api/v1/chats/' + other['id'] + '/messages?cursor=' +
quote(page['next_cursor'], safe=''), 400, actor=alice)
check_cursor_types(c, alice, path + '/messages', page['next_cursor'], 'MessagePage')
chats = c.call('GET', '/api/v1/chats?limit=1', actor=alice, schema='ChatPage')['json']
check_cursor_types(c, alice, '/api/v1/chats', chats['next_cursor'], 'ChatPage')
history = c.call('GET', path + '/messages', actor=bob, schema='MessagePage')['json']['items']
check(len(history) == 3 and history[-1]['text'] == 'read-after-write 2', 'read-after-write failed')
c.call('DELETE', '/api/v1/auth/sessions/current', 204, actor=alice)
c.call('GET', '/api/v1/users/me', 401, actor=alice)
print('PASS: registration race, invalid input, cursor scope/types on two API, read-after-write, logout')
if __name__ == '__main__':
run(main)
+61
View File
@@ -0,0 +1,61 @@
"""Проверка реального rollback после вставки чата и первого участника."""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from uuid import uuid4
import psycopg
import os
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tests'))
from client import Client
from src.config import DATABASE_URL
from src.migrate import migrate
migrate()
migrate() # Повтор миграции не создаёт дубликаты.
with psycopg.connect(DATABASE_URL) as db:
user = db.execute('SELECT id FROM users LIMIT 1').fetchone()
assert user, 'Сначала выполните smoke, чтобы создать синтетического пользователя'
chat = uuid4()
try:
with db.transaction():
db.execute('INSERT INTO chats(id,title) VALUES (%s,%s)', (chat, 'rollback test'))
db.execute('INSERT INTO chat_members VALUES (%s,%s)', (chat, user[0]))
# FK прерывает составную операцию ПОСЛЕ двух успешных INSERT.
db.execute('INSERT INTO chat_members VALUES (%s,%s)', (chat, uuid4()))
except psycopg.errors.ForeignKeyViolation:
pass
else:
raise AssertionError('Expected foreign-key failure')
assert db.execute('SELECT count(*) FROM chats WHERE id=%s', (chat,)).fetchone()[0] == 0
assert db.execute('SELECT count(*) FROM chat_members WHERE chat_id=%s', (chat,)).fetchone()[0] == 0
assert db.execute('SELECT count(*) FROM schema_migrations').fetchone()[0] == 4
print('PASS: rollback of chat + members; migration reapplied twice')
c = Client(os.getenv('BASE_URL', 'http://localhost:8080'))
alice, bob, _, chat = c.bootstrap()
key = uuid4().hex
original = c.message(alice, chat, 'До истечения ключа', key=key)['json']
with psycopg.connect(DATABASE_URL) as db:
# Без ожидания суток: сдвигаем именно persisted expiry, а не clock приложения.
db.execute("UPDATE message_requests SET expires_at=now()-interval '1 second' "
"WHERE chat_id=%s AND request_key=%s", (chat['id'], key))
renewed = c.message(alice, chat, 'После истечения ключа', key=key)['json']
assert renewed['id'] != original['id']
with psycopg.connect(DATABASE_URL) as db:
assert db.execute('SELECT count(*) FROM message_requests WHERE chat_id=%s AND request_key=%s',
(chat['id'], key)).fetchone()[0] == 1
with psycopg.connect(DATABASE_URL) as db:
message = uuid4()
try:
with db.transaction():
db.execute('INSERT INTO messages(id,chat_id,sender_id,text) VALUES (%s,%s,%s,%s)',
(message, chat['id'], bob['id'], 'atomic rollback'))
# Ошибка сохранения результата должна откатить и сообщение.
db.execute("INSERT INTO message_requests VALUES (%s,%s,%s,%s,%s,now())",
(uuid4(), chat['id'], 'rollback', '0'*64, psycopg.types.json.Jsonb({})))
except psycopg.errors.ForeignKeyViolation:
pass
else:
raise AssertionError('Expected result-store failure')
assert db.execute('SELECT count(*) FROM messages WHERE id=%s', (message,)).fetchone()[0] == 0
print('PASS: persisted key expiry, atomic message/result rollback')
+38
View File
@@ -0,0 +1,38 @@
"""Отказы Redis и PostgreSQL; старые токены и подтверждения после восстановления."""
import os
from pathlib import Path
import sys
import time
import urllib.request
import urllib.error
sys.path.insert(0,str(Path(__file__).resolve().parents[1]))
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'tests'))
from client import Client
from scripts.stack import command,wait,save
base=os.getenv('BASE_URL','http://localhost:8080');c=Client(base,timeout=15)
alice,bob,_,chat=c.bootstrap();message=c.message(alice,chat,'До отказов')['json']
att,data=c.attachment(alice,chat);att=c.wait_ready(alice,att)
results={}
try:
command(['docker','compose','stop','cache'])
for _ in range(6):c.call('GET','/api/v1/users/me',actor=alice,schema='User')
c.message(alice,chat,'Без кеша');results['redis']='PASS'
finally:command(['docker','compose','up','-d','--wait','cache'])
try:
command(['docker','compose','stop','db']);time.sleep(4)
codes=[]
for path in ['/health/ready','/api/v1/users/me']:
request=urllib.request.Request(base+path,headers={'Authorization':'Bearer '+alice['token']})
try:
with urllib.request.urlopen(request,timeout=10) as response:codes.append(response.status)
except urllib.error.HTTPError as exc:codes.append(exc.code)
assert codes==[503,503];results['postgres']=codes
finally:
command(['docker','compose','up','-d','--wait','db']);wait(2,base)
page=c.call('GET','/api/v1/chats/'+chat['id']+'/messages',actor=bob,schema='MessagePage')['json']
assert message in page['items']
assert c.call('GET','/api/v1/attachments/'+att['id']+'/content',actor=bob)['bytes']==data
results['old_token_message_original_preserved']=True
save('dependencies.json',results)
print('PASS: Redis fallback, PostgreSQL 503 and recovery, old token/message/original preserved')
+43
View File
@@ -0,0 +1,43 @@
"""Останавливаем именно API, принявшую upload, и скачиваем оригинал другой репликой."""
import hashlib
import os
from pathlib import Path
import sys
import time
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tests'))
from client import Client, Failure
from scripts.stack import stop, wait, save, command
base = os.getenv('BASE_URL', 'http://localhost:8080')
c = Client(base, timeout=3)
alice, bob, _, chat = c.bootstrap()
data = (Path(__file__).resolve().parents[1] / 'tests/fixtures/sample.png').read_bytes()
response = c.call('POST', '/api/v1/chats/'+chat['id']+'/attachments?filename=failover.png',
202, actor=alice, raw=data, headers={'Content-Type': 'image/png'}, schema='Attachment')
target = response['headers']['X-Instance-Id']
att = c.wait_ready(alice,response['json'])
c.message(alice, chat, '', attachments=[att['id']])
started = time.monotonic()
errors = 0
try:
stopped = stop(target)
while True:
try:
downloaded = c.call('GET', '/api/v1/attachments/'+att['id']+'/content', actor=bob)
alias = downloaded['headers']['X-Instance-Id']
assert alias != target and downloaded['bytes'] == data
assert hashlib.sha256(downloaded['bytes']).hexdigest() == att['sha256']
break
except Failure:
errors += 1
if time.monotonic()-started > 10:
raise
time.sleep(.2)
save('attachment_failover.json', dict(status='PASS', uploader=target, downloader=alias,
recovery_seconds=time.monotonic()-started, failed_attempts=errors,
original_size=len(data), checksum_verified=True, stop=stopped))
print('PASS: upload API stopped, original downloaded by other API with existing token')
finally:
command(['docker', 'compose', 'start', 'api'])
wait(2, base)
+58
View File
@@ -0,0 +1,58 @@
"""Проверки общего результата повтора через LB и несколько API."""
from concurrent.futures import ThreadPoolExecutor
import json
from pathlib import Path
import sys
import uuid
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tests'))
from client import Client, arguments, check, run
def main():
args = arguments('Shared idempotency through LB')
c = Client(args.base_url, args.ca_file)
alice, bob, eve, chat = c.bootstrap()
key = uuid.uuid4().hex
text = 'Один результат для конкурентных повторов'
def send(_):
return Client(args.base_url, args.ca_file).message(alice, chat, text, key=key)
with ThreadPoolExecutor(max_workers=16) as pool:
responses = list(pool.map(send, range(32)))
first = responses[0]['json']
check(all(r['json'] == first and r['status'] == 201 for r in responses), 'replay differs')
instances = {r['headers']['X-Instance-Id'] for r in responses}
check(len(instances) >= 2, 'race did not cross API replicas')
path = '/api/v1/chats/' + chat['id'] + '/messages'
history = c.call('GET', path, actor=bob, schema='MessagePage')['json']['items']
check(len(history) == 1 and history[0] == first, 'concurrent replay created duplicates')
c.call('POST', path, 409, body={'text': 'Другой текст'}, actor=alice,
headers={'Idempotency-Key': key})
for invalid in ['', 'bad key', 'a' * 129]:
c.call('POST', path, 400, body={'text': text}, actor=alice,
headers={'Idempotency-Key': invalid})
c.call('POST', path, 400, body={'text': text}, actor=alice)
# Тот же ключ независим для другого пользователя и другого чата.
other = c.message(bob, chat, text, key=key)['json']
check(other['id'] != first['id'], 'key scope must include user')
chat2 = c.call('POST', '/api/v1/chats', 201, actor=alice,
body={'title': 'Second', 'member_ids': [alice['id']]}, schema='Chat')['json']
check(c.message(alice, chat2, text, key=key)['json']['id'] != first['id'], 'key scope must include chat')
# Пробелы JSON не изменяют смысл текста и не должны менять результат.
replay = c.call('POST', path, 201, actor=alice, raw=json.dumps({'text': text}, indent=2).encode(),
headers={'Content-Type': 'application/json', 'Idempotency-Key': key}, schema='Message')
check(replay['json'] == first, 'JSON formatting changed idempotency')
c.call('POST', path, 404, actor=eve, body={'text': text}, headers={'Idempotency-Key': key})
c.call('DELETE', '/api/v1/auth/sessions/current', 204, actor=alice)
c.call('POST', path, 401, actor=alice, body={'text': text}, headers={'Idempotency-Key': key})
result = dict(status='PASS', concurrent_requests=32, observed_instances=len(instances),
messages_after_race=len(history), conflict=409, invalid_key=400, logout=401)
Path('evidence').mkdir(exist_ok=True)
Path('evidence/idempotency.json').write_text(json.dumps(result, indent=2))
print('PASS: shared idempotency, scope, conflict and auth on replay')
if __name__ == '__main__':
run(main)
+183
View File
@@ -0,0 +1,183 @@
"""Сценарии pipeline внутри сети стенда. Приватный контекст только в stdin/stdout оператора."""
import argparse
import base64
from datetime import datetime
import hashlib
import io
import json
import os
from pathlib import Path
import sys
import time
import uuid
sys.path.insert(0,str(Path(__file__).resolve().parents[1]))
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'tests'))
from client import Client,check
from src.jobs import connection,inspect,payload,event,replay,new_version
from src.broker import connect,publish,STREAM,GROUP
from src.storage import ObjectStore
from src.cleanup import run as cleanup
def main():
p=argparse.ArgumentParser();p.add_argument('mode',choices=['config','create','queued','wait','snapshot','duplicate','arm',
'fault-fired','unready','published','drained','audit','missing-stage','restore-stage','replay','version','failed','cleanup','privacy','invalid-job'])
p.add_argument('--phase');p.add_argument('--state',default='ready');p.add_argument('--timeout',type=int,default=100)
args=p.parse_args();ctx=json.load(sys.stdin)
if args.mode=='config':
from src.config import JOB_MAX_ATTEMPTS,JOB_TIMEOUT,JOB_LEASE,STAGING_RETENTION,MAX_PENDING_JOBS,WORKER_CONCURRENCY
return dict(job_max_attempts=JOB_MAX_ATTEMPTS,job_timeout_seconds=JOB_TIMEOUT,job_lease_seconds=JOB_LEASE,
staging_retention_seconds=STAGING_RETENTION,max_pending_jobs=MAX_PENDING_JOBS,
worker_concurrency=WORKER_CONCURRENCY,prefetch_per_consumer=1)
c=Client(os.getenv('BASE_URL','http://localhost:8080'),timeout=15)
fixture=(Path(__file__).resolve().parents[1]/'tests/fixtures/sample.png').read_bytes()
storage=ObjectStore()
if args.mode=='create':
alice,bob,_,chat=c.bootstrap()
response=c.call('POST','/api/v1/chats/'+chat['id']+'/attachments?filename=pipeline.png',202,actor=alice,
raw=fixture,headers={'Content-Type':'image/png'},schema='Attachment')
att=response['json'];assert att['status']=='queued'
with connection() as db:
job=db.execute('SELECT * FROM jobs WHERE attachment_id=%s',(att['id'],)).fetchone()
assert storage.head(job['staging_key']) and job['status']=='queued'
return dict(actor=alice,reader=bob,chat=chat,attachment=att,job_id=str(job['id']),uploader=response['headers']['X-Instance-Id'])
info=inspect(ctx['job_id']);job=info['job'];att=info['attachment']
path='/api/v1/attachments/'+str(job['attachment_id'])
if args.mode=='queued':
result=c.call('GET',path,actor=ctx['actor'],schema='Attachment')['json'];assert result['status']=='queued'
c.call('GET',path+'/content',409,actor=ctx['reader'])
c.message(ctx['actor'],ctx['chat'],'',attachments=[str(job['attachment_id'])])
c.message(ctx['actor'],ctx['chat'],'Worker выключен, сообщения работают')
return dict(status='PASS',attachment_id=str(job['attachment_id']),job_id=ctx['job_id'],accepted_status=202,content_status=409)
if args.mode in {'wait','fault-fired'}:
deadline=time.monotonic()+args.timeout
while time.monotonic()<deadline:
info=inspect(ctx['job_id'])
if args.mode=='fault-fired':
if any(r['phase']==args.phase and r['fired_at'] is not None for r in info['faults']):return dict(status='PASS',phase=args.phase)
elif info['job']['status']==args.state:return dict(status='PASS',state=args.state,attempts=info['job']['attempts'])
time.sleep(.2)
raise AssertionError('Pipeline deadline exceeded: '+args.mode)
if args.mode=='unready':
import urllib.request,urllib.error
codes=[]
for suffix in ['/health/ready',path+'/content']:
request=urllib.request.Request(c.base+suffix,headers={'Authorization':'Bearer '+ctx['actor']['token']})
try:
with urllib.request.urlopen(request,timeout=10) as response:codes.append(response.status)
except urllib.error.HTTPError as exc:codes.append(exc.code)
assert codes==[503,503],codes
return dict(status='PASS',readiness_and_content=codes)
if args.mode=='audit':return info
if args.mode in {'published','drained'}:
client=connect();deadline=time.monotonic()+args.timeout
try:
while time.monotonic()<deadline:
if args.mode=='published':
current=inspect(ctx['job_id']);ids=[r['stream_id'] for r in current['outbox'] if r['published_at']]
if ids and all(client.xrange(STREAM,identifier,identifier) for identifier in ids):
return dict(status='PASS',stream_ids=ids)
else:
ids=ctx['stream_ids'];last=max(tuple(map(int,x.split('-'))) for x in ids)
groups=client.xinfo_groups(STREAM);group=next(r for r in groups if r['name']==GROUP)
delivered=tuple(map(int,group['last-delivered-id'].split('-')))
pending={r['message_id'] for r in client.xpending_range(STREAM,GROUP,'-','+',10000)}
if delivered>=last and not pending.intersection(ids):return dict(status='PASS',acked=len(ids))
time.sleep(.2)
finally:client.close()
raise AssertionError('Broker state deadline exceeded')
if args.mode=='arm':
with connection() as db:
db.execute('INSERT INTO pipeline_faults(job_id,phase) VALUES (%s,%s) ON CONFLICT (job_id,phase) DO UPDATE SET fired_at=NULL',
(ctx['job_id'],args.phase))
return dict(armed=True,phase=args.phase)
if args.mode=='snapshot':
current=c.call('GET',path,actor=ctx['reader'],schema='Attachment')['json']
assert current['status']=='ready' and current['error_code'] is None
content=c.call('GET',path+'/content',actor=ctx['reader'])['bytes']
assert content==fixture
variants={v['name']:v for v in current['variants']};assert set(variants)=={'thumbnail','crop','optimized'}
digests={}
for name,meta in variants.items():
data=c.call('GET',path+'/content?variant='+name,actor=ctx['reader'])['bytes']
assert len(data)==meta['size_bytes'] and hashlib.sha256(data).hexdigest()==meta['sha256']
digests[name]=meta['sha256']
keys=[]
for prefix in ['originals/','variants/']:
keys.extend(r['Key'] for r in storage.objects(prefix+str(job['attachment_id'])+'/'))
expected=1+3
# После новой версии прежние объекты остаются для аудита; текущий набор ровно 4.
current_keys=[k for k in keys if '/v'+str(att['pipeline_version'])+'/' in k]
assert len(current_keys)==expected and len(set(current_keys))==expected
info=inspect(ctx['job_id'])
assert info['job']['status']=='ready' and info['attachment']['current_job_id']==job['id']
assert len([r for r in info['events'] if r['event']=='ready'])==1
deadline=time.monotonic()+5
while storage.head(info['job']['staging_key']) is not None and time.monotonic()<deadline:time.sleep(.1)
assert storage.head(info['job']['staging_key']) is None,'Staging not cleaned after ready'
return dict(status='PASS',attachment=current,job_id=ctx['job_id'],pipeline_version=att['pipeline_version'],
attempts=info['job']['attempts'],current_keys=sorted(current_keys),all_final_keys=sorted(keys),
variants_sha256=digests,original_sha256=hashlib.sha256(content).hexdigest(),
ready_commits=1,staging_deleted=True,queued_to_ready_seconds=round((datetime.fromisoformat(current['updated_at'].replace('Z','+00:00'))-job['created_at']).total_seconds(),6),
events=info['events'],outbox=info['outbox'])
if args.mode=='duplicate':
client=connect()
try:
result=[]
for _ in range(ctx.get('copies',1)):
result.append(publish(client,payload(job,ctx.get('attempt',max(1,job['attempts'])))))
finally:client.close()
return dict(stream_ids=result)
if args.mode=='invalid-job':
client=connect();bad=payload(job,max(1,job['attempts']));bad['url']='http://not-allowed.invalid/'
try:identifier=publish(client,bad)
finally:client.close()
deadline=time.monotonic()+10
while time.monotonic()<deadline:
with connection() as db:
row=db.execute('SELECT error_code FROM broker_rejections WHERE stream_id=%s',(identifier,)).fetchone()
if row:return dict(status='PASS',error_code=row['error_code'])
time.sleep(.2)
raise AssertionError('Invalid broker message not rejected')
if args.mode=='missing-stage':
storage.delete(job['staging_key']);return dict(deleted=True)
if args.mode=='restore-stage':
storage.put(io.BytesIO(fixture),job['staging_key'],len(fixture),'image/png',hashlib.sha256(fixture).hexdigest(),
base64.b64encode(hashlib.md5(fixture).digest()).decode())
return dict(restored=True)
if args.mode=='replay':return replay(job['id'])
if args.mode=='version':
result=new_version(job['attachment_id'],ctx.get('version',2))
return dict(ctx,job_id=result['job_id'])
if args.mode=='failed':
failed=c.call('GET',path,actor=ctx['reader'],schema='Attachment')['json']
assert failed['status']=='failed' and failed['error_code']
c.call('GET',path+'/content',409,actor=ctx['reader'])
c.call('POST','/api/v1/chats/'+ctx['chat']['id']+'/messages',409,actor=ctx['actor'],
body={'text':'','attachment_ids':[str(job['attachment_id'])]},headers={'Idempotency-Key':uuid.uuid4().hex})
return dict(status='PASS',error_code=failed['error_code'],attempts=job['attempts'],events=info['events'])
if args.mode=='cleanup':
# Вызывается при остановленном worker: текущий queued не должен быть удалён.
old_key='staging/'+str(uuid.uuid4())+'/'+str(uuid.uuid4())
def put(key):storage.put(io.BytesIO(fixture),key,len(fixture),'image/png',hashlib.sha256(fixture).hexdigest(),
base64.b64encode(hashlib.md5(fixture).digest()).decode())
put(old_key);time.sleep(3.2)
fresh_key='staging/'+str(uuid.uuid4())+'/'+str(uuid.uuid4());put(fresh_key)
dry=cleanup(2,False);assert storage.head(old_key)
applied=cleanup(2,True)
assert storage.head(old_key) is None and storage.head(fresh_key) and storage.head(job['staging_key'])
storage.delete(fresh_key)
return dict(status='PASS',orphan_removed=True,fresh_and_queued_preserved=True,dry_run=dry,apply=applied)
if args.mode=='privacy':
import urllib.request,urllib.error
from src.config import S3_ENDPOINT,S3_BUCKET
try:urllib.request.urlopen(S3_ENDPOINT+'/'+S3_BUCKET+'/'+att['object_key'],timeout=5)
except urllib.error.HTTPError as exc:assert exc.code==403
else:raise AssertionError('Public bucket')
return dict(status='PASS',anonymous_get=403)
if __name__=='__main__':
result=main()
print(json.dumps(result,ensure_ascii=False,default=str))
+87
View File
@@ -0,0 +1,87 @@
#!/usr/bin/env python3
"""Black-box grading evidence beyond the public smoke test."""
from concurrent.futures import ThreadPoolExecutor
import json
import sys
import uuid
from pathlib import Path
from urllib.parse import quote
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "tests"))
from client import Client, arguments, check, run # noqa: E402
def collect_messages(client, actor, chat, page_size=17):
items = []
cursor = None
while True:
path = f"/api/v1/chats/{chat['id']}/messages?limit={page_size}"
if cursor:
path += "&cursor=" + quote(cursor, safe="")
page = client.call("GET", path, actor=actor, schema="MessagePage")["json"]
items.extend(page["items"])
cursor = page["next_cursor"]
if cursor is None:
return items
def main():
args = arguments("Student negative, pagination and concurrency tests")
client = Client(args.base_url, args.ca_file)
alice, bob, outsider, chat = client.bootstrap()
client.call(
"POST",
"/api/v1/users",
400,
raw=b'{"username":',
headers={"Content-Type": "application/json"},
)
client.call(
"POST",
"/api/v1/users",
415,
raw=b'{"username":"wrong_media","display_name":"Wrong"}',
headers={"Content-Type": "text/plain"},
)
client.call("POST", "/api/v1/users", 409, body=alice["registration"])
client.call(
"POST",
f"/api/v1/chats/{chat['id']}/messages",
400,
actor=alice,
body={"text": " \t"},
)
client.call("GET", f"/api/v1/chats/{chat['id']}", 404, actor=outsider)
prefix = "race-" + uuid.uuid4().hex + "-"
def send(worker_id):
local = Client(args.base_url, args.ca_file)
return [
local.message(alice, chat, f"{prefix}{worker_id}-{index}")["json"]
for index in range(10)
]
with ThreadPoolExecutor(max_workers=10) as pool:
created = [message for batch in pool.map(send, range(10)) for message in batch]
check(len(created) == 100, "not all concurrent requests succeeded")
check(len({message["id"] for message in created}) == 100, "duplicate message ids returned")
history = collect_messages(client, bob, chat)
concurrent_history = [message for message in history if message["text"].startswith(prefix)]
check(len(concurrent_history) == 100, "history does not contain exactly 100 concurrent messages")
check(len({message["id"] for message in concurrent_history}) == 100, "history contains duplicates")
check(
history == sorted(history, key=lambda message: (message["created_at"], uuid.UUID(message["id"]).int)),
"multi-page history is out of order",
)
print("PASS: malformed JSON/media type, duplicate username, blank message, outsider access, pagination")
print("PASS: 10 clients created exactly 100 unique messages")
if __name__ == "__main__":
run(main)
+47
View File
@@ -0,0 +1,47 @@
"""Проверяем реальные форматы, EXIF orientation, alpha/white, размеры и метаданные."""
import hashlib
import io
from pathlib import Path
import sys
from PIL import Image
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'tests'))
from client import Client,arguments,check,run
def main():
args=arguments('Image pipeline variants');c=Client(args.base_url,args.ca_file,timeout=30)
alice,bob,eve,chat=c.bootstrap()
cases=[]
image=Image.new('RGBA',(320,200),(255,0,0,0));out=io.BytesIO();image.save(out,format='PNG');image.close()
cases.append(('alpha.png',out.getvalue(),'image/png',(256,160),(320,200)))
image=Image.new('RGB',(32,20),'green');out=io.BytesIO();image.save(out,format='PNG');image.close()
cases.append(('small.png',out.getvalue(),'image/png',(32,20),(32,20)))
image=Image.new('RGB',(320,200),'blue');exif=Image.Exif();exif[274]=6;out=io.BytesIO()
image.save(out,format='JPEG',exif=exif);image.close()
cases.append(('orientation.jpg',out.getvalue(),'image/jpeg',(160,256),(200,320)))
for filename,data,mime,thumb_size,optimized_size in cases:
att=c.call('POST','/api/v1/chats/'+chat['id']+'/attachments?filename='+filename,202,actor=alice,
raw=data,headers={'Content-Type':mime},schema='Attachment')['json']
check(att['status']=='queued','202 must carry queued snapshot')
c.message(alice,chat,'',attachments=[att['id']])
att=c.wait_ready(alice,att)
check(att['error_code'] is None,'ready has error')
check(c.call('GET','/api/v1/attachments/'+att['id']+'/content',actor=bob)['bytes']==data,'original changed')
variants={v['name']:v for v in att['variants']}
check(set(variants)=={'thumbnail','crop','optimized'},'missing variants')
for name,size,fmt,mime in [('thumbnail',thumb_size,'JPEG','image/jpeg'),('crop',(128,128),'JPEG','image/jpeg'),
('optimized',optimized_size,'WEBP','image/webp')]:
response=c.call('GET','/api/v1/attachments/'+att['id']+'/content?variant='+name,actor=bob)
content=response['bytes'];meta=variants[name]
check(response['headers'].get_content_type()==mime,'incorrect variant Content-Type')
check(len(content)==meta['size_bytes'] and hashlib.sha256(content).hexdigest()==meta['sha256'],'variant checksum')
with Image.open(io.BytesIO(content)) as result:
result.load();check(result.format==fmt and result.size==size,'variant format/size')
check((meta['width'],meta['height'])==size,'metadata dimensions')
check(not result.getexif(),'EXIF leaked into variant')
if filename=='alpha.png':check(all(v>=245 for v in result.convert('RGB').getpixel((0,0))),'alpha not composited on white')
c.call('GET','/api/v1/attachments/'+att['id']+'/content?variant='+name,404,actor=eve)
print('PASS: thumbnail/crop/WebP bytes, sizes, EXIF orientation, white alpha, no upscaling, ACL')
if __name__=='__main__':run(main)