Skip to content

sidecar-injector: configurable probes for the gateway container (and a real health check) #522

Open

Description

@utkuerol

Context

We run the DocumentDB gateway on our own CloudNativePG operator, using only the cnpg-i-sidecar-injector.documentdb.io plugin to inject the gateway container.

Problem

The injected gateway container has no readiness or liveness probe, and the plugin has no parameter to add one. A gateway that is still running but has stopped serving requests (deadlocked runtime, exhausted pool, stuck on a dead backend) is never restarted, and the pod stays Ready. Clients keep getting routed to it.

#475 adds a fixed tcpSocket liveness probe. That helps when the process is not listening, but it cannot detect a hang. The kernel completes the TCP handshake while the listening socket is open, whatever the gateway process is doing. It is also not configurable, and it adds no readiness signal.

Proposal

  1. Plugin parameters for the gateway container probes, e.g. gatewayLivenessProbe, gatewayReadinessProbe, gatewayStartupProbe as JSON-encoded corev1.Probe, like labels and gatewayArgs are encoded today. Unset keeps the current default (none, or whatever feat: add PostgreSQL, catalog, data volume, and network metrics to the OTel sidecar, plus gateway liveness probes #475 lands).
  2. A health check that exercises the request path rather than the socket. Either:
    • a lightweight health endpoint in the gateway (HTTP, or a local socket) that reports whether the listener and the Postgres pool are working, or
    • a small exec helper in the gateway image that sends a Mongo hello / ping over the wire protocol (TLS-aware) and exits non-zero on timeout.

Whichever check is used, it should not log ERROR ... InternalError on every probe connection (see documentdb/documentdb#768, item 6).

Related

Activity

  1. added
    enhancement
    go
    on Nov 20, 2026
  2. documentdb-triage-tool commented on Nov 20, 2026

    @documentdb-triage-tool

    🤖 Auto-triaged by documentdb-triage-tool.

    Applied: go, enhancement
    Project fields suggested: Component api · Priority P2 · Effort L · Status Triage
    Confidence: 0.78 (llm)

    Reasoning

    LLM: Requesting configurable liveness/readiness/startup probes for the injected gateway container plus a real health-check endpoint — a meaningful feature gap affecting reliability, spanning plugin parameters, gateway image changes, and log noise, making it a multi-file L-effort P2 enhancement.

    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.

  3. hossain-rayhan commented on Nov 23, 2026

    @hossain-rayhan
    Collaborator

    Thanks for the detailed write-up. You're right that a tcpSocket probe can't detect a hung gateway, since the kernel accepts the connection regardless.

    Here's the plan:

    1. Gateway liveness probe (feat(sidecar-injector): add a TCP liveness probe to the gateway container #526): adds a tcpSocket liveness probe to the injected gateway container (first check after 10 minutes, then every 10 s, restart after about a minute of failures). It restarts only the gateway container, and there's deliberately no readiness or startup probe: either would make the pod unready, so CNPG would remove the PostgreSQL instance from its Services while the gateway isn't listening.
    2. A real health check in the gateway ([gateway] Add a health check usable by Kubernetes probes documentdb#834): a probe that sends hello through the running gateway (liveness) and checks its PostgreSQL pool (readiness), plus logging probe connections at debug instead of ERROR (related to [gateway] Restart, shutdown and outage handling gaps documentdb#768).
    3. Configurable probe parameters for the plugin (gatewayLivenessProbe, gatewayReadinessProbe, gatewayStartupProbe, as JSON like gatewayArgs) are a good fit once (2) exists. We'd welcome a PR for this if you're interested.

    Until #526 is released, the injected container has no probes. The only option meanwhile is a mutating admission policy (for example Kyverno) that adds a probe to the documentdb-gateway container.

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

    enhancementgo

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions