Skip to content

[gateway] Add a health check usable by Kubernetes probes #834

Backlog

Description

@hossain-rayhan

Problem

Kubernetes can only probe the gateway with tcpSocket today. The kernel completes the TCP handshake while the listener socket is open, so a gateway whose runtime is deadlocked, whose connection pool is exhausted, or that is stuck on a dead backend still passes, is never restarted, and keeps receiving traffic. The DocumentDB Kubernetes operator and users running the gateway on their own CloudNativePG both need a real check (documentdb/documentdb-kubernetes-operator#522).

What exists today doesn't cover this:

  • documentdb_gateway check starts a new process that tests PostgreSQL connectivity. It doesn't tell whether the running gateway is serving, and as a liveness probe it would restart a healthy gateway whenever PostgreSQL is down.
  • ping/hello work without authentication and exercise the listener, TLS and request loop, but the gateway image has no client to send them from an exec probe.
  • Every probe connection is logged as ERROR … Gateway runtime connection failed ([gateway] Restart, shutdown and outage handling gaps #768 item 6), so any probe floods the logs and breaks error-based alerting.

Proposal

  1. documentdb_gateway probe subcommand for exec probes. It connects to the local listener (honoring the configured TLS; skip certificate verification for loopback), sends hello, and exits 0 on a valid reply within --timeout (default 2 s), 1 otherwise. No credentials needed. This detects a hung runtime or listener, which is what a liveness probe needs.
  2. Readiness mode (probe --ready, or a loopback-only HTTP/Unix-socket endpoint): also confirms the running process can get a connection from its PostgreSQL pool within the timeout, so a gateway with an exhausted or broken pool reports not ready. This must run inside the gateway process, not as a separate process like check.
  3. Quiet probe connections: log connections that close before sending a complete request, and probe connections, at debug, not error ([gateway] Restart, shutdown and outage handling gaps #768 item 6).
  4. Document recommended probe settings (period, timeout, failure threshold).

Acceptance

  • probe returns 1 within the timeout when the request loop is blocked, and 0 on a healthy gateway, with TLS on and off.
  • probe --ready returns 1 while the PostgreSQL pool can't hand out a connection.
  • A probe every 10 s produces no ERROR log lines.

Related

Activity

  1. added
    enhancement
    gateway
    on Nov 24, 2026
  2. documentdb-triage-tool commented on Nov 24, 2026

    @documentdb-triage-tool

    🤖 Auto-triaged by documentdb-triage-tool.

    Applied: gateway, enhancement
    Project fields suggested: Component gateway · Priority P2 · Effort L · Status Triage
    Confidence: 0.90 (llm)

    Reasoning

    LLM: Adds a new probe subcommand plus readiness mode and log-level fixes across the gateway component, touching multiple files and runtime behavior for Kubernetes operability.

    If a label is wrong, ping @patty-chow so the rules can be tuned. Issues with component labels are left alone; PR component labels are reconciled from changed paths on every run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgateway

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions