fix: harden rolling update cleanup and preconditions found in verify

Reset the new replica ID before entering the starting state and let the
cleanup find a replica created by an interrupted compose scale; refuse
to start while LB slots keep a manual drain or maint state; log the exit
code of each stopped old replica and print full LB commands for manual
cleanup. Document the migrate step and the rollback tag limitation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-11 01:33:33 +03:00
co-authored by Claude Opus 5.5
parent 69ebf5cd38
commit 5e102e6d0c
9 changed files with 199 additions and 40 deletions
+7 -3
View File
@@ -81,9 +81,13 @@ paths:
(сервер перестаёт быть PID 1) и не из lifespan: реплик несколько, и
каждая гонялась бы с остальными за одну схему. Сервис `migrate`
выполняется один раз на `up`, реплики ждут его завершения; повторный
запуск — no-op. При поочерёдной замене — один `docker compose run
--rm migrate` на новом образе до первой новой реплики
(`scripts/rolling-update.sh`).
запуск — no-op. При поочерёдной замене — один запуск на новом образе до
первой новой реплики (`scripts/rolling-update.sh`): пересоздаётся
контейнер самого сервиса (`up --no-deps --force-recreate
--exit-code-from migrate migrate`), а не одноразовый `run --rm`. Иначе
в стенде остался бы `migrate` прежнего образа, и `restart.sh` (`start
api` запускает его как зависимость) падал бы на «Can't locate
revision» (`balancer.md`).
- `migrations/env.py` — асинхронный шаблон alembic: URL из
`settings.database.url`, мимо ConfigParser (`%` в пароле ничего не
ломает), журнал — JSON через `src/infra/logger.py`. Синхронный