Skip to content

feat: parameterize ports/pod, fix valkey healthcheck, address all review comments#251

Closed
sheepdestroyer wants to merge 22 commits into
masterfrom
chore/learn-deployment-guidelines
Closed

feat: parameterize ports/pod, fix valkey healthcheck, address all review comments#251
sheepdestroyer wants to merge 22 commits into
masterfrom
chore/learn-deployment-guidelines

Conversation

@sheepdestroyer

@sheepdestroyer sheepdestroyer commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

Parameterizes all ports and pod name for parallel prod/dev deployments, fixes the Valkey restart loop caused by BusyBox nc -z incompatibility, and addresses all review comments from PRs #248, #249, and #250.

Changes

Port & pod parameterization

  • All ports configurable via .env / .env.dev with +10 offset for dev
  • POD_NAME env var replaces hardcoded agent-router-pod throughout
  • ROUTER_IMAGE env var replaces hardcoded ghcr.io/sheepdestroyer/llm-routing:latest
  • DATA_ROOT defaults to WORKDIR/data, volume dirs created under it
  • deploy_fresh_pod() helper DRYs the repeated generate→render→deploy→verify sequence

Valkey healthcheck fix

  • Switched from tcpSocket probes to exec valkey-cli ping (with -p port)
  • Switched from valkey:9.1.0-alpine to valkey:9.1.0 (non-alpine has no broken nc -z)
  • Root cause: podman play kube converts tcpSocket to nc -z -v localhost <port>, BusyBox nc lacks -z, healthcheck always fails, HealthcheckOnFailureAction=restart causes infinite loop

Review fixes (all rounds)

  • litellm/entrypoint.py: restore quote stripping before setdefault, safe int parsing for POSTGRES_PORT
  • router/main.py: extract _valkey_port() helper (returns int, safe parsing), replace hardcoded :3001 with LANGFUSE_WEB_PORT, use LLAMA_SERVER_URL for health check
  • start-stack.sh: placeholder validation in both render_litellm_config and render_router_config, chmod 644 on rendered configs, remove undocumented --pull-latest alias
  • scripts/backup.sh: use POD_NAME and POSTGRES_PORT from .env
  • pod.yaml: remove redundant PORT env var (duplicate of LITELLM_PORT)

Verified in dev

  • valkey-cache: healthy, 0 SIGTERMs
  • valkey-lf: healthy, 0 SIGTERMs
  • Chat completions: 200 OK
  • Langfuse: 0 ECONNREFUSED

Summary by Sourcery

Parameterize pod name, ports, and data directories for flexible prod/dev deployments, add dev startup wrapper, and update health checks and dependencies to stabilize Valkey, LiteLLM, Postgres, ClickHouse, Langfuse, and MinIO.

New Features:

  • Introduce environment-driven configuration for pod name, router image, ports, and data root to support parallel prod/dev stacks.
  • Add rendered LiteLLM and router config outputs and ClickHouse port override files to decouple runtime ports from static configs.
  • Provide a start-dev.sh wrapper and .env.dev overlay for convenient dev stack deployment on alternate ports.

Bug Fixes:

  • Fix Valkey cache and Langfuse queue health checks by switching to valkey-cli exec probes and updating the Valkey image to avoid BusyBox nc incompatibility.
  • Ensure PostgreSQL readiness checks and backups use the configured port and pod name, preventing false failures.
  • Update Langfuse, LiteLLM, router, and MinIO URLs and ports to eliminate hardcoded defaults that could cause connection errors.

Enhancements:

  • Refactor stack startup script to centralize deployment into a deploy_fresh_pod helper, support image pulling, and parameterize zombie port cleanup.
  • Generate pod YAML from expanded environment placeholders including ports, pod name, data root, and router image, with validation for unresolved placeholders.
  • Improve router health and dashboard logic to respect configured LiteLLM, Valkey, Langfuse, and Llama server endpoints and ports.
  • Adjust LiteLLM entrypoint to respect existing environment values and derive the listening port from env, with robust parsing of the PostgreSQL port.

Deployment:

  • Extend pod volume definitions to use a configurable data root and add ClickHouse port-override config mounts for customized port bindings.

Documentation:

  • Clarify CLI help text for stack startup modes, including separate options for pulling the router image and performing local full rebuilds.

Chores:

  • Update .gitignore and add .env.dev scaffold to support environment-based dev configuration.

boy and others added 17 commits July 11, 2026 12:18
…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)
…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
@sourcery-ai

sourcery-ai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

This PR parameterizes all core service ports and pod naming for flexible prod/dev deployments, fixes Valkey health checks to avoid BusyBox nc incompatibility, and refactors deployment scripts/configs to be DRY and environment-driven while addressing earlier review feedback.

Sequence diagram for deploy_fresh_pod environment-driven deployment

sequenceDiagram
    participant User
    participant start_stack_sh as start-stack.sh
    participant clickhouse_cfg as generate_clickhouse_config
    participant litellm_cfg as render_litellm_config
    participant router_cfg as render_router_config
    participant pod_yaml as render_pod_yaml
    participant Podman as podman
    participant Minio as setup_minio_buckets
    participant Health as verify_stack_health

    User->>start_stack_sh: run ./start-stack.sh
    start_stack_sh->>clickhouse_cfg: generate_clickhouse_config
    start_stack_sh->>litellm_cfg: render_litellm_config
    start_stack_sh->>router_cfg: render_router_config
    start_stack_sh->>pod_yaml: render_pod_yaml
    pod_yaml-->>start_stack_sh: pod.yaml with POD_NAME and ports
    start_stack_sh->>Podman: play kube -
    Podman-->>start_stack_sh: create POD_NAME pod
    start_stack_sh->>Minio: setup_minio_buckets
    start_stack_sh->>Health: verify_stack_health
    Health-->>User: stack healthy (router, LiteLLM, Valkey, Langfuse)
Loading

File-Level Changes

Change Details Files
Make pod name, router image, data root, and all service ports configurable via environment and use them consistently across shell scripts and Kubernetes pod definition.
  • Load optional dev overlay env file and define POD_NAME, ROUTER_PORT, LITELLM_PORT, LANGFUSE_WEB/WORKER_PORT, POSTGRES_PORT, Valkey, ClickHouse, MinIO ports, ROUTER_IMAGE, and DATA_ROOT with defaults in start-stack.sh
  • Export these env-driven values and use them for LOCAL_BASE_URL, zombie port cleanup, MinIO health/alias URLs, curl-based health checks, PostgreSQL readiness checks, and pod existence/restart logic in start-stack.sh
  • Replace hardcoded pod name, ports, and image references in pod.yaml with POD_NAME_PLACEHOLDER, DATA_ROOT_PLACEHOLDER, ROUTER/LITELLM/LANGFUSE/POSTGRES/VALKEY/CLICKHOUSE/MINIO_*_PORT_PLACEHOLDER, and ROUTER_IMAGE_PLACEHOLDER, and adjust volume hostPaths to use DATA_ROOT_PLACEHOLDER
  • Add start-dev.sh wrapper and .env.dev support so dev deployments can run alongside prod with offset ports
start-stack.sh
pod.yaml
start-dev.sh
.env.dev
Introduce rendered configuration artifacts and ClickHouse port override to keep prod/dev configs separated and driven by env placeholders.
  • Add generate_clickhouse_config to write a ClickHouse config.d port-override.xml using CLICKHOUSE_HTTP/TCP/INTERSERVER env ports into DATA_ROOT/clickhouse-config
  • Add render_litellm_config to produce a rendered LiteLLM config.yaml under DATA_ROOT/litellm-rendered by replacing VALKEY_CACHE_PORT_PLACEHOLDER and ROUTER_PORT_PLACEHOLDER, validating no unresolved placeholders, and chmod-ing outputs
  • Add render_router_config to produce a rendered router config.yaml under DATA_ROOT/router-rendered by replacing LITELLM_PORT_PLACEHOLDER and validating placeholders
  • Update pod.yaml volumes to mount litellm-rendered, router-rendered, datasets, and clickhouse-config from DATA_ROOT, and adjust LiteLLM/router volumeMounts to use the rendered config volumes
  • Factor deploy_fresh_pod helper in start-stack.sh to generate ClickHouse config, render both configs, play kube, setup MinIO buckets, and verify health, and reuse it across initial deploy, replace, pull, and rebuild flows
start-stack.sh
pod.yaml
Add explicit Valkey ports and switch health probes from tcpSocket to exec valkey-cli ping to avoid BusyBox nc -z incompatibility under podman play kube.
  • Add --port VALKEY_CACHE_PORT_PLACEHOLDER to valkey-cache container command and change its image from valkey:9.1.0-alpine to valkey:9.1.0
  • Replace valkey-cache liveness/readiness tcpSocket probes with exec valkey-cli -p VALKEY_CACHE_PORT_PLACEHOLDER ping probes
  • Set Valkey LF container to use VALKEY_LF_PORT_PLACEHOLDER for --port and switch image to valkey:9.1.0
  • Replace Valkey LF liveness probe with exec valkey-cli using VALKEY_LF_PORT_PLACEHOLDER and REDIS_AUTH_PLACEHOLDER for ping, and update readiness probe port to VALKEY_LF_PORT_PLACEHOLDER
  • Ensure related envs and Langfuse Redis config use VALKEY_LF_PORT_PLACEHOLDER instead of hardcoded 6380
pod.yaml
Refine router and LiteLLM Python code to respect env-driven ports, safely parse values, and remove duplicated URL configuration logic.
  • Update router/main.py to compute LITELLM_URL and LANGFUSE_HOST defaults using LITELLM_PORT and LANGFUSE_WEB_PORT env vars, and introduce _valkey_port helper with guarded int parsing and logging fallback
  • Use _valkey_port in get_redis and dashboard health checks instead of hardcoded 6379, and parameterize LiteLLM, LLAMA server, and Langfuse health check URLs and dashboard display ports based on env
  • Change /v1/memory proxy base to use LITELLM_PORT env, and switch LLAMA health check to use LLAMA_SERVER_URL env for /health
  • Adjust router/config.yaml backend api_base entries to use LITELLM_PORT_PLACEHOLDER rather than fixed :4000
  • In litellm/entrypoint.py, restore quote stripping while using os.environ.setdefault when loading env, add safe POSTGRES_PORT parsing for readiness check, and drive LiteLLM server port from LITELLM_PORT or PORT env
  • Update LiteLLM config.yaml to parameterize cache and redis ports using VALKEY_CACHE_PORT_PLACEHOLDER and router api_base using ROUTER_PORT_PLACEHOLDER
router/main.py
router/config.yaml
litellm/entrypoint.py
litellm/config.yaml
Tighten backup, MinIO setup, and health verification scripts to respect env-configured pod names/ports and improve deployment ergonomics.
  • Change scripts/backup.sh to source .env, default POD_NAME and POSTGRES_PORT, and use ${POD_NAME}-postgres-db and pg_isready -p POSTGRES_PORT for readiness and pg_dump invocations
  • Update start-stack.sh MinIO bucket setup to use ${POD_NAME}-minio-s3 instead of hardcoded pod names and respect MINIO_S3_PORT for health checks and mc alias endpoints
  • Adjust verify_stack_health to use ${POD_NAME}-postgres-db with pg_isready -p POSTGRES_PORT and curl LiteLLM and router readiness using configured ports
  • Modify safe_pod_teardown and backup pre-deploy logic to use POD_NAME for pod existence/stop/rm and restart messaging
  • Add new --pull mode for router image (ROUTER_IMAGE env), deprecating the old implicit pull alias, and clarify help text for replace/pull/full-rebuild flows
scripts/backup.sh
start-stack.sh

Possibly linked issues

  • #LHF-03: PR replaces hardcoded LiteLLM/Langfuse/Valkey endpoints in router/main.py with env-driven URLs and ports, fully addressing LHF-03.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@sheepdestroyer, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 38 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 40241132-ae27-4aec-b0e1-2dc4fbcb86e9

📥 Commits

Reviewing files that changed from the base of the PR and between 3c2296e and bbc56ee.

📒 Files selected for processing (11)
  • .env.dev
  • .gitignore
  • litellm/config.yaml
  • litellm/entrypoint.py
  • pod.yaml
  • router/config.yaml
  • router/main.py
  • router/tests/test_get_redis.py
  • scripts/backup.sh
  • start-dev.sh
  • start-stack.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/learn-deployment-guidelines

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • You now derive ports and URLs from env in several places (start-stack.sh, router/main.py, litellm/entrypoint.py); consider centralizing this parsing/validation in one helper per component to avoid duplicated default logic and reduce the chance of divergence.
  • The YAML rendering pipeline mixes Python placeholder replacement (pod.yaml) with sed-based templating (render_litellm_config/render_router_config); unifying these on the existing Python templater would make the configuration generation more consistent and easier to maintain.
  • Router/main.py constructs the LiteLLM and Langfuse base URLs multiple times inline (e.g., in get_dashboard_data and proxy_memory) instead of reusing LITELLM_URL/LANGFUSE_HOST; reusing those globals would simplify the code and keep behavior consistent if the defaults change.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- You now derive ports and URLs from env in several places (start-stack.sh, router/main.py, litellm/entrypoint.py); consider centralizing this parsing/validation in one helper per component to avoid duplicated default logic and reduce the chance of divergence.
- The YAML rendering pipeline mixes Python placeholder replacement (pod.yaml) with sed-based templating (render_litellm_config/render_router_config); unifying these on the existing Python templater would make the configuration generation more consistent and easier to maintain.
- Router/main.py constructs the LiteLLM and Langfuse base URLs multiple times inline (e.g., in get_dashboard_data and proxy_memory) instead of reusing LITELLM_URL/LANGFUSE_HOST; reusing those globals would simplify the code and keep behavior consistent if the defaults change.

## Individual Comments

### Comment 1
<location path="scripts/backup.sh" line_range="16-21" />
<code_context>
 RETENTION_DAYS=14
 LOG_FILE="/tmp/llm-backup-${TIMESTAMP}.log"

+# Source .env for POD_NAME and POSTGRES_PORT (with prod defaults)
+if [ -f "${WORKDIR}/.env" ]; then
+    set -a; source "${WORKDIR}/.env"; set +a
+fi
+POD_NAME="${POD_NAME:-agent-router-pod}"
+POSTGRES_PORT="${POSTGRES_PORT:-5432}"
+
 mkdir -p "$BACKUP_DIR"
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Backup script only sources `.env`, so dev deployments with a different POD_NAME/ports won’t get correct backup behavior.

With `start-dev.sh` and `DEV_ENV_FILE` in `start-stack.sh`, dev setups can use different `POD_NAME`/`POSTGRES_PORT` (e.g., `dev-router-pod`). Since `backup.sh` always sources `${WORKDIR}/.env` and defaults to `agent-router-pod`, running it in dev will still target the prod pod/port. If dev backups are desired, this script should either respect `DEV_ENV_FILE` or allow the env file path to be configured.

```suggestion
# Determine env file to source for POD_NAME and POSTGRES_PORT.
# Priority: BACKUP_ENV_FILE (explicit), DEV_ENV_FILE (dev stack), then ${WORKDIR}/.env (prod default).
ENV_FILE=""
if [ -n "${BACKUP_ENV_FILE:-}" ]; then
    ENV_FILE="${BACKUP_ENV_FILE}"
elif [ -n "${DEV_ENV_FILE:-}" ]; then
    ENV_FILE="${DEV_ENV_FILE}"
else
    ENV_FILE="${WORKDIR}/.env"
fi

if [ -f "${ENV_FILE}" ]; then
    set -a; source "${ENV_FILE}"; set +a
fi

# Sensible defaults if env file did not define them
POD_NAME="${POD_NAME:-agent-router-pod}"
POSTGRES_PORT="${POSTGRES_PORT:-5432}"
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread scripts/backup.sh

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a development environment overlay (.env.dev and start-dev.sh) to run a development stack on distinct ports alongside production. It parameterizes ports, pod names, and image paths across configuration files and scripts, dynamically rendering them at startup. Feedback on the changes includes: ensuring the backup script preserves dev environment overrides by sourcing the dev environment file; checking and building local router images instead of attempting to pull them from remote registries on first deploy; stripping whitespace from parsed environment keys in litellm/entrypoint.py for robustness; and using POSIX-compliant grep -E instead of GNU-specific extensions for better portability.

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.

Comment thread scripts/backup.sh
Comment thread start-stack.sh
Comment thread litellm/entrypoint.py
Comment on lines 18 to +20
key, _, val = line.partition("=")
val = val.strip().strip('"').strip("'")
os.environ[key] = val
os.environ.setdefault(key, val)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The key parsed from the .env file is not stripped of whitespace. If there are spaces around the = character in the .env file (e.g., PORT = 4000), the key will contain trailing spaces (e.g., "PORT "), causing os.environ.get("PORT") to return None. Stripping the key ensures robust environment variable loading.

Suggested change
key, _, val = line.partition("=")
val = val.strip().strip('"').strip("'")
os.environ[key] = val
os.environ.setdefault(key, val)
key, _, val = line.partition("=")
key = key.strip()
val = val.strip().strip('"').strip("'")
os.environ.setdefault(key, val)

Comment thread start-stack.sh Outdated
sheepdestroyer and others added 5 commits July 11, 2026 21:42
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')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant