Skip to content

Remove manual CertReloader wiring#6946

Draft
ycombinator wants to merge 2 commits into
elastic:mainfrom
ycombinator:remove-manual-cert-reload-wiring
Draft

Remove manual CertReloader wiring#6946
ycombinator wants to merge 2 commits into
elastic:mainfrom
ycombinator:remove-manual-cert-reload-wiring

Conversation

@ycombinator
Copy link
Copy Markdown
Contributor

@ycombinator ycombinator commented Apr 30, 2026

What is the problem this PR solves?

PR #6838 added TLS certificate hot-reload support to fleet-server by manually wiring up a CertReloader in server.go. This manual wiring duplicates logic that now lives in elastic-agent-libs (via elastic/elastic-agent-libs#417), which wires CertReloader into both LoadTLSServerConfig (server-side) and LoadTLSConfig (client-side) automatically. Having the wiring in both places is redundant and means fleet-server carries passphrase resolution and reloader option-building code that the library already handles.

How does this PR solve the problem?

Removes the manual CertReloader setup block from server.Run() and the local resolvePassphrase helper function. LoadTLSServerConfig now returns a TLSConfig with certReloader already configured, and BuildServerConfig() automatically sets GetCertificate on the resulting tls.Config. No behavioral change — certificate hot-reload continues to work exactly as before.

Note that elastic/elastic-agent-libs#417 also wires up client-side certificate reloading via LoadTLSConfigToConfig(), which sets GetClientCertificate on the resulting tls.Config. This means fleet-server's client-side TLS connections to Elasticsearch (via httpcommon.HTTPTransportSettings.RoundTripper()) also get automatic certificate hot-reload without any code changes in fleet-server.

How to test this PR locally

The existing Test_server_TLSCertReload integration test validates that certificate reload works end-to-end. Run it with:

go test ./internal/pkg/api/ -run Test_server_TLSCertReload -v

Design Checklist

  • I have ensured my design is stateless and will work when multiple fleet-server instances are behind a load balancer.
  • I have or intend to scale test my changes, ensuring it will work reliably with 100K+ agents connected.
  • I have included fail safe mechanisms to limit the load on fleet-server: rate limiting, circuit breakers, caching, load shedding, etc.

Checklist

  • I have added tests that prove my fix is effective or that my feature works

Related issues

🤖 Generated with Claude Code

LoadTLSServerConfig in elastic-agent-libs now handles CertReloader
setup internally (elastic/elastic-agent-libs#417), making the manual
wiring in server.go redundant. This also removes the local
resolvePassphrase helper which is now handled by the library.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ycombinator ycombinator requested a review from a team as a code owner April 30, 2026 23:03
@ycombinator ycombinator added Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team skip-changelog labels Apr 30, 2026
@ycombinator ycombinator changed the title Remove manual CertReloader wiring from server Remove manual CertReloader wiring; adopt library-level TLS cert reload Apr 30, 2026
@ycombinator ycombinator changed the title Remove manual CertReloader wiring; adopt library-level TLS cert reload Remove manual CertReloader wiring Apr 30, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 30, 2026

This pull request does not have a backport label. Could you fix it @ycombinator? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@ycombinator ycombinator marked this pull request as draft May 7, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant