Repository navigation
Closed
Labels
effort/mediumEffort Mediumpriority/p1-highPriority P1: high-impact work for the next planned milestonescope/k8sKubernetes commands, Helm charts, pods, services, and policiessource/agentFiled by an agenttype/bugType bug: the code does not do what it mustvalue/highValue High: the delivery of the item matters much
Description
Problem Description
Three settings of the LiteLLM gateway and its database use a Kubernetes or CloudNativePG default. Each default cuts open model calls or stops the gateway start.
- Gateway pod grace period.
k8s/llm/gateway/deployment.yamlsets noterminationGracePeriodSecondsand nopreStop, so the default of 30 s applies. On SIGTERM, uvicorn waits for the open streams. LiteLLM 1.103.11 passes notimeout_graceful_shutdown(proxy_cli.py:282), so uvicorn waits until the kubelet kills it. The router timeout is 1500 s (k8s/llm/gateway/config.yaml:247), and thedevops-backgroundtimeout is 1100 s. Thus a call that is open at a rollout fails after 30 s. The gateway rolled 10 times in 7 days. - Database smart shutdown. The gateway CloudNativePG Cluster
llm-gateway-dbhas 1 instance (k8s/llm/gateway-db.yaml:91),smartShutdownTimeout180 (the default) andprimaryUpdateMethodrestart. On an image change, the operator restarts the only instance. The smart shutdown waits up to 180 s for each session to end, and the old gateway pod keeps its Prisma pool open. During that time, the database refuses new connections. LiteLLM v1 tries the migration check 4 times in about 5 s with no delay (litellm_proxy_extrasutils.py:1346,1379-1381) and then exits with code 1. The new gateway pod crash-loops, and the kubelet back-off is the only wait. - Probe timeout. The liveness and readiness probes (
k8s/llm/gateway/deployment.yaml:139-154) set notimeoutSeconds, so the default of 1 s applies. The gateway runs 1 uvicorn worker. The unpaginated v1/spend/logsreads and serializes up to 10,000 rows in that worker. During that time,/health/livelinesswaits for more than 1 s.
Reproduction Steps
- Start a long call through the gateway, for example a roadmap refine call on
devops-background. - While the call is open, run
kubectl -n llm rollout restart deployment/llm-gateway. - Read the old pod log in Loki. It logs
Waiting for connections to closeand noFinished server process. The client gets an error about 30 s after the rollout. - Change the PostgreSQL image of the Cluster
llm-gateway-dbwhile a gateway pod holds open sessions. The database logsthe database system is shutting downfor 180 s. A gateway pod that starts in that window logsP1001and exits with code 1. - Call v1
GET /spend/logs?start_date=<day>&end_date=<next day>on a day with about 10,000 rows. The kubelet recordsUnhealthyprobe events withcontext deadline exceeded.
Expected vs Actual Behavior
Expected: a rollout lets the old pod finish its open calls. A restart of the gateway database takes seconds. One slow request does not make the probes fail.
Actual:
- 3 of 10 shutdowns in 7 days logged
Waiting for connections to closeand noFinished server process(2026-11-10T00:30:53Z, 2026-11-11T03:14:30Z and 2026-11-12T14:32:42Z). About 30 s later, roadmap-service loggedRefine skipped #4404 ... AIClientError, LLM_INFERENCE_ERROR(2026-11-11T03:15:00Z) andRefine skipped #5100 ...(2026-11-12T14:33:12Z). - On 2026-11-12, the database refused connections for 3 minutes, and the new gateway pod crash-looped (restart count 4).
- 28 probe failures in 7 days. There was no restart, because the failures never reached 3 in a row.
Environment Diagnostics
- DevOps CLI Version: 0.124.0
- Gateway: LiteLLM v1.103.11, 1 replica, 1 uvicorn worker, RollingUpdate (default strategy)
- Database: CloudNativePG Cluster
llm-gateway-db, 1 instance, PostgreSQL 17.11 - Execution Environment: homelab Kubernetes cluster, managed by Argo CD
Logs, Traces, or Terminal Output
# Database, 2026-11-12 (an image-drift restart, not a node drain: the node events show no drain at 14:28)
14:28:42 Detected drift ... runningImages 17.2, latestImages 17.11 ... smartShutdownTimeout 180
14:28:43-14:31:43 275 x "the database system is shutting down", then "Requesting fast shutdown"
# 2 idle sessions of the old gateway pod held the shutdown open.
# New gateway pod, 14:29:41-14:31:28
16 x P1001, 4 x "Database setup failed after multiple retries", restartCount 4
# Probes, 7 days: 28 Unhealthy "context deadline exceeded" events on /health/liveliness
# (20 readiness, 8 liveness, 2026-11-08T13:26Z to 2026-11-09T23:11Z). Each event came about
# 3 s before "GET /spend/logs?start_date=2026-11-09&end_date=2026-11-10" from a port-forward,
# every 70 s. CPU was 0.04 to 0.25 core.
WARNING spend_management_endpoints.py:331 /spend/logs result truncated to the 10000 most recent rowsProposed Fix
k8s/llm/gateway/deployment.yaml(pod spec): setspec.template.spec.terminationGracePeriodSeconds: 600. This covers a normal long call. The upper limit is the router timeout of 1500 s. RollingUpdate starts the new pod first, so the longer grace period only lets the old pod finish its calls and flush its spend queue.k8s/llm/gateway-db.yaml(Cluster spec): setspec.smartShutdownTimeout: 15. A restart then takes seconds.k8s/llm/gateway/deployment.yaml:139-154: settimeoutSeconds: 5onlivenessProbeandreadinessProbe.- Keep
allow_requests_on_db_unavailableunset, as the comment atk8s/llm/gateway/config.yaml:285requires. - Do not put the PostgreSQL image and the LiteLLM image in one manual bump again. Commit 3109817 (build(deps): take every safe version update before Renovate #5102) changed both together. Renovate already updates the two images in separate pull requests (
.github/renovate.jsonhas no group for them). - Ad-hoc callers use
/spend/logs/v2(paginated) or the Prometheus spend series, not v1/spend/logs. No code insrccalls/spend/logs.
Related: #5267 (a CloudNativePG window for a node drain), #5091 (the next gateway upgrade, which also rolls the pod).
Acceptance Criteria
-
kustomize build k8s/llm/gatewayshowsterminationGracePeriodSeconds: 600on the pod andtimeoutSeconds: 5on both probes. - The live Cluster
llm-gateway-dbshowssmartShutdownTimeout: 15. - A rollout during a long call (more than 30 s) ends with
Finished server processin the old pod log, and the client gets a full reply. - The next restart of the gateway database ends in less than 30 s, and the restart count of the gateway pod does not increase.
- A v1
/spend/logscall of 10,000 rows causes noUnhealthyprobe event on the gateway. -
allow_requests_on_db_unavailablestays unset ink8s/llm/gateway/config.yaml.
Metadata
Metadata
Assignees
Labels
effort/mediumEffort Mediumpriority/p1-highPriority P1: high-impact work for the next planned milestonescope/k8sKubernetes commands, Helm charts, pods, services, and policiessource/agentFiled by an agenttype/bugType bug: the code does not do what it mustvalue/highValue High: the delivery of the item matters much
Activity
dan-petty commentedon Nov 13, 2026
Three of ten rollouts in seven days killed open AI calls and the database restart caused a crash-loop.Both concern the gateway rollout, but #4373 verifies one rollout while the candidate fixes the rollout to not kill open calls.devops-cli-service commentedon Nov 13, 2026
Released in v0.125.5: https://github.com/dan-petty/devops-cli/releases/tag/v0.125.5
devops-cli-service commentedon Nov 13, 2026
Live since 2026-11-13 03:45 UTC