Repository navigation
feat(sidecar-injector): add a TCP liveness probe to the gateway container - #526
hossain-rayhan wants to merge 1 commit into
Conversation
…iner Split from documentdb#475 so the gateway probe can ship on its own. The injected documentdb-gateway container had no probes, so a gateway that stopped accepting connections was never restarted (documentdb#522). - tcpSocket liveness probe on gatewayPort: initial delay 600 s (the entrypoint waits up to 600 s for PostgreSQL), period 10 s, timeout 5 s, failure threshold 6. A failure restarts only the gateway container. - No readiness or startup probe: either would make the pod unready and remove PostgreSQL from the CNPG Services while the gateway isn't listening. - Unit tests (default and custom port, no readiness/startup probe) and an E2E assertion in the sidecar resources spec. - Docs: Gateway Container Restarts in the local HA guide, including the limits of a TCP probe and its ERROR log lines; gatewayPort notes in the plugin guide and product-neutral-core design; CHANGELOG. A request-level health check needs the gateway itself: documentdb/documentdb#834. Co-authored-by: Copilot <[email protected]> Copilot-Session: 9f1a71b4-9969-4456-9f65-8d19dd550d8e Signed-off-by: Rayhan Hossain <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the gateway TCP liveness probe change.
No open issues 🎉
What changed in this PR
Adds a TCP liveness probe to the injected gateway container so Kubernetes can restart a gateway that stops accepting connections. This delivers the gateway-probe portion of #475 and partially addresses #522.
Changes:
- Probes the configured gateway port after a 10-minute startup grace period, without adding readiness or startup probes.
- Adds unit and end-to-end assertions for the probe configuration.
- Documents restart behavior, TCP health-check limitations, probe-related logging, and rollout to newly created pods.
| File | Description |
|---|---|
test/e2e/tests/resources/sidecar_resources_test.go |
Checks gateway probes on a deployed pod. |
operator/cnpg-plugins/sidecar-injector/internal/lifecycle/lifecycle.go |
Adds the TCP liveness probe to the gateway container. |
operator/cnpg-plugins/sidecar-injector/internal/lifecycle/lifecycle_test.go |
Tests default and custom ports, timing, and absent readiness/startup probes. |
docs/operator-public-documentation/v1/high-availability/local-ha.md |
Explains gateway restarts and probe limitations. |
docs/developer-guides/sidecar-injector-plugin-configuration.md |
Notes that liveness checks use gatewayPort. |
docs/designs/product-neutral-core.md |
Documents the gateway listener port requirement. |
CHANGELOG.md |
Records the probe behavior and rollout details. |
Review effort: Balanced
|
🤖 Auto-triaged by documentdb-triage-tool. Applied: Reasoningcomponent from path globs (docs, test); effort from diff stats (115+2 LOC, 7 files) If a label is wrong, ping |
Summary
Adds a TCP liveness probe to the injected
documentdb-gatewaycontainer. Today the container has no probes at all, so a gateway that stops accepting connections is never restarted. This is the gateway-probe part of #475, split out so it can ship on its own; #475 keeps the OTel metrics work. Addresses part of #522.tcpSocketongatewayPort(10260 by default)initialDelaySecondsperiodSeconds/timeoutSeconds/failureThresholdA failed probe restarts only the gateway container: PostgreSQL keeps running and no failover occurs.
Limitations (documented)
ERRORlines in the gateway (Failed to create TLS connectionandGateway runtime connection failed … Connection closed), about 12 lines per minute per pod. Quieter logging is part of [gateway] Add a health check usable by Kubernetes probes documentdb#834 and [gateway] Restart, shutdown and outage handling gaps documentdb#768.Changes
sidecar-injector/internal/lifecycle:gatewayLivenessProbe(port)added to the gateway container. Unit tests cover the default port and a customgatewayPort, and check there is no readiness or startup probe; they fail without the probe.test/e2e/tests/resources/sidecar_resources_test.go: asserts the probe on a real pod.gatewayPortnotes in the plugin guide and the product-neutral-core design, and a CHANGELOG entry.Upgrade behavior
The plugin mutates pods only when they're created, so existing pods get the probe at their next recreation (for example a rolling restart). Upgrading the operator doesn't restart clusters.
Testing
go vetandgo test ./...pass for the sidecar injector;go vetpasses for the E2E resources package.mkdocs build --strictpasses.