- evidence/s3: bootstrap, privacy (make s3_check), gRPC without token, restart and SIGKILL, client failures, memory of 20 concurrent uploads - evidence/tests: failure_checks with own S3, test_isolated prefix cleanup (red tests: no attachment_ids until attachments) - REPORT.md: S3 role, services table, bootstrap, readiness dependencies, skeleton S3_* names, evidence rows, limitations - refine expected-red counts in tasks, design and PLAN Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6.2 KiB
6.2 KiB
Клиент S3 приложения: операции, отказы, отказ в учётных данных
- Дата: 2026-10-20, 17:15–17:16 UTC.
- Commit:
2e997f9. - Стенд:
make run_docker, проектmtusi-lab4. Клиент запущен в консоли (uv run python, настройки из.envиconfig.tomlпо умолчанию):127.0.0.1:8334, bucketmessenger,[s3] timeout_seconds5,connect_timeout_seconds1, без повторов. - Скрипт
probe_client.py(scratchpad) вызываетsrc.infra.s3(ObjectStorage) и docker compose (pause,stop,startсервисаs3). - Спек
object-storage: «Клиент хранилища в приложении» — «S3 остановлен», «S3 завис», «S3 вернулся», «Объекта нет», «Учётные данные отклонены»;service-logging: «Обращение к S3». Design changes3-storage, решение 7. - Hostname машины в поле
instance_idзаменён на<host>.
1. Операции
$ uv run python probe_client.py ops
put 3 MiB: ok in 139 ms
head: ok in 3 ms
head: size=3145745 content_type=image/png
open: size=3145745 content_type=image/png
open+read: ok in 63 ms
sha256 equal: True
delete: ok in 2 ms
head missing -> None
open missing: StoredObjectMissing in 2 ms
delete missing: ok in 1 ms
Отсутствующий объект отличается от недоступности: head → None, open
→ StoredObjectMissing, delete → не ошибка.
2. S3 завис, остановлен, вернулся — без перезапуска клиента
$ uv run python probe_client.py outage
healthy put: ok in 15 ms
timeout_seconds=5.0
{"event": "Object storage is unavailable", "instance_id": "<host>", "module": "object_storage", "operation": "put_object", "endpoint": "127.0.0.1:8334", "bucket": "messenger", "key": "messenger/probe/outage", "duration_ms": 5003, "error_type": "TimeoutError", "level": "warning", "timestamp": "2026-10-20T17:16:00.590525Z", "filename": "client.py", "lineno": 348, "func_name": "_failure"}
paused put: ObjectStorageUnavailable in 5008 ms
{"event": "Object storage is unavailable", "instance_id": "<host>", "module": "object_storage", "operation": "head_object", "endpoint": "127.0.0.1:8334", "bucket": "messenger", "key": "messenger/probe/outage", "duration_ms": 5005, "error_type": "TimeoutError", "level": "warning", "timestamp": "2026-10-20T17:16:05.598635Z", "filename": "client.py", "lineno": 348, "func_name": "_failure"}
paused head: ObjectStorageUnavailable in 5007 ms
unpaused put: ok in 9 ms
docker compose stop s3: 15.6 s
{"event": "Object storage is unavailable", "instance_id": "<host>", "module": "object_storage", "operation": "put_object", "endpoint": "127.0.0.1:8334", "bucket": "messenger", "key": "messenger/probe/outage", "duration_ms": 7, "error_type": "EndpointConnectionError", "level": "warning", "timestamp": "2026-10-20T17:16:21.444762Z", "filename": "client.py", "lineno": 348, "func_name": "_failure"}
stopped put: ObjectStorageUnavailable in 8 ms
{"event": "Object storage is unavailable", "instance_id": "<host>", "module": "object_storage", "operation": "head_object", "endpoint": "127.0.0.1:8334", "bucket": "messenger", "key": "messenger/probe/outage", "duration_ms": 2, "error_type": "EndpointConnectionError", "level": "warning", "timestamp": "2026-10-20T17:16:21.447111Z", "filename": "client.py", "lineno": 348, "func_name": "_failure"}
stopped head: ObjectStorageUnavailable in 2 ms
started put: ok in 18 ms
started delete: ok in 7 ms
- Сервер заморожен (
docker pause): вызов обрывается сроком через 5,007–5,008 с при сроке 5 с, повторов нет. - Сервер остановлен: отказ соединения за 2–8 мс, это меньше 0,1 с.
- После
unpauseиstartследующий вызов проходит тем же клиентом, без пересоздания.
3. Неверный секрет — 503 и одна запись error
$ uv run python probe_client.py wrong-secret
{"event": "Object storage rejected credentials", "instance_id": "<host>", "module": "object_storage", "error_code": "SignatureDoesNotMatch", "operation": "put_object", "endpoint": "127.0.0.1:8334", "bucket": "messenger", "key": "messenger/probe/wrong", "duration_ms": 13, "error_type": "ClientError", "level": "error", "timestamp": "2026-10-20T17:16:27.071569Z", "func_name": "_failure", "lineno": 332, "filename": "client.py"}
wrong secret put: ObjectStorageUnavailable in 13 ms
ObjectStorageUnavailable — наследник ServiceUnavailable: таблица
src/api/errors.py отдаёт на него 503 unavailable.
$ uv run python -c "from src.api.errors import DOMAIN_ERRORS; from src.core.exceptions import ObjectStorageUnavailable as E; print(next((c.__name__, DOMAIN_ERRORS[c]) for c in E.__mro__ if c in DOMAIN_ERRORS))"
('ServiceUnavailable', (503, <ErrorCode.UNAVAILABLE: 'unavailable'>))
4. Секретов в журнале нет
Значения пяти секретов S3 из .env (административные ключ и секрет, ключ
подписи, ключ и секрет API) проверены grep -F по выводу трёх прогонов:
secret/key values found in client logs: 0
В apply тем же способом проверен журнал make run_dev, к пяти значениям
добавлены пароли PostgreSQL и Valkey: 0 совпадений. Запись старта:
{"event": "Started API", "instance_id": "<host>", "module": "startup", "host": "127.0.0.1", "port": 8080, "run_mode": "<RunModeEnum.CONSOLE: 'console'>", "database_host": "127.0.0.1", "database_port": 5433, "database_name": "messenger", "cache_host": "127.0.0.1", "cache_port": 6380, "s3_host": "127.0.0.1", "s3_port": 8334, "s3_bucket": "messenger", "level": "info", ...}
Логгеры botocore, aiobotocore и aiohttp стоят на WARNING
(src/infra/logger.py): заголовок Authorization с подписью в журнал не
попадает.