Skip to content

Swap to using Spring boot elastic auto configuration, fixes health check failing#205

Draft
jacomago wants to merge 1 commit intoChannelFinder:masterfrom
jacomago:healthcheck-fix
Draft

Swap to using Spring boot elastic auto configuration, fixes health check failing#205
jacomago wants to merge 1 commit intoChannelFinder:masterfrom
jacomago:healthcheck-fix

Conversation

@jacomago
Copy link
Contributor

This uses a more standard (although not completely standard) way of configuring the elastic search client.

Does this by creating a RestClient bean rather than the per index elastic beans.

  • This is then autowired in the healthcheck against elasticsearch making sure the health of channelfinder relies on elasticsearch health.
  • As well as the ElasticSearchClient is auto matically wired by Spring Boots auto elasticsearch configuration.

Note that I could have gone even more standard by autowiring the RestClient from the Spring Boot auto configuration, but that would have mean the application.properties properties for configuring the connection would have to have a new prefix from elasticsearch to spring.elasticsearch.

…-configuration

ElasticConfig now exposes a single @bean RestClient built from the existing
elasticsearch.* properties. Spring Boot's ElasticsearchClientAutoConfiguration
detects this bean and auto-configures ElasticsearchTransport and
ElasticsearchClient on top of it. This also activates
ElasticsearchRestClientHealthContributorAutoConfiguration, fixing the
/actuator/health elasticsearch indicator that was previously broken.

No changes to application.properties are required — all existing
elasticsearch.* connection properties continue to work unchanged:

  elasticsearch.host_urls          (preferred)
  elasticsearch.network.host       (deprecated, still supported)
  elasticsearch.http.port          (deprecated, still supported)
  elasticsearch.authorization.header
  elasticsearch.authorization.username
  elasticsearch.authorization.password

Internal changes:
- Removed the duplicate searchClient/indexClient @bean methods and the
  manual createClient() factory; there is now exactly one ElasticsearchClient
  bean in the context
- Removed @qualifier("indexClient") from ChannelRepository, PropertyRepository,
  TagRepository, ChannelScrollController, and PopulateDBConfiguration
- InfoController now injects ElasticsearchClient directly instead of going
  through ElasticConfig.getSearchClient()
- ElasticConfig no longer implements ServletContextListener; Spring Boot
  manages the RestClient lifecycle

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link

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