-
Notifications
You must be signed in to change notification settings - Fork 40.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Elasticsearch RestClientBuilder auto-configuration without RestHighLevelClient #28496
Support Elasticsearch RestClientBuilder auto-configuration without RestHighLevelClient #28496
Conversation
1c85eb0
to
9b2c905
Compare
I didn't do any changes to the Gradle Wrapper. Seems like some problem in the Gradle Wrapper action itself |
This PR is reversing the team's decision explained in #22358 (comment). I'm not sure I understand the rationale behind this. The presence of If the main goal is to support the newly released client, maybe we should auto-configure as well and deprecate the high-level variant in 2.6.x? |
The biggest reason why I created this PR was to get the The reason for that is Lines 41 to 42 in 83e4430
We have a platform that heavily uses Spring Boot and we are using the The addition of the Even if you only partially integrate this (without the new beans) we can easily do
and have the In addition to all of this, there is also OpenSearch with its own things. Without going into too much detail, for our own simple purposes it might be possible to use one In a nutshell for us having to maintain support for our own things on both OpenSearch and Elasticsearch it makes a lot of sense to only use the Low Level Clients. I hope that you are going to take this into consideration and revise your decision about this. Thanks a lot for the understanding |
Thanks for the background information @filiphr, that's super useful. With that I think we should:
|
Something else, that I forgot to add to this PR. The Ideally the health contributor will be adapted to only use I can of course provide PRs and / or adapt this PR if you decide that you are OK with my proposals. |
One, I hope final, argument is also the fact that removing the dependency on the |
Thanks a lot @filiphr for all your insights. We've just discussed this as a team and we've decided to:
Could you adapt this PR to address 1) and 2)? |
Thanks a lot for this decision @bclozel. I am going to adapt this PR to take into consideration for 1) and 2). What about exposing I have managed to achieve what I need with 2.5 already, but the way I did it is not the best approach, since I am doing some nasty magic with |
9b2c905
to
3e160a4
Compare
Exposing the It's a bit late in the 2.6 cycle unfortunately so if we want to introduce a change here, it has to be extra-safe. |
@bclozel I think that I have adapted the PR as you asked. Please have a look at it and let me know if there is something more that needs to be done. Also adapted the use of
Exposing the |
@filiphr you're right, I forgot we were already exposing the builder as a bean. I need to take a deeper look. |
@bclozel I'll try to do a small proposal as a separate PR for that. You can then decide what you want to do |
1ca278f
to
902dd0b
Compare
3e160a4
to
d6e5a58
Compare
@bclozel I finally found the time and adapted the changed in this PR to address point 1) and 2) from #28496 (comment). I've changed the base of the PR to be 2.7. Please have a look at it and let me know what you think about it. |
d6e5a58
to
994550e
Compare
For the record |
Damn, I first rebased on main, but then realized that main and 2.7.x are not the same, so I did it on 2.7.x. I'll try to do take the new changes from 2.7.x into consideration and fix the conflicts. Basically, I need to make sure that there are no deprecation warnings, right? |
Prior to this commit, Spring Boot would only auto-configure the `RestHighLevelClient` and `RestClientBuilder` if the `RestHighLevelClient` was present. This was done in 1d73d4e. This commit brings back the exposing of the `RestClient` bean in Spring Boot when exposing the `RestHighLevelClient` or when the `RestHighLevelClient` is not present. It allows for using the Spring Boot auto configuration and its customizers of the `RestClientBuilder` in a similar way as it is done for the `RestTeamplateBuilder` and the `WebClient.Builder`. Now the presence of the `org.elasticsearch.client:elasticsearch-rest-high-level-client` is optional. This opens the door for potentially adding support to the new [Elasticsearch Java Client](https://github.com/elastic/elasticsearch-java) that is based on the same `RestClient` It also adapts the health contributor to only depend on the low level RestClient.
994550e
to
582e2d1
Compare
Prior to this commit, Spring Boot would only auto-configure the `RestHighLevelClient` and `RestClientBuilder` if the `RestHighLevelClient` was present. This was done in 1d73d4e. This commit brings back the exposing of the `RestClient` bean in when exposing the `RestHighLevelClient` or when the `RestHighLevelClient` is not present. It allows for using the auto-configuration and its customizers of the `RestClientBuilder` in a similar way as it is done for the `RestTemplateBuilder` and the `WebClient.Builder`. The presence of the `elasticsearch-rest-high-level-client` module is now optional. This opens the door for potentially adding support for the new Elasticsearch Java Client[1] that is based on the same `RestClient`. The health contributor and its configuration has also been updated to only depend on the low-level RestClient. See gh-28496 [1] https://github.com/elastic/elasticsearch-java
@wilkinsona I agree with you that the code is simplified with your change. However, your change means that you can only have Elasticsearch health checks if you have the I personally see no need to lose Elasticsearch auto configuration if you do not have If this is something that the Boot team wants to do, then I am all OK with it. However, I would ask you to reconsider and have health checks without the RestHighLevelClient. |
That’s an unintentional over-simplification. Thanks for catching it, @filiphr. I’ll take another look. Requiring a |
It is not about the auto-configuration. The auto configuration works correctly and it auto configures if a Thanks for taking another look at it. |
Thanks a lot for bringing back the old changes @wilkinsona. It is really appreciated. |
@wilkinsona Are we opensearch users expected to keep using opensearch.RestHighLevelClient after 2.7.0? |
Spring Boot does not have any auto-configuration for OpenSearch so we don't have any expectations about what you should do. |
@nightswimmings as far as I know, you can keep using the Elasticsearch |
Thanks filiphr, we already have all forked opensearch client code, its just that I did not know whether to expect any impact or not on the new autconfiguration and deprecation if you are on opensearch-flavoured els, but if Boot does not account the later, then its not an issue |
Prior to this commit, Spring Boot would only auto-configure
the
RestHighLevelClient
andRestClientBuilder
if theRestHighLevelClient
was present. This was done in 1d73d4e as part of #22358
This commit brings back the exposing of the
RestClient
bean inSpring Boot when exposing the
RestHighLevelClient
orwhen the
RestHighLevelClient
is not present.It allows for using the Spring Boot auto configuration and its customizers
of the
RestClientBuilder
in a similar way as it is done for theRestTeamplateBuilder
and the
WebClient.Builder
.Now the presence of the
org.elasticsearch.client:elasticsearch-rest-high-level-client
is optional.This opens the door for potentially adding support to the new
Elasticsearch Java Client that is based on the same
RestClient
The exposing of the
RestClient
as a bean is not the most important thing in this PR.I would rather say that the fact that the
RestClientBuilder
is exposed as a bean is the most important part.This allows users to rely on the Spring Boot provided mechanisms for configuring the
RestClientBuilder
and not depend on the now deprecated Elasticsearch Rest High Level Client.