Commit 4aea423
authored
feat(etl-uvicorn): ignore SIGTERM in plugin uvicorn Server (#68)
## Summary
uvicorn's default SIGTERM behavior load-sheds new requests with 504
while draining in-flight work. Plugin webservers in our platform are
expected to **outlive their controller container** during pod shutdown
so the controller can finish dispatching in-flight work before the pod
is SIGKILLed — the default behavior races with that drain and orphans
records.
This PR monkey-patches `uvicorn.Server.install_signal_handlers` at
module import time so plugin webservers using `etl-uvicorn` install only
a SIGINT handler. The process now ignores SIGTERM and exits only on
SIGKILL (or SIGINT for local-dev Ctrl-C).
## Why a monkey-patch instead of a Server subclass?
Subclassing requires bypassing `uvicorn.run()` and manually constructing
`Config + Server`, which loses uvicorn's built-in handling of workers /
reload / multiproc. Plugin webservers don't use those today but the
surface area isn't worth changing. The patch is 8 lines, well-scoped to
module import, and works for any uvicorn.Server instance in this
process.
## Test plan
- [x] `make tidy` — clean
- [x] `make check-ruff` — passes
- [x] `pytest` — all tests pass (existing suite + 2 new in
`test/test_signal_handlers.py` covering the patch is applied + the
SIGINT-only handler set)
- [ ] Smoke test: send SIGTERM to a plugin pod, confirm the process
keeps serving until SIGKILL at end of pod grace
- [ ] Verify plugin logs / traces show no 504s from `/invoke` during a
rolling deploy after this version is rolled out
## Version
Bumps `unstructured_platform_plugins` to `0.0.44`. Downstream consumers
will need a separate change to pin the new version.1 parent 094fc3d commit 4aea423
4 files changed
Lines changed: 64 additions & 1 deletion
File tree
- test
- unstructured_platform_plugins
- etl_uvicorn
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
1 | 8 | | |
2 | 9 | | |
3 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
1 | 4 | | |
2 | 5 | | |
3 | 6 | | |
4 | 7 | | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
11 | 32 | | |
12 | 33 | | |
13 | 34 | | |
| |||
0 commit comments