Skip to content

Fix unhealthy health check in GCP ALB for pusher endpoints - #6335

Merged
beastoin merged 1 commit into
mainfrom
task/fix-unhealthy-pusher-pod-on-alb
Apr 7, 2026
Merged

beastoin merged 1 commit into
mainfrom
task/fix-unhealthy-pusher-pod-on-alb

Conversation

@thainguyensunya

@thainguyensunya thainguyensunya commented Apr 5, 2026 •

Copy link
Copy Markdown
Collaborator
  • pusher/main.py — Make /health endpoint async
  • router/pusher.py — Offload blocking get_google_maps_location HTTP call to thread pool in conversation task
  • utils/app_integrations.py — Wrap trigger_realtime_integrations and trigger_realtime_audio_bytes in asyncio.to_thread()
  • utils/webhooks.py — Wrap requests.post() in realtime_transcript_webhook with asyncio.to_thread()
  • utils/webhooks.py — Offload blocking requests.post in send_audio_bytes_developer_webhook to thread pool
  • charts/pusher/prod_omi_pusher_values.yaml — Switch K8s probes from tcpSocket to httpGet /health
  • charts/pusher/prod_omi_pusher_values.yaml — Migrate pusher to n4-highmem-2 node pool for better price/performance

@thainguyensunya
thainguyensunya requested a review from beastoin April 5, 2026 06:10
@greptile-apps

greptile-apps Bot commented Apr 5, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes unhealthy GCP ALB health checks for the pusher service by switching K8s probes from tcpSocket to httpGet /health, making the /health endpoint async, and wrapping blocking sync calls in asyncio.to_thread() to prevent event loop starvation. It also migrates the prod deployment to the v3 (n4-highmem-2) node pool and removes per-zone scheduling preferences.

  • pusher/main.py: health_check is now async, ensuring the endpoint is served directly on the event loop and reflects true application responsiveness — not just whether a TCP port is open.
  • utils/app_integrations.py: trigger_realtime_integrations and trigger_realtime_audio_bytes now use asyncio.to_thread(), correctly offloading their blocking threading.Thread.join() calls from the event loop.
  • utils/webhooks.py: realtime_transcript_webhook correctly wraps requests.post in asyncio.to_thread(), but the sibling async function send_audio_bytes_developer_webhook still calls requests.post directly — the same blocking pattern that was fixed elsewhere in the file.
  • Helm charts: Both dev and prod switch from tcpSocket to httpGet /health probes. In prod, startupProbe.failureThreshold was halved from 60 → 30 (10 min → 5 min max startup window), which may be tight during large-scale scheduling events.

Confidence Score: 3/5

Safe to merge with one missed blocking-call fix and a startup probe threshold worth revisiting

The core fix is correct and well-targeted: async health endpoint + asyncio.to_thread wrapping properly prevents event loop starvation and makes health probes reflect real application responsiveness. However, send_audio_bytes_developer_webhook still calls blocking requests.post directly in an async function — the exact same pattern fixed elsewhere in the same PR. The prod startupProbe halving from 60→30 is a minor operational risk during large scale-out events.

backend/utils/webhooks.py (send_audio_bytes_developer_webhook missing asyncio.to_thread fix), backend/charts/pusher/prod_omi_pusher_values.yaml (startupProbe failureThreshold reduced 60→30)

Important Files Changed

Filename Overview
backend/pusher/main.py Makes /health endpoint async — trivially correct and directly fixes the event-loop-block → unhealthy probe issue
backend/utils/app_integrations.py Wraps _trigger_realtime_integrations and _trigger_realtime_audio_bytes in asyncio.to_thread() — correct fix, prevents event loop blocking during sync thread joins
backend/utils/webhooks.py Fixes realtime_transcript_webhook with asyncio.to_thread but leaves send_audio_bytes_developer_webhook with a blocking requests.post in an async function
backend/charts/pusher/prod_omi_pusher_values.yaml Switches probes to httpGet /health, removes zone preferences, migrates to v3 node pool; startupProbe failureThreshold halved from 60→30 in prod (5 min max vs 10 min)
backend/charts/pusher/dev_omi_pusher_values.yaml Switches probes from tcpSocket to httpGet /health with adjusted thresholds — dev environment, changes are low-risk

Sequence Diagram

sequenceDiagram
    participant ALB as GCP ALB
    participant K8s as Kubernetes
    participant Pusher as Pusher Pod
    participant EventLoop as Uvicorn Event Loop
    participant Thread as Thread Pool

    Note over ALB,Pusher: Before PR — tcpSocket probe (port open only)
    ALB->>K8s: tcpSocket :8080 probe
    K8s-->>ALB: TCP ACK (passes even if event loop is blocked)

    Note over ALB,Pusher: After PR — httpGet /health (application-level)
    ALB->>Pusher: GET /health HTTP
    Pusher->>EventLoop: async health_check()
    EventLoop-->>ALB: 200 {status: healthy}

    Note over EventLoop,Thread: Blocking calls moved off event loop
    EventLoop->>Thread: asyncio.to_thread(_trigger_realtime_integrations)
    Thread->>Thread: spawn worker threads + join
    Thread-->>EventLoop: done (event loop free during wait)

    EventLoop->>Thread: asyncio.to_thread(requests.post) [realtime_transcript_webhook ✓]
    Thread-->>EventLoop: HTTP response

    Note over EventLoop: ⚠ send_audio_bytes_developer_webhook still calls requests.post directly
Loading

Comments Outside Diff (1)

  1. backend/utils/webhooks.py, line 158-176 (link)

    P1 send_audio_bytes_developer_webhook still blocks the event loop

    This PR correctly wraps requests.post in asyncio.to_thread() for realtime_transcript_webhook (line 120), but the sibling async function send_audio_bytes_developer_webhook at line 169 still calls requests.post directly — a blocking network call in an async context that ties up the uvicorn event loop for the full timeout=15 duration per call.

    This is exactly the same pattern the PR set out to fix. The asyncio.to_thread import is already present. Suggest applying the same fix:

Reviews (1): Last reviewed commit: "Fix unhealthy health check in GCP ALB fo..." | Re-trigger Greptile

@thainguyensunya
thainguyensunya force-pushed the task/fix-unhealthy-pusher-pod-on-alb branch 2 times, most recently from 53a18ee to 0dff27a Compare April 5, 2026 09:38
@beastoin

beastoin commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

lgtm

@beastoin
beastoin merged commit 7ceed3e into main Apr 7, 2026
3 checks passed
@beastoin
beastoin deleted the task/fix-unhealthy-pusher-pod-on-alb branch April 7, 2026 02:02
Glucksberg pushed a commit to Glucksberg/omi-local that referenced this pull request Apr 28, 2026

This branch was previously deployed

1 inactive deployment
prod — 540464f8 Deployed Apr 5, 2026 by thainguyensunya via deploy #157
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.

2 participants