Skip to content

ssl reloading: pull ownership of rebuilding into es client holder#1

Open
yaauie wants to merge 1 commit intokaisecheng:xpack-reload-certsfrom
yaauie:xpack-reload-certs-using-client-holder
Open

ssl reloading: pull ownership of rebuilding into es client holder#1
yaauie wants to merge 1 commit intokaisecheng:xpack-reload-certsfrom
yaauie:xpack-reload-certs-using-client-holder

Conversation

@yaauie
Copy link
Copy Markdown

@yaauie yaauie commented Apr 29, 2026

As-implemented in elastic#19045, callers of LogStash::Helpers::SslRebuildable need to manage the rebuild state of the client, and the single LogStash::Helpers::SslRebuildable implementation needed to be able to handle being instantiated without a tracker. This spreads the complexity across multiple classes.

This PR is an alternative to that approach.

It introduces a new LogStash::Helpers::ElasticsearchClientHolder that callers can use to get a current elasticsearch client WITHOUT needing to manage the state of that client.

It also provides two implementations, along with a routing function to select the correct implementation depending on whether a tracker is provided:

  • Lazy: simply creates the client on first use and returns the same client instance for all subsequent calls
  • SslRebuildable: similarly lazily creates the client on first use, but rebuilds clients that have been marked stale by the provided tracker before returning them to the caller.

The result is that the caller(s) don't need to be aware of certificate reloading and can simply use LogStash::Helpers::ElasticsearchClientHolder#get to get a current client. The implementation handles the details of ensuring that the client it returns isn't stale.

Introduces a new `LogStash::Helpers::ElasticsearchClientHolder` that callers
can use to get a current elasticsearch client WITHOUT needing to manage the
state of that client.

Provides two implementations, one of which is selected depending on whether
a tracker is provided:

 - `Lazy`: simply creates the client on first use and returns the same
   client instance for all subsequent calls
 - `SslRebuildable`: similarly lazily creates the client on first use, but
   rebuilds clients that have been marked stale by the provided tracker
   before returning them to the caller.
@github-actions
Copy link
Copy Markdown

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

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.

1 participant