Repository navigation
fix(proxy): expose drain status for graceful deploys - #564
Conversation
91f90d8 to
337ced8
Compare
337ced8 to
4639601
Compare
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 46396013dd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| address = ip_address(client_host) | ||
| except ValueError: | ||
| return False | ||
| return address.is_loopback or address.is_private |
There was a problem hiding this comment.
Restrict drain control access to loopback only
Tighten _is_internal_client_host because allowing address.is_private means any workload on a private network (for example, another pod in the cluster CIDR) can call /internal/drain/start and force this instance into draining mode, which immediately flips readiness and returns 503 for normal traffic. This commit changed the check from loopback-only to broad private-network trust, so it introduces an availability/security regression in multi-tenant or flat east-west network environments.
Useful? React with 👍 / 👎.
|
Thanks @Komzpa -- the polling-based preStop and the in-flight exclusion for health/drain endpoints are both right. Codex review caught one real availability/security regression I'd like to address before merge: P1 -- private-network trust is too wideThe widening from loopback-only to The Helm Suggested shapes, ranked by least-invasive first: 1. Revert to loopback-only If the in-pod loopback path works in your environment, revert 2. Env-configurable allowlist If there is a sidecar or DaemonSet caller that needs access, add an env like def _is_internal_client_host(client_host):
if client_host in {"127.0.0.1", "::1", "localhost"}:
return True
if client_host is None:
return False
trusted = _get_trusted_drain_cidrs() # env-driven
if not trusted:
return False
try:
addr = ip_address(client_host)
except ValueError:
return False
return any(addr in net for net in trusted)3. Shared secret / bearer If we want to keep this purely network-level, an env-driven Option 1 is what I'd push for. The Helm preStop already loops over loopback so I don't see what we lose. Option 2 is the right escape hatch if you have a legit non-loopback caller you want to keep working. The rest of the PR (status endpoint, in-flight middleware excludes, drain endpoints reachable while draining, helm preStop with status polling, README update) all look correct. Let me know which shape you want and I'll re-run |
|
Codex Review: Didn't find any major issues. Keep it up! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@all-contributors please add @Komzpa for code, test |
…l fetch timeouts, image rewrite) Upstream batch v1.16.0 highlights: - proxy: expose drain status for graceful deploys (Soju06#564) - proxy: narrow budget-safe gate to primary usage (Soju06#561) - proxy: handle model fetch timeouts (Soju06#541) - proxy: inline-rewrite input_image file references (Soju06#571) - proxy: retry transient stream timeouts (Soju06#551) - proxy: use DEFAULT_HOME_DIR for oversized response.create dumps (Soju06#575) - accounts: split compact quota row + recover quota status (Soju06#562, Soju06#559) - db: size background pool for burst traffic (Soju06#563) - upstream: drop top_p for gpt-5 (Soju06#538) Conflict resolved: - app/modules/proxy/service.py: kept fork's multi-line import + FailurePhase (used by deterministic failover at line 8294). Merge cleanup: - app/main.py: removed pre-existing duplicate InFlightMiddleware class + duplicate _is_benign_metrics_bind_failure helper that shadowed canonical versions and broke new upstream test (test_in_flight_middleware_does_not_count_drain_status). Verification: - pytest tests/unit: 1459 passed, 17 failed (all pre-existing on backup branch backup/pre-upstream-merge-20260511 — date-bound API key tests, test_db_migrate.py SQLite env, settings duplicate validators). - openspec validate --specs: 19/19 passed. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
* fix(proxy): expose drain status for graceful deploys * fix(health): keep drain start loopback-only * fix(helm): preserve drain deregistration wait
Summary
/internal/drain/statuswithdraining,bridge_drain_active, andin_flightcounters for deploy toolingpreStophook to start drain and poll/internal/drain/statusinstead of only sleeping a fixed intervalThis is a graceful-drain primitive, not a full single-container zero-downtime deploy story: websocket sessions still need an old backend kept alive until they close, and local Docker deployments need a separate stable frontend/proxy for true blue/green cutover.
Tests
UV_PROJECT_ENVIRONMENT=/home/kom/.venvs/codex-lb-routing-policy uv run pytest tests/unit/test_graceful_shutdown.py tests/unit/test_health_probes.py tests/unit/test_helm_external_secrets.py -q(Helm rendering tests skipped locally becausehelmis not installed in this environment)UV_PROJECT_ENVIRONMENT=/home/kom/.venvs/codex-lb-routing-policy uv run ruff check app/core/middleware/inflight.py app/modules/health/api.py tests/unit/test_graceful_shutdown.py tests/unit/test_health_probes.py tests/unit/test_helm_external_secrets.pyUV_PROJECT_ENVIRONMENT=/home/kom/.venvs/codex-lb-routing-policy uv run ty check app/core/middleware/inflight.py app/modules/health/api.py tests/unit/test_graceful_shutdown.py tests/unit/test_health_probes.py tests/unit/test_helm_external_secrets.pygit diff --check