Skip to content

fix: reuse readiness probe transport to prevent memory leaks - #1124

Open
oliverbaehler wants to merge 1 commit into
projectcapsule:mainfrom
oliverbaehler:fix/memory-leak
Open

oliverbaehler wants to merge 1 commit into
projectcapsule:mainfrom
oliverbaehler:fix/memory-leak

Conversation

@oliverbaehler

Copy link
Copy Markdown
Member

Readiness checks created a new HTTPS transport on every call, leaving idle connections, goroutines, and buffers retained indefinitely. Go 1.27’s automatic response draining exposed this leak.

Reuse a bounded readiness client with two connections, idle expiry, a five-second timeout, response draining, and shutdown cleanup. Liveness probes perform no HTTP calls; regression coverage confirms they do not share this leak.

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>
Copilot AI balanced review requested due to automatic review settings October 10, 2026 05:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused implementation is bounded, lifecycle-aware, and covered across unit, benchmark, and e2e levels.

0 open findings

What changed in this PR

Reuses a bounded readiness HTTP client to prevent transport resource leaks while preserving probe behavior.

Changes:

  • Adds connection reuse, timeouts, response draining, and shutdown cleanup.
  • Adds unit, benchmark, and tenant-aware e2e regression coverage.
  • Documents the focused probes e2e suite.

Assessment: Connection growth is bounded to two per host; loopback-only insecure TLS remains isolated, and tenant authorization is regression-tested. Tests were inspected but not executed.

File Description
internal/​webserver/​webserver.go Introduces and reuses the bounded readiness client.
internal/​webserver/​probes_test.go Tests reuse, limits, cancellation, draining, and liveness behavior.
e2e/​probes_test.go Adds real-cluster leak and tenant-isolation regression coverage.
e2e/​README.md Documents probe-suite requirements and execution.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bakito

bakito commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

LGTM

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.

3 participants