Skip to content

fix(deploy): migrate legacy prod Cloud Run public bindings - #9911

Merged
mdmohsin7 merged 1 commit into
mainfrom
fix/prod-cloud-run-legacy-binding-migration
Jul 17, 2026
Merged

mdmohsin7 merged 1 commit into
mainfrom
fix/prod-cloud-run-legacy-binding-migration

Conversation

@mdmohsin7

@mdmohsin7 mdmohsin7 commented Jul 17, 2026 •

Copy link
Copy Markdown
Member

Problem

Every prod backend deploy has failed since 2026-07-14:

ERROR: (gcloud.run.deploy) Cannot update environment variable [GOOGLE_CLIENT_ID]
to string literal because it has already been set with a different type.

efca8b8 ("fix(deploy): classify deployment setting boundaries") reclassified GOOGLE_CLIENT_ID, STT_PRERECORDED_MODEL and the MCP_OAUTH_CLAUDE_* settings from Secret Manager references to public literals sourced from environment variables. Those values are genuinely public (an OAuth client ID, a model routing list, the string Claude, a public callback URL), so the reclassification is correct.

The gap is the rollout: the "Migrate legacy public Cloud Run bindings" step was wired into gcp_backend_auto_dev.yml only, and migrate_legacy_public_bindings was hard-gated to dev via _require_development_scope. Prod's four Cloud Run services kept the old Secret Manager bindings, and gcloud cannot flip a binding's type in place — so the deploy dies before it can set the literal.

Live drift confirmed on every prod service:

Service Declared literal, still bound as secret
backend GOOGLE_CLIENT_ID, STT_PRERECORDED_MODEL, MCP_OAUTH_CLAUDE_CLIENT_ID, MCP_OAUTH_CLAUDE_CLIENT_NAME, MCP_OAUTH_CLAUDE_REDIRECT_URIS
backend-sync, backend-sync-backfill, backend-integration GOOGLE_CLIENT_ID, STT_PRERECORDED_MODEL

Change

  • Scope the migration to the project the manifest declares for the target environment (_require_manifest_scope) instead of hardcoding dev. The operation still cannot be aimed at another environment's project. check_runtime_bindings stays dev-only.
  • Run the migration in gcp_backend.yml before the Cloud Run deploy step, mirroring the dev workflow's ordering.

The migration only strips a binding whose secret name equals the manifest-declared public setting name, so real secrets stay bound, and it no-ops once a service is clean — it is not permanent pipeline overhead.

Verification

  • Live drift confirmed on all four prod services via gcloud run services describe.
  • Value-preserving: each prod environment variable hashes identical (sha256) to the Secret Manager value it replaces, so the flip cannot change runtime behavior.
  • Dry run against live prod — migrate_legacy_public_bindings with a runner that captures mutations instead of executing them. Planned commands match the independently computed drift set, and GOOGLE_CLIENT_SECRET is absent from every removal list:
    backend:               --remove-secrets=GOOGLE_CLIENT_ID,MCP_OAUTH_CLAUDE_CLIENT_ID,
                             MCP_OAUTH_CLAUDE_CLIENT_NAME,MCP_OAUTH_CLAUDE_REDIRECT_URIS,
                             STT_PRERECORDED_MODEL --no-traffic
    backend-sync:          --remove-secrets=GOOGLE_CLIENT_ID,STT_PRERECORDED_MODEL --no-traffic
    backend-sync-backfill: --remove-secrets=GOOGLE_CLIENT_ID,STT_PRERECORDED_MODEL --no-traffic
    backend-integration:   --remove-secrets=GOOGLE_CLIENT_ID,STT_PRERECORDED_MODEL --no-traffic
    
  • validate-backend-runtime-env.py --check-workflows --check-rendered-cloud-run passes for dev and prod.
  • check_deployment_secret_boundary.py --base origin/main passes.
  • pytest tests/unit/{test_preflight_cloud_run_deploy,test_verify_dev_backend_deployment,test_backend_runtime_env_validator,test_repair_cloud_run_traffic,test_deploy_status_report,test_mcp_oauth_deploy_contract}.py → 104 passed.

Prod traffic is pinned to a named revision and the migration revision is created with --no-traffic, so no serving revision changes.

Regression coverage

  • test_legacy_binding_migration_strips_prod_legacy_bindings — the migration runs for prod and strips only the manifest-declared public setting, leaving GOOGLE_CLIENT_SECRET bound.
  • test_prod_deploy_invokes_legacy_binding_migration_before_deploy — the prod workflow invokes the migration for all four services ahead of the deploy step. This is the wiring whose absence caused the outage.
  • test_legacy_binding_migration_rejects_mismatched_projects_without_gcloud_calls — replaces the old dev-only assertion; a mismatched env/project pair still fails with no gcloud calls.

Failure-Class: none

Review in cubic

efca8b8 reclassified GOOGLE_CLIENT_ID, STT_PRERECORDED_MODEL and the
MCP_OAUTH_CLAUDE_* settings from Secret Manager references to public
literals, but wired the binding migration into the dev deploy only and
gated the helper to dev. Prod services kept the old secret bindings, and
gcloud cannot flip a binding's type in place, so every prod backend deploy
since 2026-07-14 failed with:

  Cannot update environment variable [GOOGLE_CLIENT_ID] to string literal
  because it has already been set with a different type.

Scope the migration to the project the manifest declares for the target
environment instead of hardcoding dev, and run it in the prod deploy before
the Cloud Run deploy step. The migration only strips bindings whose secret
name equals the manifest-declared public setting name, so real secrets
(GOOGLE_CLIENT_SECRET) stay bound, and it no-ops once a service is clean.

Verification:
- Confirmed live drift on all four prod services via `gcloud run services
  describe`: backend carries 5 legacy bindings, the other three carry 2.
- Confirmed the flip is value-preserving: each prod environment variable
  hashes identical to the Secret Manager value it replaces (sha256).
- Dry-ran migrate_legacy_public_bindings against live prod with a runner
  that captures mutations instead of executing them; the planned commands
  match the independently computed drift set and exclude GOOGLE_CLIENT_SECRET:
    backend: --remove-secrets=GOOGLE_CLIENT_ID,MCP_OAUTH_CLAUDE_CLIENT_ID,
      MCP_OAUTH_CLAUDE_CLIENT_NAME,MCP_OAUTH_CLAUDE_REDIRECT_URIS,
      STT_PRERECORDED_MODEL --no-traffic
    backend-sync/-sync-backfill/-integration:
      --remove-secrets=GOOGLE_CLIENT_ID,STT_PRERECORDED_MODEL --no-traffic
- validate-backend-runtime-env.py --check-workflows --check-rendered-cloud-run
  passes for dev and prod; check_deployment_secret_boundary.py passes.
- pytest tests/unit/{test_preflight_cloud_run_deploy,
  test_verify_dev_backend_deployment,test_backend_runtime_env_validator,
  test_repair_cloud_run_traffic,test_deploy_status_report,
  test_mcp_oauth_deploy_contract}.py -> 104 passed.

Prod traffic is pinned to a named revision and the migration revision is
created with --no-traffic, so no serving revision changes.
@mdmohsin7
mdmohsin7 merged commit af1fd58 into main Jul 17, 2026
32 of 36 checks passed
@mdmohsin7
mdmohsin7 deleted the fix/prod-cloud-run-legacy-binding-migration branch July 17, 2026 10:37
mdmohsin7 added a commit that referenced this pull request Jul 17, 2026
…9913)

## Problem

With the Cloud Run binding fix (#9911) merged, the prod deploy got all
the way through image build, all four Cloud Run services, GKE Helm, and
the post-deploy runtime-env validation — then failed at `Resolve
transcription candidate URL` (run
[29574215693](https://github.com/BasedHardware/omi/actions/runs/29574215693)):

```
ERROR: Cloud Run tag 'stt-gate-29574215693-1' has no valid HTTPS URL
```

The known-audio probe reaches the candidate revision over a Cloud Run
**tag URL**, which is a `run.app` URL. Production deliberately has no
`run.app` URL:

| | dev | prod |
|---|---|---|
| `run.googleapis.com/default-url-disabled` | unset | **`true`** |
| ingress | `all` | `internal-and-cloud-load-balancing` |
| `status.url` | `https://backend-…-uc.a.run.app` | **none** |

So a prod tag resolves to no HTTPS endpoint. This is not a transient
failure — it is structural, and it would fail **every** prod deploy. Two
independent blockers, in fact: even if the default URL were re-enabled,
ingress is internal-only while the deploy runs on `ubuntu-latest-m`, a
GitHub-hosted runner outside the VPC.

The gate works in dev only because dev is wide open.

## Why it went unnoticed

The gate landed in d4252a6 on **2026-07-13** — one day *after* the
last successful prod deploy (`d40d43be`, 2026-07-12) and one day
*before* the binding break (efca8b8, 2026-07-14). It has never
executed against prod. The binding bug masked it; fixing that bug
surfaced it.

## Change

Scope the `--tag` flag and the four gate steps to `development`. This
restores the 2026-07-12 prod behavior and matches the step's own
documented intent, already in the workflow:

> The manual development deployment runs this same no-traffic probe
before promotion, making it the required auth and route dry run for
production.

The gate keeps running on dev, where it works. The comment now records
*why* prod is excluded, so this isn't silently re-enabled.

Promotion steps (`Verify validated revisions are still current`, `Shift
Cloud Run traffic to validated revisions`) keep no `if:` — a **skipped**
step does not fail `success()`, so traffic promotion proceeds normally.

## Verification

- **Parsed the rendered workflow**: all four gate steps carry the
development condition; the `--tag` flag is development-gated; both
promotion steps still carry no `if:`.
- **Mutation-checked the new guard** — re-enabled the gate for prod and
confirmed the test fails with `Gate backend candidate on known audio
must be development-only; a production run cannot resolve a tag URL`,
then restored. The guard catches the real regression rather than
asserting a tautology.
- Confirmed prod's posture directly via `gcloud run services describe`
(`default-url-disabled=true`, `status.url` empty, ingress
internal-and-LB) and dev's (`ingress: all`, URL present).
- Confirmed no org policy sets `run.disableDefaultURI` — the annotation
is set on the service, deliberately.
- `pytest
tests/unit/{test_sync_two_lane,test_sync_ledger_fence_cutover,test_smoke_what_matters_now,test_resolve_cloud_run_tagged_url,test_verify_dev_backend_deployment,test_preflight_cloud_run_deploy}.py`
→ **86 passed**.

Prod is currently unchanged and safe: 100% traffic pinned to the
2026-07-12 revision, the #9911 candidate revision Ready at 0%, and the
failed tag cleaned up.

## Regression coverage

`test_transcription_candidate_gate_is_development_only` pins all four
gate steps and the tag flag as development-only, and asserts promotion
does not depend on the gate. Mutation-verified above.

## Follow-up

This removes the pre-promotion STT gate from prod, which is worth naming
explicitly: the pending `main` includes a change defaulting free-plan
live transcription to Parakeet, and that is exactly the class of
regression this gate was built to catch. Recommend a dev deploy to
exercise the gate against that change before promoting prod. Giving the
probe a prod-viable route (VPC-connected runner, or a probe path that
does not depend on a public revision URL) is separate work.

Failure-Class: none


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/9913?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
pull Bot pushed a commit to codingwatching/omi that referenced this pull request Jul 17, 2026
The known-audio probe reaches the backend candidate over a Cloud Run tag
URL, which is a run.app URL. Production deliberately serves no run.app URL
(run.googleapis.com/default-url-disabled=true) and restricts ingress to
internal-and-cloud-load-balancing, so a production tag resolves to no HTTPS
endpoint. The deploy runner is GitHub-hosted and outside the VPC, so it
could not reach such a URL even if one existed. The gate therefore cannot
work in production by construction; it works in dev only because dev runs
ingress `all` with the default URL enabled.

The gate landed 2026-07-13, one day after the last successful production
deploy (d40d43b, 2026-07-12), so it never executed against production
until the Cloud Run binding fix (BasedHardware#9911) unblocked the deploy far enough to
reach it. Run 29574215693 then failed at "Resolve transcription candidate
URL": `Cloud Run tag 'stt-gate-29574215693-1' has no valid HTTPS URL`.

Scope the tag and the four gate steps to development. This restores the
2026-07-12 production behavior and matches the step's own documented intent:
the manual development deployment runs this probe as the auth and route dry
run for production. Promotion steps keep no `if:`, so a skipped gate does
not block traffic shifting.

Verification:
- Parsed the rendered workflow: all four gate steps carry the development
  condition, the --tag flag is development-gated, and the two promotion
  steps still carry no `if:` (a skipped step does not fail success()).
- Mutation-checked the new guard: re-enabling the gate for production makes
  test_transcription_candidate_gate_is_development_only fail with
  "must be development-only; a production run cannot resolve a tag URL".
- pytest tests/unit/{test_sync_two_lane,test_sync_ledger_fence_cutover,
  test_smoke_what_matters_now,test_resolve_cloud_run_tagged_url,
  test_verify_dev_backend_deployment,test_preflight_cloud_run_deploy}.py
  -> 86 passed.

Production remains on the 2026-07-12 revision with 100% pinned traffic; the
candidate revision from BasedHardware#9911 is Ready at 0% traffic.
kodjima33 added a commit that referenced this pull request Jul 17, 2026
…ts (#9922)

## Summary

Prod chat (mobile TestFlight + App Store) went down after today's prod
backend deploy — every `POST /v2/messages` hung 122–560s (vs the normal
3–10s) until mobile clients gave up.

**Root cause:** `d83e37d21a` ("feat(llm-gateway): enable production
serving", merged Jul 13) turned on
`OMI_LLM_GATEWAY_FEATURE_MODE=gateway` for all prod backend services,
but the llm-gateway itself was never deployed to prod:

- Cloud Run services point at `http://172.16.160.108` — the static IP
`prod-omi-self-hosted-llm-ip-address` is **RESERVED with no forwarding
rule** (TCP blackhole; audit logs show no forwarding rule ever
attached).
- GKE `backend-listen` points at
`prod-omi-llm-gateway.prod-omi-backend.svc.cluster.local` — **no such
helm release/service exists** in the prod cluster.

Because prod deploys had been failing since Jul 14 (fixed by #9911), the
flag sat unshipped until today's deploy (`backend:7290a41`, ~11:43 UTC)
released it. Every `omi:auto:*` LLM call (chat_agent, chat_extraction,
fair_use, onboarding) then hung through connect timeouts + openai-client
retries before falling back to the direct path.

**This PR** flips the five prod `OMI_LLM_GATEWAY_FEATURE_MODE` entries
to `'off'` (Cloud Run backend / backend-sync / backend-sync-backfill via
anchor / backend-integration, plus GKE backend-listen), matching the
live mitigation already applied to prod, and updates the deploy contract
test to encode "wiring declared, serving off until the gateway is
actually deployed". URL/token wiring stays so re-enablement is a
one-line flip once a reachable prod gateway exists.

## Live mitigation already applied (prod is healthy now)

- Removed `OMI_LLM_GATEWAY_FEATURE_MODE` from Cloud Run `backend`
(revision `backend-01158-lmd`, 100% traffic), `backend-sync`,
`backend-sync-backfill`, `backend-integration`; same for GKE
`prod-omi-backend-listen` via `kubectl set env`.
- This PR makes the repo manifest match prod so the next deploy doesn't
re-break chat.

## Verification

- Before: real-user `POST /v2/messages` latencies 122s/248s/364s/505s on
`backend-7290a41`; gateway telemetry `outcome=error
reason=unexpected_error` (fair_use, onboarding) and `outcome=fallback
reason=timeout` (chat_agent, chat_extraction).
- After: real-user POSTs 3.5s/3.6s/8.8s 200 on `backend-01158-lmd`;
authenticated end-to-end send as a real user (`viUv7Gt…`) via
`https://api.omi.me/v2/messages` returned the AI reply over SSE in
**3.9s**.
- `pytest tests/unit/test_llm_gateway_deploy_contract.py
tests/unit/test_backend_runtime_env_validator.py` → 61 passed.
- `validate-backend-runtime-env.py --env dev --check-workflows` and
`--env prod --check-workflows` → both pass.
- `helm lint charts/backend-listen -f
prod_omi_backend_listen_values.yaml` → 0 failed.
- Note: `scripts/pre-deploy-check.sh` not run locally (uv cannot fetch
cpython 3.11.15 on this machine right now); CI runs the same contract.

## Product invariants affected

none

## Failure class (fixes)

Failure-Class: new

Adds `.github/failure-classes/FC-unprovisioned-rollout-target.json`: a
rollout flag routing production traffic to a service endpoint must not
be enabled for an environment until that endpoint is provisioned and
reachable there (evidence: #9651).

## Follow-up

- Deploy the llm-gateway to prod (helm release + ingress bound to
`prod-omi-self-hosted-llm-ip-address`, service token, Vertex WI perms)
before flipping FEATURE_MODE back to `gateway`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
undivisible pushed a commit to undivisible/omi that referenced this pull request Sep 29, 2026
…ts (BasedHardware#9922)

## Summary

Prod chat (mobile TestFlight + App Store) went down after today's prod
backend deploy — every `POST /v2/messages` hung 122–560s (vs the normal
3–10s) until mobile clients gave up.

**Root cause:** `d83e37d21a` ("feat(llm-gateway): enable production
serving", merged Jul 13) turned on
`OMI_LLM_GATEWAY_FEATURE_MODE=gateway` for all prod backend services,
but the llm-gateway itself was never deployed to prod:

- Cloud Run services point at `http://172.16.160.108` — the static IP
`prod-omi-self-hosted-llm-ip-address` is **RESERVED with no forwarding
rule** (TCP blackhole; audit logs show no forwarding rule ever
attached).
- GKE `backend-listen` points at
`prod-omi-llm-gateway.prod-omi-backend.svc.cluster.local` — **no such
helm release/service exists** in the prod cluster.

Because prod deploys had been failing since Jul 14 (fixed by BasedHardware#9911), the
flag sat unshipped until today's deploy (`backend:7290a41`, ~11:43 UTC)
released it. Every `omi:auto:*` LLM call (chat_agent, chat_extraction,
fair_use, onboarding) then hung through connect timeouts + openai-client
retries before falling back to the direct path.

**This PR** flips the five prod `OMI_LLM_GATEWAY_FEATURE_MODE` entries
to `'off'` (Cloud Run backend / backend-sync / backend-sync-backfill via
anchor / backend-integration, plus GKE backend-listen), matching the
live mitigation already applied to prod, and updates the deploy contract
test to encode "wiring declared, serving off until the gateway is
actually deployed". URL/token wiring stays so re-enablement is a
one-line flip once a reachable prod gateway exists.

## Live mitigation already applied (prod is healthy now)

- Removed `OMI_LLM_GATEWAY_FEATURE_MODE` from Cloud Run `backend`
(revision `backend-01158-lmd`, 100% traffic), `backend-sync`,
`backend-sync-backfill`, `backend-integration`; same for GKE
`prod-omi-backend-listen` via `kubectl set env`.
- This PR makes the repo manifest match prod so the next deploy doesn't
re-break chat.

## Verification

- Before: real-user `POST /v2/messages` latencies 122s/248s/364s/505s on
`backend-7290a41`; gateway telemetry `outcome=error
reason=unexpected_error` (fair_use, onboarding) and `outcome=fallback
reason=timeout` (chat_agent, chat_extraction).
- After: real-user POSTs 3.5s/3.6s/8.8s 200 on `backend-01158-lmd`;
authenticated end-to-end send as a real user (`viUv7Gt…`) via
`https://api.omi.me/v2/messages` returned the AI reply over SSE in
**3.9s**.
- `pytest tests/unit/test_llm_gateway_deploy_contract.py
tests/unit/test_backend_runtime_env_validator.py` → 61 passed.
- `validate-backend-runtime-env.py --env dev --check-workflows` and
`--env prod --check-workflows` → both pass.
- `helm lint charts/backend-listen -f
prod_omi_backend_listen_values.yaml` → 0 failed.
- Note: `scripts/pre-deploy-check.sh` not run locally (uv cannot fetch
cpython 3.11.15 on this machine right now); CI runs the same contract.

## Product invariants affected

none

## Failure class (fixes)

Failure-Class: new

Adds `.github/failure-classes/FC-unprovisioned-rollout-target.json`: a
rollout flag routing production traffic to a service endpoint must not
be enabled for an environment until that endpoint is provisioned and
reachable there (evidence: BasedHardware#9651).

## Follow-up

- Deploy the llm-gateway to prod (helm release + ingress bound to
`prod-omi-self-hosted-llm-ip-address`, service token, Vertex WI perms)
before flipping FEATURE_MODE back to `gateway`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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