Split the S3 keys of the API and the reconciler, drop root from one-offs

The API key now has only GetObject, PutObject and DeleteObject on the
attachment objects: the server never lists the bucket, never runs
multipart uploads and has its region set. The reconciler gets its own
user messenger-reconciler with ListBucket, GetObject and DeleteObject,
created by s3-init from a secret of its own, so the API replicas can no
longer list the bucket. The cost seeding writes objects and therefore
runs in a one-off API container under the API key. s3-check proves the
API key cannot list and checks the reconciler key; its snapshot drops
dated fields with a JSON filter instead of grep, which left a dangling
comma, and its first line carries the date and the commit.

s3-init and s3-cli run as uid 65534, and migrate and reconciler get an
init process, so SIGTERM reaches python and docker stop ends a pass in
a fraction of a second instead of waiting for SIGKILL. limits.py and CI
check the users of the one-off services. Stack tests move a 3 MiB file
up and down through the balancer at 256 and 192 KiB/s, longer than the
request timeout, and check 401 before the declared size.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V1d3RLHNBBMA6UqBLLJv27
This commit is contained in:
Artyom
2026-10-30 08:53:39 +03:00
co-authored by Claude Opus 5.5
parent 54099e1da3
commit 2891b37e75
13 changed files with 234 additions and 48 deletions
@@ -1,18 +1,18 @@
## 1. Платформа
- [ ] 1.1 Конвейер: guard раньше проверки объявленного `Content-Length`
- [ ] 1.2 Конвейер: дедлайн с минимальной скоростью передачи для `receive`/`send` приложения; `MIN_TRANSFER_RATE_BYTES` в `TransportSettings`, `main.py`, `compose.yaml`, `.env.example`
- [ ] 1.3 Проверка группы: `make lint`; API-тесты: upload без токена с `Content-Length` больше лимита → `401`; медленный идущий upload и скачивание дольше таймаута → `201`/`200`; тело ползёт медленнее порога → `503`
- [x] 1.1 Конвейер: guard раньше проверки объявленного `Content-Length`
- [x] 1.2 Конвейер: дедлайн с минимальной скоростью передачи для `receive`/`send` приложения; `MIN_TRANSFER_RATE_BYTES` в `TransportSettings`, `main.py`, `compose.yaml`, `.env.example`
- [x] 1.3 Проверка группы: `make lint`; API-тесты: upload без токена с `Content-Length` больше лимита → `401`; медленный идущий upload и скачивание дольше таймаута → `201`/`200`; тело ползёт медленнее порога → `503`
## 2. Стенд
- [ ] 2.1 `infra/s3/api-policy.json` без multipart, `GetBucketLocation` и `ListBucket`; `infra/s3/reconciler-policy.json`; `init.sh` создаёт обоих пользователей; `cli.sh` — alias `reconciler`
- [ ] 2.2 `scripts/secrets.sh`: ключ сверки; `compose.yaml`: secrets сверки у `reconciler`, `s3-init`, `s3-cli`; `user` у `x-s3-client`; `init: true` у `migrate` и `reconciler`
- [ ] 2.3 `scripts/limits.py`: политика секретов; `scripts/s3-check.sh`: запрет листинга ключом API, права ключа сверки; `scripts/reconcile_track.py`: наполнение под ключом API
- [ ] 2.4 CI: uid одноразовых сервисов
- [ ] 2.5 Проверка группы: стенд из чистого состояния, `make test`, `make s3-check`, `make limits`, `make reconcile`, `docker stop` прохода сверки
- [x] 2.1 `infra/s3/api-policy.json` без multipart, `GetBucketLocation` и `ListBucket`; `infra/s3/reconciler-policy.json`; `init.sh` создаёт обоих пользователей; `cli.sh` — alias `reconciler`
- [x] 2.2 `scripts/secrets.sh`: ключ сверки; `compose.yaml`: secrets сверки у `reconciler`, `s3-init`, `s3-cli`; `user` у `x-s3-client`; `init: true` у `migrate` и `reconciler`
- [x] 2.3 `scripts/limits.py`: политика секретов; `scripts/s3-check.sh`: запрет листинга ключом API, права ключа сверки; `scripts/reconcile_track.py`: наполнение под ключом API
- [x] 2.4 CI: uid одноразовых сервисов
- [x] 2.5 Проверка группы: стенд из чистого состояния, `make test`, `make s3-check`, `make limits`, `make reconcile`, `docker stop` прохода сверки
## 3. Стенд: тесты
- [ ] 3.1 Тесты стенда: медленный upload и медленное скачивание 3 MiB через LB, upload без токена с большим `Content-Length` → `401`
- [ ] 3.2 Проверка группы: `make student-test`, `make test-faults`, `make test-persistence ACTION_SCRIPT=scripts/restart.sh`, `make test-failover ACTION_SCRIPT=scripts/stop-one.sh`, `make check`
- [x] 3.1 Тесты стенда: медленный upload и медленное скачивание 3 MiB через LB, upload без токена с большим `Content-Length` → `401`
- [x] 3.2 Проверка группы: `make student-test`, `make test-faults`, `make test-persistence ACTION_SCRIPT=scripts/restart.sh`, `make test-failover ACTION_SCRIPT=scripts/stop-one.sh`, `make check`