Loading
docs(v2/httpserver): add readiness check best practices
Summary
- Adds readiness check best practices documentation to
v2/httpserver/README.md, covering liveness vs readiness semantics, startup probes, the cascading failure anti-pattern, and Kubernetes probe configuration guidance - Implements a dedicated probe port (default
:9090) that serves/-/liveness,/-/readiness, and/-/metrics— the main application port now serves only application traffic - Updates all Kubernetes probe YAML examples to reference port
9090
What changed
v2/httpserver/server.go
- New
Config.ProbeAddrfield (default":9090") — configures the dedicated probe server address; use":0"in tests - New
Server.ProbeAddr()method — returns the bound probe address afterStart NewWithConfigbuilds a privateprobeSrv *http.Serverwith its ownhttp.ServeMuxrouting/-/liveness,/-/readiness, and/-/metrics(no middleware applied)Startbinds both listeners sequentially; if the probe bind fails after the app bind succeeds, the app listener is closed (no leaked resources)Shutdowndrains the app server first, then shuts down the probe server —/-/readinessstays observable during the drain windowServeHTTPsimplified: health paths removed, application traffic only; requests to/-/livenessor/-/readinesson the main port return 404
v2/httpserver/server_test.go
- All existing health tests (
TestLiveness_*,TestReadiness_*,TestAddReadinessCheck_IsChainable) rewritten to use a real probe listener on:0via astartProbeServerhelper - New table-driven tests:
TestProbeAddr_EmptyBeforeStart,TestProbeServer_StartsAndReturnsAddr,TestProbeServer_Start_FailsIfProbeAddrInvalid,TestProbeServer_ServesHealthEndpoints,TestProbeServer_AppPortNoLongerServesProbes
v2/httpserver/README.md
- Added
### Liveness,### Startup,### Readiness,### Writing safe readiness checkssubsections - Added startup probe guidance with
failureThreshold: 24(2 min grace) and explanation of when to use a custom startup endpoint - Added cascading failure anti-pattern section with numbered failure sequence
- Added
#### What to check,#### What not to check,#### Kubernetes probe configuration,#### Liveness probessubsections - Health endpoints table updated with Port column (
:9090) - All Kubernetes probe YAML examples updated to port
9090 ProbeAddradded to the Configuration section example- Security note added: probe port can be restricted to internal cluster traffic independently of the app port
- Prose reflowed to one sentence per line; startup probe wording clarified per review feedback
Test plan
- CI pipeline passes (
go test ./...inv2/) -
/-/livenessand/-/readinessreturn expected responses on the probe port (:9090default,:0in tests) -
/-/livenessand/-/readinessreturn 404 on the main app port -
Server.ProbeAddr()returns empty string beforeStart, bound address after - Invalid
ProbeAddrcausesStartto return an error without leaking the app listener -
Shutdownsucceeds cleanly
Closes gitlab-org/quality/quality-engineering/team-tasks#4381 (closed)
Edited by Elliot Forbes