Skip to content

fix(api): report admission saturation in /api/health without marking the proxy dead - #280

Open
ANAMASGARD wants to merge 1 commit into
dmnd-pool:masterfrom
ANAMASGARD:fix/health-check-saturation-signal
Open

fix(api): report admission saturation in /api/health without marking the proxy dead#280
ANAMASGARD wants to merge 1 commit into
dmnd-pool:masterfrom
ANAMASGARD:fix/health-check-saturation-signal

Conversation

@ANAMASGARD

Copy link
Copy Markdown

Summary

Fixes #244

When the proxy hits its max active downstream limit, it’s still healthy — it’s just not accepting new miners. Before this change, /api/health could return 503 based on signals that don’t reflect real admission capacity (handoff queue depth or stats count). Load balancers and operators could treat a live, working proxy as dead and keep sending miners to it anyway.

This PR separates liveness (“is the proxy up?”) from readiness (“can it take more miners?”):

  • 503 only when something is actually wrong: translator handoff channel is closed, or the proxy is globally down.
  • 200 when the proxy is alive, with a JSON body that reports saturation clearly.

Saturation is read from the ingress admission semaphore — the same gate that stops new TCP accepts when the proxy is full — not from the handoff queue (which drains quickly into background setup) or from stats.len() (which can lag).

What changed

Before After
Full handoff queue → 503 200 + handoff_backlog_full: true
stats.len() >= max → 503 200 + saturated: true (from semaphore)
Alive and healthy → 200 "Proxy OK" 200 with structured body

Example response when alive but at capacity:

{
  "success": true,
  "data": {
    "status": "ok",
    "saturated": true,
    "handoff_backlog_full": false,
    "message": "Proxy is alive but admission saturated: not accepting new connections"
  }
}

Fixes dmnd-pool#244
Return HTTP 200 when the proxy is alive but at max active downstreams.
Saturation is read from the ingress admission semaphore (ground truth),
not handoff queue depth or stats.len(). Handoff backlog is exposed as
a readiness field (handoff_backlog_full) instead of HTTP 503.
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.

health check must return 200 when proxy is saturate (max number of active connection raeched)

1 participant