fix: address PR#252 review comments + Gemini review fix (ROUTER_PORT/LANGFUSE_WEB_PORT)#254
Conversation
…yments Replaces all hardcoded port values and the pod name in pod.yaml, start-stack.sh, litellm/config.yaml and litellm/entrypoint.py with environment-variable-driven placeholders. A single pod.yaml now serves both the production agent-router-pod and the development dev-router-pod. Changes: - pod.yaml: rewrite with *_PLACEHOLDER vars for pod name, all 13 service ports, and DATA_ROOT; add clickhouse-port-config volume; litellm-config volume now points to DATA_ROOT/litellm-rendered (rendered copy) - start-stack.sh: load optional DEV_ENV_FILE overlay; resolve port/name defaults after env sourcing; add generate_clickhouse_config() and render_litellm_config() helpers; parameterize all agent-router-pod refs and hardcoded ports throughout cleanup, health-check, and minio helpers - litellm/config.yaml: replace port 6379 / 5000 with *_PLACEHOLDER vars (rendered at deploy time via render_litellm_config) - litellm/entrypoint.py: read POSTGRES_PORT / LITELLM_PORT from env instead of hardcoded 5432 / 4000; use setdefault to not clobber container-injected env vars - .env: append production port defaults (POD_NAME, ROUTER_PORT, ...) - .env.dev: new dev overlay (POD_NAME=dev-router-pod, +10 port offsets, dev.vendeuvre.lan URLs) - start-dev.sh: thin wrapper that sets DEV_ENV_FILE + DATA_ROOT then delegates to start-stack.sh - .gitignore: exclude dev-data/ (dev-stack runtime volumes)
…T, LANGFUSE_WEB_PORT, ROUTER_PORT)
…non-alpine valkey image Root cause: podman play kube converts tcpSocket liveness probes into 'nc -z -v localhost <port> || exit 1' healthchecks. Alpine's BusyBox nc does not support -z, so the healthcheck always fails. With HealthcheckOnFailureAction=restart, this causes an infinite SIGTERM restart loop (~every 30s). Changes: - valkey-cache: tcpSocket -> exec valkey-cli ping (liveness + readiness) - valkey-lf: tcpSocket -> exec valkey-cli -a <pass> ping (liveness) - Image: valkey:9.1.0-alpine -> valkey:9.1.0 (non-alpine has no nc, so no broken built-in healthcheck to conflict with) Verified in dev: 0 SIGTERMs, 0 ECONNREFUSED, both valkey instances healthy, Langfuse web/worker stable, chat completions 200 OK.
Sourcery review: valkey-cli ping without -p targets default 6379, causing false negatives when VALKEY_CACHE_PORT is customized (e.g. dev=6389). Now matches the port-aware pattern already used by valkey-lf probes.
- litellm/entrypoint.py: restore quote stripping before setdefault (prevents literal '"5432"' from breaking int() parsing) - start-stack.sh: use ROUTER_IMAGE var instead of hardcoded ghcr.io/sheepdestroyer/llm-routing:latest in build/pull paths - start-stack.sh: create volume dirs under DATA_ROOT instead of WORKDIR (fixes pod creation when DATA_ROOT != WORKDIR) - start-stack.sh: add placeholder validation to render_litellm_config and chmod 644 on rendered configs for non-root container access - scripts/backup.sh: use POD_NAME from .env instead of hardcoded agent-router-pod-postgres-db (fixes dev backup failures) - router/main.py: extract _valkey_port() helper to DRY the VALKEY_CACHE_PORT/VALKEY_PORT fallback (3 call sites) - router/main.py: replace hardcoded :3001 with LANGFUSE_WEB_PORT env var in dashboard Infrastructure Nodes display
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
- scripts/backup.sh: wire POSTGRES_PORT through pg_isready -p flag (fixes backup failures when DB port is customized, e.g. dev=5442) - pod.yaml: remove redundant PORT env var (LITELLM_PORT already set) - start-stack.sh: remove undocumented --pull-latest alias - start-stack.sh: add placeholder validation to render_router_config (matches existing render_litellm_config guard) - start-stack.sh: extract deploy_fresh_pod() helper to DRY the repeated generate→render→deploy→setup→verify sequence (4 call sites) - router/main.py: use LLAMA_SERVER_URL for health check instead of hardcoded http://127.0.0.1:8080/health
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
- router/tests/test_get_redis.py: _valkey_port() now safely catches
ValueError and returns 6379, so the old test that expected int('invalid')
to crash inside get_redis() no longer applies. Split into two tests:
test_valkey_port_invalid_fallback (new) and a rewritten
test_get_redis_initialization_failure that uses aioredis.Redis
side_effect instead.
- start-stack.sh: fix broken if/elif/else chain in first-deploy path
(direct-applied commit had 'if' instead of 'elif', causing the
localhost check and pull branch to run inside FULL_REBUILD mode,
plus an extra dangling 'fi')
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…ip, empty-string port handling
- safe_pod_teardown: use podman pod inspect --format '{{.State}}' instead of
podman pod exists to distinguish running vs stopped pods (Gemini review)
- litellm/entrypoint.py: strip key after line.partition('=') to handle
spaces around '=' in .env files (Gemini review)
- router/main.py + litellm/entrypoint.py: replace os.getenv('PORT', 'default')
with os.getenv('PORT') or 'default' to handle empty-string env vars
correctly, preventing broken URLs like http://127.0.0.1: (Gemini review)
- README.md: update health check table — valkey probes now use exec
valkey-cli ping instead of tcpSocket, postgres uses pg_isready -p <port>
- Replied to false positives: LiteLLM /ping is a valid endpoint; the or
chain in entrypoint.py correctly handles empty LITELLM_PORT
The router uses these for dashboard display and health checks. Without them, the dashboard always shows default ports even when custom ports are configured via .env.dev. Reported by Gemini Code Assist review on PR#253.
Reviewer's GuideThis PR wires environment-driven port and pod configuration through the startup scripts, pod spec, router, and LiteLLM, fixes several Gemini-found correctness issues (pod teardown, .env parsing, empty ports), and aligns health probes and docs with the actual deployment behavior, while adding a dev deployment wrapper. Sequence diagram for deploy_fresh_pod env-driven deployment flowsequenceDiagram
actor Dev
participant start_stack_sh
participant deploy_fresh_pod
participant podman
participant minio_s3
participant postgres_db
participant litellm_gateway
participant llm_router
Dev->>start_stack_sh: run start-stack.sh [--pull|--full-rebuild]
start_stack_sh->>start_stack_sh: safe_pod_teardown
start_stack_sh->>deploy_fresh_pod: deploy_fresh_pod
deploy_fresh_pod->>start_stack_sh: generate_clickhouse_config
deploy_fresh_pod->>start_stack_sh: render_litellm_config
deploy_fresh_pod->>start_stack_sh: render_router_config
deploy_fresh_pod->>start_stack_sh: render_pod_yaml
start_stack_sh->>podman: play kube (render_pod_yaml)
podman-->>litellm_gateway: start with LITELLM_PORT, POSTGRES_PORT, VALKEY_CACHE_PORT
podman-->>llm_router: start with ROUTER_PORT, LITELLM_PORT, LANGFUSE_WEB_PORT, VALKEY_CACHE_PORT
podman-->>postgres_db: start with POSTGRES_PORT
deploy_fresh_pod->>minio_s3: setup_minio_buckets
deploy_fresh_pod->>start_stack_sh: verify_stack_health
start_stack_sh->>postgres_db: pg_isready -p POSTGRES_PORT
start_stack_sh->>litellm_gateway: GET /health/readiness on LITELLM_PORT
start_stack_sh->>llm_router: POST /v1/chat/completions on ROUTER_PORT
llm_router-->>Dev: triage router ready with env-driven ports
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reached
Next review available in: 10 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (13)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- There are several places now resolving ports from env (e.g., LITELLM_PORT, LANGFUSE_WEB_PORT, Valkey ports) with similar
os.getenv(...) or defaultpatterns; consider centralizing this logic into small helper functions for consistency and easier future changes. - The raw
render_pod_yamlreplacements for POD_NAME/DATA_ROOT/port placeholders in pod.yaml assume safe, unquoted values; if these can contain spaces or special characters (especially DATA_ROOT or ROUTER_IMAGE), it may be safer to either quote them in YAML or validate/sanitize them before substitution.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- There are several places now resolving ports from env (e.g., LITELLM_PORT, LANGFUSE_WEB_PORT, Valkey ports) with similar `os.getenv(...) or default` patterns; consider centralizing this logic into small helper functions for consistency and easier future changes.
- The raw `render_pod_yaml` replacements for POD_NAME/DATA_ROOT/port placeholders in pod.yaml assume safe, unquoted values; if these can contain spaces or special characters (especially DATA_ROOT or ROUTER_IMAGE), it may be safer to either quote them in YAML or validate/sanitize them before substitution.
## Individual Comments
### Comment 1
<location path="start-stack.sh" line_range="659" />
<code_context>
+ "CLICKHOUSE_INTERSERVER_PORT_PLACEHOLDER",
</code_context>
<issue_to_address>
**issue (bug_risk):** Placeholder list includes CLICKHOUSE_INTERSERVER_PORT_PLACEHOLDER but it’s never substituted, which will cause render_pod_yaml to fail.
In render_pod_yaml, CLICKHOUSE_INTERSERVER_PORT_PLACEHOLDER is added to `placeholders` but is neither referenced in pod.yaml nor included in `raw_replacements`. Since the function now raises when a placeholder is missing from the YAML, this will always fail. Please either remove CLICKHOUSE_INTERSERVER_PORT_PLACEHOLDER from `placeholders`, or add it as a real placeholder in pod.yaml and include it in `raw_replacements`.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request introduces a development environment overlay (.env.dev, start-dev.sh) and parameterizes port assignments, pod names, and data directories across the stack's configurations and scripts to allow running a development pod alongside production. Key changes include dynamic port resolution in Python entrypoints, rendering configurations with port placeholders, and generating ClickHouse port overrides. A critical review comment points out that running both production and development pods concurrently with the same default DATA_ROOT will cause database and data corruption, and suggests isolating the development data directory.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
scripts/dev-setup.sh creates a .venv with runtime deps (mirrored from router/Dockerfile) + test deps (pytest, pytest-asyncio, anyio). Was already referenced but never committed.
Summary
Addresses all valid review comments from PR #252 (Gemini Code Assist + Sourcery), plus a fix for a Gemini review finding on PR #253.
Changes
Fix: safe_pod_teardown false timeout report (Gemini)
podman pod existsreturns 0 for stopped pods too, so after a successful graceful stop the script falsely reported a timeout and force-removed. Now usespodman pod inspect --format '{{.State}}'to check actual running state.Fix: .env key not stripped (Gemini)
line.partition("=")preserves spaces around the key. Addedkey = key.strip()so"KEY "doesn't fail to match inos.environ.get().Fix: empty-string port handling (Gemini)
os.getenv('PORT', 'default')returns""when the var is set but empty, producing broken URLs likehttp://127.0.0.1:. Replaced all 9 occurrences inrouter/main.pyand 1 inlitellm/entrypoint.pywithos.getenv('PORT') or 'default'.Fix: missing ROUTER_PORT and LANGFUSE_WEB_PORT env vars in pod.yaml (Gemini review on PR#253)
The router uses these for dashboard display and health checks. Without them, the dashboard always shows default ports even when custom ports are configured via
.env.dev. Added both to thellm-triage-routercontainer's environment.Docs: README health check table
Updated valkey probes from
tcpSockettovalkey-cli ping(matching the actual pod.yaml), and postgres frompg_isready -U postgrestopg_isready -U postgres -p <port>.False positives (replied, no code change)
/pingis a valid health endpoint alongside/health/livenessorchain in entrypoint.py correctly handles empty stringsos.environ.setdefaultis intentional: pod spec is authoritative, .env fills gapsFiles changed
start-stack.sh— safe_pod_teardown fixlitellm/entrypoint.py— key strip + empty-string port fixrouter/main.py— empty-string port fix (9 occurrences)pod.yaml— added ROUTER_PORT and LANGFUSE_WEB_PORT env varsREADME.md— health check table updateSummary by Sourcery
Align routing stack deployment with configurable ports and images, improving dev/prod separation and fixing env/health-check issues.
New Features:
Bug Fixes:
Enhancements:
Documentation: