-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Extensions] Add ClusterStateRequest parameter to cluster state transport request #7066
Conversation
Gradle Check (Jenkins) Run Completed with:
|
@dbwiddis : Looking for more context on the change here. So with extensions, each request has to be explicitly added in the |
Great question, @shwetathareja, and there may be a more general approach needed eventually for "transport actions" in general, but I'm not sure it's clear yet what that approach is. In Extensions, our first choice is to use existing clients for these requests. Most API requests are in the specification and automatically generate the appropriate Request/Response classes in the various clients, such as
I hope this explains my thought process. I'm sure @saratvemulapalli probably has some comments on this as he's trying to integrate the transport handling with protobuf. |
Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
50f0569
to
ff4380c
Compare
Gradle Check (Jenkins) Run Completed with:
|
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main opensearch-project/OpenSearch#7066 +/- ##
============================================
- Coverage 70.77% 70.63% -0.15%
- Complexity 59367 59447 +80
============================================
Files 4825 4852 +27
Lines 284369 285165 +796
Branches 41021 41112 +91
============================================
+ Hits 201263 201423 +160
- Misses 66603 67182 +579
- Partials 16503 16560 +57
... and 469 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@dbwiddis Thanks for all the details. It helped me understand better.
Yes, if we want to expose the whole of cluster state to users, then implementing it via fromXContent() is the right way forward. But, I wonder if we want to expose all _cluster/state API constructs to clients. I foresee lot of challenges:
I see this API more of helping in debugging and providing it as official Cluster APIs in client could cause lot of maintenance overhead. Until community feels the need with real use cases, we should refrain from exposing it. I also want to warn that the response of this API could be huge in the order of MBs (for large cluster it could easily be > 100MB depending on their mappings). This could cause significant overhead in terms of cpu, memory and keeping transport threads busy if it is being accessed a lot over the transport across extensions. Today, plugins can access the direct in-memory object from ClusterService as opposed to making transport calls. Also if each extension end up storing the de-serialized cluster state at its end, then overall it could be a significant overhead in terms of memory. I would like to brainstorm/ discuss more on access of cluster state across extensions @dbwiddis / @saratvemulapalli
Yes, i would also like to understand the use cases better here before we design a generic solution here for exposing any TransportAction. |
Thanks for all the great insight, @shwetathareja ... some of that belongs on the bug opensearch-project/documentation-website#3784 I filed as well. We had previously (see the diff) returned the As for the specific use case of this request, we are migrating the Anomaly Detection plugin to an extension and have encountered this code in the existing plugin: ClusterStateRequest clusterStateRequest = new ClusterStateRequest()
.clear()
.indices(AnomalyDetectionIndices.ALL_AD_RESULTS_INDEX_PATTERN)
.metadata(true)
.local(true)
.indicesOptions(IndicesOptions.strictExpand());
adminClient.cluster().state(clusterStateRequest, ActionListener.wrap(clusterStateResponse -> { The How would you suggest filtering the |
Thanks @dbwiddis for sharing the AnomalyDetection Plugin use case.
For now, for AD we can keep the logic as is. The bigger question for later is that the plugins which had direct access to ClusterService and were using ClusterState, now would need to resort to transport calls. |
It looks like we are trying to expose cluster state for an extension to know whether an index exists. This seems like a valid concern. Extensions should be able to create/update/delete/check for existence of indices. It should be a first class API. Cluster state is an internal construct of a cluster-based system. Cluster state or nodes wouldn't exist in a serverless environment, for example, which tells me that is not an API that should not need to be exposed to extensions. |
Good point, @dblock ... we should probably just use the Index API for this particular use case. I was trying to migrate existing code (Minimizing the diff helps migration) but this looks like a case where we're digging too deep into the internals and we should use a better (and supported) API for it. |
@dbwiddis : If you are planning to use TransportAction for get index API (use local=true for that as well), this API doesn't return system indices by default. AD index would be a system index. There is a way around using headers, you should first check (could be tricky). Also, how is AD using the response as of today. There could be difference in cluster state API response and get index API for an index. @dblock This is an interesting discussion how system indices should be accessed by extensions. Should it be same as any other customer indices. Ideally no, otherwise customer can mess it up, are we relying on access control alone? |
Based on feedback about sending cluster state over transport, I'm closing this PR in favor of targeted API requests for the information we need. |
@shwetathareja there's two uses in AD extension. The one cited in this thread which this PR was intended to implement was a user-provided index. The system index use case is used via the cluster service |
Cluster state is used by AD to find index information. +1 to @dblock an API to get an index should solve the problem.
I am sure there could be other cases where extensions would need to access cluster state, but we haven't seen anything other than AD for now. Until that day comes with all the feedback here, exposing it as an API is not worth it. |
Companion PR on SDK: opensearch-project/opensearch-sdk-java#668
Description
Adds the ability to send a
ClusterStateRequest
parameter when requesting Cluster State, to limit the values returned (and reduce transport bandwidth). To get the old behavior, usenew ClusterStateRequest().all()
as the parameter.Issues Resolved
Fixes SDK opensearch-project/OpenSearch#354
Check List
Commit changes are listed out in CHANGELOG.md file (See: Changelog)By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.