Repository navigation
fix(deploy): re-land sync GMP savings without collector secrets - #22118
Conversation
# Conflicts: # .github/actions/deploy-backend-stack/action.yml # backend/deploy/cloud_run_gmp_sync.yaml # backend/docs/runbooks/cloud-run-metrics-ingestion.md # backend/scripts/attach_cloud_run_gmp_sidecar.py # backend/tests/unit/test_attach_cloud_run_gmp_sidecar.py # backend/tests/unit/test_fleet_deployment.py
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5b1abfdb75
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| dict(SYNC_COLLECTOR_LIMITS) | ||
| if metadata.get('name') in SYNC_SERVICES |
There was a problem hiding this comment.
Avoid unsupported fractional CPU on gen2 sync revisions
For every sync/integration attachment this selects 0.08 vCPU, while the same patch unconditionally sets run.googleapis.com/execution-environment=gen2 and cpu-throttling=false; these services also retain concurrency above 1 (integration is deployed with 40). Cloud Run's CPU requirements require sub-1-vCPU configurations to use first generation, request-based billing, and concurrency 1, so the real gcloud run services replace can reject each candidate and block the backend deployment. Keep the collector at at least 1 vCPU or change the surrounding service settings to a supported combination.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The per-container 0.08 CPU limit is deliberate; the app retains 2 vCPU, so total instance CPU is 2.08, not a fractional instance below 1. The existing runbook resource-validation section records real gcloud run services replace --dry-run acceptance separately for backend-sync, backend-sync-backfill, and backend-integration with gen2, concurrency, and instance billing retained (including rejection controls for 0.079 CPU and 64Mi). Those are prior control-plane receipts, not a new probe or runtime/load qualification in this PR task. Google documents instance CPU as the sum of container limits: https://docs.cloud.google.com/run/docs/about-instance-autoscaling#autoscaling_and_multiple_containers_sidecars . I also corrected an older contradictory cost paragraph in the same runbook; the backend/desktop 1-vCPU collector allocation remains unchanged. Retaining the validated sync allocation and explicit runtime-readiness/memory/scrape acceptance requirement rather than changing service billing/concurrency.
| if name not in retained_secret_names: | ||
| entries.pop(name, None) | ||
| if entries: | ||
| annotations[SECRET_ANNOTATION] = _render_secret_annotation(entries) |
There was a problem hiding this comment.
Normalize retained secret annotations before replacing
When a base service export contains an application-secret annotation such as projects/based-hardware/secrets/..., the new config-env branch removes the collector aliases but renders every retained entry without _normalize_secret_resource. This regresses the normalization performed by the former _merge_secret_annotation path: Cloud Run accepts the project-ID form during this replacement, but the repository's documented gcloud parser rejects it on the next deploy with Invalid secret path, potentially wedging subsequent backend rollouts. Normalize all retained entries with project_number before writing either annotation.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in e676025. Both retained annotation maps now pass each resource through _normalize_secret_resource(..., project_number=...) before rendering, matching the legacy path. The broad/sync env-config regression now covers both project-ID and project-number annotations, proves the app alias normalizes to the numeric project, and still removes only unused collector aliases. Focused suite: 129 passed. No live service/secret mutation performed.
#22926) ## Summary Restore the Firestore reads loop's visibility into `backend-sync`, `backend-sync-backfill` and `backend-integration`. #22118 (merged 2026-10-18 08:26Z, live ~13Z) gave those three services a revision-local GMP keep-regex. The regex omits `omi_firestore_billed_reads_by_{caller,origin}_total`, `omi_firestore_caller_label_overflow_total` and `omi_fsr_leader_lease_total`. Since then: - **Attribution blind spot.** The three services disappeared from per-caller read attribution in Managed Prometheus. At the 10-18 08Z trough they carried 320M reads/day (GMP 24h: sync 142.4M, backfill 150.4M, integration 26.9M). By subtraction they now carry about 500M of the fleet's 926M/day. That's the largest growth in the 10-18 → 10-20 regression (648M → 1007M/day), and the loop could not rank it. - **False lever flag-off.** The `singleton_loops` lease gate went blind to holders on those services. On 10-20 09Z, listen showed `skipped_owner` 44–69/h with `acquired=0`. The loop graded that as starvation and flagged the lever off (#22851). In `fsr_admit`, a recovery loop returns `skipped_owner` only while the tick key is live, and only an admission sets that key, so the work was running on an unscraped holder. This PR keeps the four families: about 270 series per instance on 10-18, against the sidecar's `samples: 10000` limit. It also pins them in `test_sync_scrape_retains_exporter_and_direct_sentinel_consumers`, so a future trim fails in CI instead of at ingestion. Predicted reads/day saved: **0 directly**. It restores attribution for about 55% of fleet reads and the lease evidence needed to re-ramp `singleton_loops`, which measured −119M/day on its callers at 100% on 10-17. Measurement line: after the Cloud Run train, `avo/firestore-reads/measure.py` shows `origins.missing_services == []` and `coverage_1h` ≥ 0.8 (0.381 at 10-20 18Z). The GMP query `sum by (service_name) (increase(omi_firestore_billed_reads_by_caller_total[1h]))` returns rows for all three services again. ## Lane / contract fs-regress (P1, two-lane rollout swarm 10-20). Owner sign-offs: none needed; the sync scrape profile comment block already says consumer changes update the allowlist and its test together. ## Product invariants affected none ## Verification - `backend/test.sh` with `BACKEND_UNIT_TEST_FILE_LIST` = `test_attach_cloud_run_gmp_sidecar.py` + `test_parakeet_request_metrics.py`: 7 passed (unit layer; regex contract only). - Prod series counts (GMP, `ro-prod`, aggregates): `max by (service_name) (count by (service_name, instance) (omi_firestore_billed_reads_by_caller_total))` at 10-18 08Z: sync 149, backfill 140, integration 115; origin series 100/62/79. - Not run: a collector startup or prod scrape. That's the deploy layer, measured by the line above. ## Rollback Revert this commit; the next Cloud Run train drops the four families again. No application behavior depends on the scrape. ## Deploy Cloud Run train (`backend-sync`, `backend-sync-backfill`, `backend-integration` revisions pick up the collector config). Owned by the rollout lead. Failure-Class: FC-metric-dropped-by-scrape-allowlist 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/22926?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="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/22926?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F22926&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
…et; singleton_loops 25% (#22929) ## Summary Re-graduate two proven Firestore read levers stuck below 100%, and restart `singleton_loops` at 25%. This changes only the `FIRESTORE_READ_LEVERS` literal: runtime_env `_base.yaml` → rendered `runtime_env.yaml`, listen + pusher dev/prod values, flag registry, and the two contract tests that pin the literal. Generated with `avo/firestore-reads/set_levers.py` as the complete 13-key literal. | Lever | From → to | Evidence | Predicted reads/day saved | |---|---|---|---| | `usage_month_cache` | 5 → 100 | −45.0M/day absolute at 100% on 10-17 (loop readout `readout-2026-10-17T20Z-absolute.json`). It was flagged off 10-18 on an ambiguous backend-sync 5xx guard that stayed elevated with the lever at 0, then ran at 5% from 10-20 05Z with guards in band. | **~35–39M**. Its caller `user_usage:get_monthly_usage_stats_since` is 43.2M/day now (listen 33.1M + backend 10.1M, 24h to 10-20T17Z) vs ~4.9M/day at 100% on 10-17. | | `queue_age_sample_budget` | 5 → 100 | At 5% since 10-20 05Z with no guard breach (WQ3, reviewed SAFE in #22142). | Unknown until measured. Caller `durable_queue_age:_sample_status_page` is 46.8M/day visible (listen 40.3M, backend 6.5M) plus the sync services. It overlaps `singleton_loops`; never sum the two. | | `singleton_loops` | 0 → 25 | At 100% on 10-17: −119M/day on its callers (ledger READOUT 2026-10-17T05:20Z). The 10-20T09Z flag-off (#22851) read `acquired=0 / skipped_owner>0` on listen. `fsr_admit` returns `skipped_owner` for a recovery loop only while the tick key is live, and only an admission sets it, so the holder ran on backend-sync, whose lease counter #22118 hid (fixed in the companion PR). 25% first per the loop runbook until lease evidence is visible on every service. | Unknown at 25%. Visible callers are 93M/day on listen + backend. Per-process cohorts mean savings scale with the cohort share. | Measurement line: the Firestore reads loop (`avo/firestore-reads`) grades each lever from the served revision. `usage_month_cache` is graded on absolute caller reads vs `baseline-2026-10-20T05-00Z.json` (`get_monthly_usage_stats_since` 1.24M reads/h on backend). Fleet total is `progress.py` HEADLINE (926M/day at 10-20T17Z). ## Lane / contract fs-regress (P1, two-lane rollout swarm 10-20), on behalf of the `firestore-reads` loop (work items WQ8, WQ3, WQ1 → WQ10). ## Product invariants affected INV-MEM-4: path match only. The lever literal appears in a file under the INV-MEM-4 glob; no memory promotion, consolidation or intake behavior changes. `historical_scan_memo` and the other memory-path levers keep their current values. ## Verification - `backend/test.sh` with `BACKEND_UNIT_TEST_FILE_LIST` = `test_render_backend_runtime_env.py`, `test_verify_pusher_config_references.py`, `test_firestore_read_levers.py`, `test_fsr_s2_singleton_loops.py`, `test_fsr_wq3_queue_age_budget.py`, `test_fsr_s4_caches.py`: 70 passed (unit layer). - Precondition from the loop runbook for any `singleton_loops` enable: `FSR_QUEUE_AGE_PUBLISHER=1` in prod listen values, and `omi_queue_oldest_ready_age_seconds` present on listen (200 series) and Cloud Run (490) at 10-20 18:30Z (in-cluster Prometheus, `ro-prod`). - Not run: any deploy. Live effect is measured by the loop after the lead's train. ## Rollback Each lever is its own kill switch. `set_levers.py` with the previous literal (`usage_month_cache` 5, `queue_age_sample_budget` 5, `singleton_loops` 0), or revert this commit. The loop's hourly verify flags a lever off on a 5xx or lease breach. ## Deploy `FIRESTORE_READ_LEVERS` train order: **listen → pusher → Cloud Run** (the Cloud Run candidate check compares listen/pusher env against main). Ship together with or after the companion sync-GMP scrape PR, so the `singleton_loops` lease gate can see every holder. Owned by the rollout lead. Failure-Class: none 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/22929?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="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/22929?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F22929&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
BasedHardware#22118 gave backend-sync, backend-sync-backfill and backend-integration a metric keep-regex that omits omi_firestore_billed_reads_by_{caller,origin}_total, omi_firestore_caller_label_overflow_total and omi_fsr_leader_lease_total. From 2026-10-18 ~13Z those three services vanished from per-caller read attribution (320M reads/day at the 10-18 trough; ~500M/day now by subtraction) and from the singleton_loops lease gate, which then graded a healthy backend-sync lease holder as starvation and flagged the lever off (BasedHardware#22851). Keep the four families (~270 series per instance against the 10000-sample limit) and pin them in the scrape contract test. Failure-Class: FC-metric-dropped-by-scrape-allowlist Co-Authored-By: Claude Opus 5.5 <[email protected]>
…et; singleton_loops 25% FIRESTORE_READ_LEVERS literal only (runtime_env, listen + pusher values, flag registry, two pinned contract tests): - usage_month_cache 5 -> 100: measured -45.0M reads/day at 100% on 10-17; flagged off 10-18 on an ambiguous backend-sync 5xx guard that stayed elevated with the lever at 0. Its caller is 43.2M/day now (listen 33.1M, backend 10.1M, 24h to 10-20T17Z). - queue_age_sample_budget 5 -> 100: 5% since 10-20 05Z with no guard breach. - singleton_loops 0 -> 25: the 10-20T09Z "starvation" flag-off (BasedHardware#22851) read acquired=0 / skipped_owner>0 on listen; skipped_owner proves a live tick key, i.e. an admission on a holder whose lease counter BasedHardware#22118 hid. 25% first per the loop runbook until lease_1h is visible on every service. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Re-land the sync GMP cost profile from #22089 without a new secret, secret version, IAM grant, or image build for the backend stack. The failed production deploy was run 39101727125:
omi-ci-deployer-prodcannot createcloud-run-gmp-sync-config. Production traffic was restored; this PR does not deploy or merge anything.Chosen option B: secret-free, revision-local collector configuration. Revert #22116 merged on October 18, 2026 at 07:21:12 UTC (
e55569a0305225182d99ca0cd84c09cadd11460a). This branch incorporates that main commit without force-pushing or rewriting the recovered work./bin/sh,/run-gmp-entrypoint, and a file-based RunMonitoring loader. It does not accept a RunMonitoring--config=env:...override. Write the quoted non-sensitive collector env value into/etc/rungmp/config.yaml, thenexecthe unchanged entrypoint. Noeval; arbitrary config text remains data.Validation
nice -n 19 backend/.venv/bin/python -m pytest backend/tests/unit/test_attach_cloud_run_gmp_sidecar.py backend/tests/unit/test_preflight_cloud_run_deploy.py backend/tests/unit/test_fleet_deployment.py -qthroughomi-heavy.secrets.createand every collector Secret Manager call: both config attachments succeed without making those calls. A missing application secret exits before the representative revision mutation, binding migration, or traffic repair.$()/${...}, fail-closed empty config handling, and entrypoint execution. Local tests do not claim a Linux collector startup or production scrape/load acceptance.f782d8c67ad3f0e54d791fbf7cc6c8d36bc9e15c4b68d8b38ef372674defe452, entrypoint/run-gmp-entrypoint, Linux/amd64 Alpine shell, embedded/etc/rungmp/config.yamland collector version 1.2.0.Rollout And Rollback
No production deployment, secret access, IAM change, or traffic change is performed by this PR task. GCP identity tier: none (public registry inspection only). Existing candidate readiness and promotion gates remain authoritative. Validate fresh retained metric samples and collector memory under load before production promotion; the control-plane dry-run evidence for the resource allocation is not runtime acceptance.
Rollback uses the prior serving revisions, which retain their original config. Restore the broad sync scrape profile and resource allocation in a follow-up deploy if needed; do not rewrite/delete historical secrets or change CPU billing as a shortcut.
Product Invariants Affected
none
Failure Class
Failure-Class: FC-gate-hides-its-operator-prerequisite
Run 39101727125 discovered an unprovisioned config-secret prerequisite after candidate mutation. The canonical prevention is the early required-secret/config preflight plus denied-create/no-Secret-Manager regression tests; the existing failure-class guard-artifact list includes these tests and the deploy helper. This removes the collector prerequisite rather than requesting a wider CI identity.