Repository navigation
fix(parakeet): scope GPU autoscaling to Parakeet workloads - #21673
Conversation
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: c07fcc4975
ℹ️ 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".
| for field, (before, after) in gpu_changes.items(): | ||
| if gpu.get(field) not in (before, after): | ||
| raise ValueError(f'Unexpected live Parakeet GPU {field}: reconcile and review first') | ||
| gpu[field] = after |
There was a problem hiding this comment.
Reject half-applied GPU query transitions
When the live ConfigMap has only one GPU field reconciled—for example, a scoped seriesQuery but the old namespace-wide metricsQuery—this loop accepts each field independently and rewrites both to the new values, so compare() reports no error. That admits an unreviewed mixed state through the production HOLD gate even though the runbook permits only the complete old pair or complete new pair; validate the two fields together against those exact states before normalizing them.
Useful? React with 👍 / 👎.
#23441) Production Parakeet rollback currently depends on the P77 laptop process surviving. Add an independent Kubernetes CronJob that can perform only the pre-approved drift-checked HPA rollback, plus a batch observer that clearly reports incomplete coverage. ## Behavior and deployment - Every 5m, Forbid overlap, 240s deadline, no retries; small non-root CPU-only Python Job using the existing digest-pinned monitoring image. - Arm only workloadOnly floors 5/8 without the latency metric, after a full 15m observed HPA configuration/generation and image window. Ordinary autoscaling replica changes preserve the arming clock. Persist the clock and K=3 consecutive blind readings in one name-scoped ConfigMap. Missing/stale/nonfinite data never passes as clean. Fresh low-count samples, including successful undefined idle histogram/ratio arithmetic, report LOW_SAMPLE without tripping quiet hours; missing series/query errors remain blind. - Preserve P77 thresholds and exact `step_fast.build(old,12,True)` patch/drift assertions. JSON Patch tests the entire observed `/spec`; sets min=12 and restores `parakeet_request_latency_p99` Value=3. No serving Deployment writes. - The mounted entrypoint uses the shared dependency-free structured logger. Add an explicit ConfigMap launch binding to the logging guard, verifying source/mount wiring and byte equality of the generated logging-module copy; no logging exemption or pending allowance. - Dedicated KSA: named HPA get/patch, named deployment get, namespace events list, named state ConfigMap get/patch. No secrets, exec, cluster RBAC or GCP WI annotation. - Existing batch queue metrics are scraped through a PodMonitor installed by this release. Fresh oldest uncommitted age >30m emits TRIP/log/annotation and fails the Job. This is a historical-inclusive proxy, not proof of a new projection wedge. **Lead dispatch after merge:** workflow `gcp_incluster_guards.yml` (Deploy In-cluster Safety Guards) on `main`, inputs `environment=prod`, `source_sha=<full merged SHA>`, `dry_run=false`, `enabled=true`. Dev: `environment=development`, same merged SHA; workflow forces dry-run. This installs only `prod-omi-incluster-guards` in `prod-omi-backend`; it never invokes the Parakeet rollout workflow. Kill switch: same dispatch with `dry_run=true`; remove resources with `enabled=false`. Inspect scheduled readings and full-window arming before retiring the P77 owner. After this exact head is merged, the lead can dispatch: ```bash gh workflow run gcp_incluster_guards.yml --repo BasedHardware/omi --ref main \ -f environment=prod -f source_sha=4d712a5b8a22eae0395774b5ac2428d0a1c7327e \ -f dry_run=false -f enabled=true ``` ## Explicit v1 blockers / lead and David asks 1. **Batch is partial.** No Prometheus metric exists for new projection obligations >15m, pinned-object custody loss or VAD-proven speech loss. Those are recorded as unavailable, never clean. Retain the P90 guard until the missing signals are implemented and verified. Queue age includes historical/deep obligations, so it is alert-only and never rolls back admission. 2. **Alert delivery needs activation verification.** Existing monitoring disables Alertmanager; Grafana owns pages. This chart emits structured JSON, failed Jobs and state annotations but cannot assert a page is delivered. The runbook includes a bounded-age failed-Job query; lead must wire/verify the Grafana route before unattended reliance. Verify live backend -> monitoring TCP/9090 network policy too; the committed policy selects only listen-edge pods. 3. **Future Cloud Run rollback requires David's specific access approval.** `batch.cloudRunRollbackEnabled=false` is reserved and fails rendering if enabled in v1; no Cloud Run read or write path exists. Proposed GSA `[email protected]`; on it bind `roles/iam.workloadIdentityUser` to `serviceAccount:based-hardware.svc.id.goog[prod-omi-backend/prod-omi-incluster-guards]`, then annotate only that KSA with `iam.gke.io/gcp-service-account=<GSA>`. Bind custom `projects/based-hardware/roles/omiBatchAdmissionGuard` (`run.services.get`, `run.services.update`, `run.revisions.get`) to the GSA on each `us-central1` service `backend`, `backend-sync`, `backend-sync-backfill`, `backend-integration`; grant `run.operations.get` via a separate project-scoped custom role, and `roles/iam.serviceAccountUser` only on each actual runtime SA if required for actAs. Reads need Cloud Run IAM too. Separate metadata-read approval is needed for Firestore/GCS if the missing P90 signals are not exported first. None of these access changes is made by this PR. A follow-up must verify every traffic-serving revision, preserve unrelated config/custody/recovery, set only `BATCH_PIPELINE_PERCENT=0`, and honor the P90 fresh-state clocks. 4. **CI timing blocker:** on final head `4d712a5b8a22eae0395774b5ac2428d0a1c7327e`, backend shard 1 completed its assertions but failed its wall-time gate: **722s versus 720s**. All other checks passed. Evidence: [failed shard](https://github.com/BasedHardware/omi/actions/runs/40010965857/job/120610932767). No duration budget or check was weakened. A prior head also exceeded by one second and passed a failed-only rerun; this final-head timing failure remains open. The proposed identity bindings apply Google's [GKE impersonation procedure](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/workload-identity) and [Cloud Run IAM permissions](https://docs.cloud.google.com/run/docs/reference/iam/permissions); the actual project/service bindings remain an approval-gated proposal. Why isn't this a shared primitive instead? This is the reusable in-cluster implementation of the existing P77 process, removing laptop liveness from the rollback boundary; it does not add another developer checklist. The real instance is the 2026-10-23 P77 workloadOnly floor ramp protected by `guard_fast.py`/`step_fast.py`. Related merged autoscaling incident: #21673 (GPU metrics were scoped to unrelated workloads). The original drift assertions protect that autoscaling boundary; we do not silently rewrite its metrics on unexpected drift. ## Verification All commands run through `/Users/david/workspace/omi-workspace/bin/omi-heavy run -- ...` with ambient Google/Firebase/Kubernetes credential paths unset for tests. No kubectl/helm/gcloud cluster calls, deployment, workload env reads, or production API requests were made. - `cd backend && .venv/bin/python -m pytest tests/unit/test_incluster_guards.py tests/unit/test_logging_entrypoint_guard.py tests/unit/test_backend_unit_selector_output.py -q` — 186 passed (1.02s); production one-shot path with fake APIs, ± thresholds, low samples, blind persistence, arming resets, drift refusal, frozen P77 patch equivalence, Prometheus failures, dev/prod Helm rendering and exact RBAC/CPU placement. Monitor URLs and release labels are checked against the existing adapter and Parakeet values, including the distinct dev stack name. - `actionlint .github/workflows/gcp_incluster_guards.yml` — passed. - `python3 .github/scripts/check-deployment-concurrency.py` — passed (31 persistent writers). - `python3 .github/scripts/check_ci_budget.py --refresh` — reviewed: manual-only guard deploy, zero PR runs, 5m p50, Backend infrastructure owner. - `make preflight` with `OMI_PR_BODY_FILE=/tmp/incluster-guards-pr-body.md` — **44 checks passed in 191.21s**, including the mounted-script logging inventory. The normal pre-push gate also passed: 44 manifest checks (180.20s), full backend typing with 0 errors, runtime source closure, selected unit tests, and the remaining bounded hooks. Full typing reports 0 errors. ## Product invariants affected - INV-DATA-1 — the workflow selects the existing environment/cluster deploy identity and installs only guard resources. It introduces no client, Firebase, Firestore, or serving-authority routing change. Failure-Class: none <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/23441?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/23441?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F23441&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. --> 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Parakeet's GPU HPA currently averages DCGM utilization for every GPU workload in the backend namespace. A read-only production check returned about 3.97% through the external metric while Parakeet alone was about 1.05%; VAD, NLLB and diarizer activity entered the scaling signal.
Scope discovery and utilization queries to
container="parakeet"in both the chart-owned definition and production cluster-wide adapter. The deployment comparator now accepts the reviewed old-to-new Parakeet query transition, so the documented upgrade can reach Helm. Unknown live queries and missing/duplicate GPU rules fail closed; exact-live rollback comparison remains strict. The runbook names the complete set of allowed rule differences.Admission remains 2 requests / 35%, with floors unchanged. The installed HPA consumes requests and GPU with 600s down stabilization and one pod removed per 600s; the source chart's 900s/p99 policy is not installed and is unchanged here. No production rollout was performed. DCGM remains whole-device utilization on physically shared GPUs, so this change does not qualify co-location.
Validation:
--require-live-configstill rejects the candidate upgrade as a rollback.make preflightand bounded pre-push checks run before publication; GitHub CI remains authoritative.Production adapter rollout must verify the external API agrees with the Parakeet-only query before any scaling-policy change. The lead ships this PR; no merge or deployment is requested.
Product invariants affected
none
Failure-Class: none