forked from mtusi2026/mtusi2026lab3
Answer requests cancelled at shutdown with 503 in the contract format
After the drain window uvicorn waits for accepted requests for three seconds and then cancels their tasks. CancelledError is a BaseException, so neither the pipeline nor ServerErrorMiddleware saw it and uvicorn answered with its own text/plain 500 without X-Request-Id and X-Instance-Id. The pipeline now handles the cancellation next to the request timeout: it logs request.cancelled, sends 503 unavailable in the common error format when the response has not started and re-raises, so uvicorn only closes the transport after the buffered answer. The declared Content-Length check joins the guard as a rejection to keep the call within the statement limit; behaviour is unchanged. 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:
co-authored by
Claude Opus 5.5
parent
13e856ebd4
commit
aa1485bd86
@@ -1,7 +1,7 @@
|
||||
## 1. Платформа: остановка, готовность, журнал
|
||||
|
||||
- [ ] 1.1 `RequestPipeline`: отмена задачи → `request.cancelled`, `503 unavailable` в общем формате, если ответ не начат, затем отмена пробрасывается
|
||||
- [ ] 1.2 `test_drain.py`: прерванный при остановке запрос — `503`, `application/json`, `error.code = unavailable`, `request_id` = `X-Request-Id`, непустой `X-Instance-Id`
|
||||
- [x] 1.1 `RequestPipeline`: отмена задачи → `request.cancelled`, `503 unavailable` в общем формате, если ответ не начат, затем отмена пробрасывается
|
||||
- [x] 1.2 `test_drain.py`: прерванный при остановке запрос — `503`, `application/json`, `error.code = unavailable`, `request_id` = `X-Request-Id`, непустой `X-Instance-Id`
|
||||
- [ ] 1.3 Порт `Readiness`, адаптер `DatabaseReadiness` с флагом `DRAINING` в `shared/infrastructure/readiness.py`, сборка в `PlatformProvider`, маршрут `/health/ready` через порт; тест состава модулей ядра
|
||||
- [ ] 1.4 `gunicorn_conf.py`: флаг из инфраструктуры, событие `service.draining` через `StructlogLogger`; `failover-evidence.sh` ищет его в логе
|
||||
- [ ] 1.5 `openspec/config.yaml`: карта модулей (`readiness` за портом)
|
||||
|
||||
Reference in New Issue
Block a user