Repository navigation
Closed
Description
Context
The LLM Gateway rollout exposed a broader infra smell: backend runtime config is split across GKE Helm values, Cloud Run deploy workflow YAML, Secret Manager sync scripts, and live cloud state. This made it easy for backend-listen to have OMI_LLM_GATEWAY_URL while Cloud Run backend, backend-sync, and backend-integration did not.
Recent tactical fixes:
- PR Fix dev backend-listen auto deploy rollout #8509 fixed dev
backend-listenCD to use immutable image tags and wait for rollout. - PR Wire dev Cloud Run backend to LLM gateway #8514 wires dev Cloud Run backend services to the dev LLM Gateway endpoint.
This issue tracks the long-term fix so future backend env changes cannot drift between Cloud Run and GKE.
Root Causes
- Backend config is split across deploy planes:
- GKE
backend-listenenv is declared in Helm values, for examplebackend/charts/backend-listen/dev_omi_backend_listen_values.yamlandprod_omi_backend_listen_values.yaml. - Cloud Run
backend,backend-sync, andbackend-integrationenv is declared separately in GitHub Actions workflows.
- GKE
- Secrets and non-secrets propagate differently:
- GKE secret names flow through the
backend-secretschart and ExternalSecret. - Cloud Run secret bindings are patched by
backend/scripts/sync_cloudrun_secrets_from_chart.sh. - Non-secret env vars have no shared manifest or equivalent sync path.
- GKE secret names flow through the
- Service discovery is platform-specific but not modeled explicitly:
- GKE callers use Kubernetes DNS.
- Cloud Run callers need VPC/private endpoint routing, currently a dev internal ILB/IP for LLM Gateway.
- Validation is too narrow:
backend/scripts/validate-llm-gateway-env.pychecks chart-to-chart wiring only.- Backend Cloud Run deploys do not prove the deployed revision has required env/secrets or can reach internal services.
Target Architecture
Create one repo-owned backend runtime config manifest per environment, separating:
- non-secret env vars: checked in and reviewable
- secret bindings: checked-in names only, values remain in Secret Manager
- service discovery endpoints: explicit per caller platform, e.g. GKE DNS vs Cloud Run private ILB/DNS
- service-specific overrides:
backend,backend-sync,backend-integration,backend-listen,llm-gateway
Use that manifest to generate or validate:
- Helm-compatible env lists
- Cloud Run
env_vars - Cloud Run secret bindings
- required private networking settings for Cloud Run callers
Prefer stable internal DNS or named internal load balancer addresses over undocumented raw IPs for Cloud Run-to-GKE service discovery.
Migration Plan
- Inventory current backend env vars from
backend-listenHelm values and live Cloud Run services. - Classify each var as non-secret, secret binding, service discovery, or service-specific override.
- Add a canonical manifest, for example
backend/deploy/env/{dev,prod}.yaml. - Build a renderer/validator that emits or verifies Helm env blocks, Cloud Run env vars, and Cloud Run secret bindings.
- Replace hardcoded Cloud Run values with manifest-derived values.
- Extend CI so PRs fail when backend runtime env changes are not represented in the manifest.
- Add deploy-time validation before traffic shift:
- required env vars exist on the new Cloud Run revision
- required secret bindings exist on the new Cloud Run revision
- private networking settings are present when private endpoints are configured
- same-network probe can reach required internal endpoints
- Remove duplicated definitions after the generated/validated path is proven in dev and one prod deploy.
Acceptance Criteria
- Adding or changing a backend runtime env var fails CI unless it is classified in the canonical manifest.
- Dev/prod Cloud Run backend services receive required secret bindings consistently with GKE when applicable.
- Non-secret env vars required by backend runtime, including gateway config, are present on all intended Cloud Run services.
- GKE
backend-listencontinues to use Kubernetes DNS for in-cluster service calls. - Cloud Run backend services use stable private service discovery instead of undocumented raw IPs.
- Backend deploy workflows fail before traffic shift if rendered config and live revision config diverge.
- LLM Gateway deploys keep their
/readyand chat-completions smoke checks, and backend deploys also verify caller reachability.
Risks / Constraints
- Some env vars intentionally differ between
backend,backend-sync, andbackend-integration; the manifest needs explicit override support. - A generator can become another drift source unless CI validates generated/rendered output.
- Secret rotation must stay additive and non-disruptive during migration.
- Cloud Run-to-GKE networking may need DNS/ILB cleanup before raw IPs can be fully removed.
Metadata
Metadata
Assignees
Labels
No labels
Activity
Add backend runtime env validator (#8520)
[codex] Guard backend runtime env drift (#8623)
Git-on-my-level commentedon Jun 29, 2026
Additional production evidence from a read-only observability sweep on 2026-06-29 UTC supports this runtime-config drift issue.
Sanitized Cloud Logging sweep:
based-hardwarebackend-syncseverity>=ERROR, bucketed by final exception / platform messageObserved buckets:
PORT=8080; connection failed with statusCANCELLED.google.auth.exceptions... File google-credentials.json was not found.No document to updateunder sanitizedusers/<id>/memories/<id>paths.Current service state at triage was Ready, so this did not look like an active outage:
latestReadyRevisionName:backend-sync-00700-fw2latestCreatedRevisionName:backend-sync-00700-fw2gcloud run services describeWhy this belongs here: the
google-credentials.json was not foundstartup burst is another concrete example of Cloud Run runtime/env/secret configuration drifting or failing validation during rollout. A future fix for this issue should include a deploy-time/runtime preflight that catches missing credential bindings before a revision receives traffic.No raw log payloads, user IDs, credentials, tokens, or request bodies are included here.
Git-on-my-level commentedon Jun 29, 2026
One extra implementation note for this runtime-config issue: the 2026-06-29 backend-sync evidence specifically involved a revision that failed startup because
google-credentials.jsonwas missing, then recovered on the current ready revision.For the long-term fix, please make sure the canonical runtime config/preflight covers both styles used in this repo:
SERVICE_ACCOUNT_JSON/ mounted-file expectations used by backend local/dev docs.google-credentials.jsonat runtime.The guard should fail before traffic if a revision expects a credential file/env binding that is absent. This would have caught the sampled backend-sync startup-probe burst without needing to wait for Cloud Logging.
[codex] Fix backend runtime config validation (BasedHardware#8651)