-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Run cluster info requests on local node #120982
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
Conversation
The actions `GetIndex`, `GetMapping`, and `ExplainLifecycle` (ILM) solely need the cluster state, they can run on any node.
Documentation preview: |
Pinging @elastic/es-data-management (Team:Data Management) |
Hi @nielsbauman, I've created a changelog YAML for you. |
}, | ||
"local":{ | ||
"type":"boolean", | ||
"description":"Return local information, do not retrieve the state from master node (default: false)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This param for the GetFieldMapping
API was deprecated in #55014 and I think #57265 aimed to propagate that deprecation to the REST API spec, but it changed get_mapping.json
instead of get_field_mapping.json
. #55100 removed the local
param for the field mapping API but the regular mapping API still supports the local
param. That's why I'm deleting the param here and deprecating it in get_mapping.json
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you pull this out to a separate PR?
@@ -516,16 +514,6 @@ public void testDeleteIndex() { | |||
assertSameIndices(deleteIndexRequest, TransportDeleteIndexAction.TYPE.name()); | |||
} | |||
|
|||
public void testGetMappings() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deleted this test because it didn't seem to make much sense to keep it when we run the action on the local node -- and it was failing.
/** | ||
* Even though this action is executed on the local node, we still need to be able to read an incoming request as it's used across | ||
* clusters. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is worth discussing. It looks like the GetIndexAction
is used across clusters:
elasticsearch/server/src/main/java/org/elasticsearch/action/admin/indices/get/GetIndexAction.java
Line 19 in a59c182
public static final RemoteClusterActionType<GetIndexResponse> REMOTE_TYPE = new RemoteClusterActionType<>(NAME, GetIndexResponse::new); |
which means we'll need to support transport serialization for both
GetIndexRequest
and GetIndexResponse
. That in turn meant I had to remove final
LocalClusterStateRequest#writeTo
(see further down this PR). I don't really see a way around this but any suggestions are welcome.
We could also add final
back into LocalClusterStateReuqest#writeTo
and add a method like writeToRemoteCluster
to something along those lines, to make it more explicit that that method is required for cross-cluster requests.
@@ -177,7 +172,7 @@ static IndexLifecycleExplainResponse getIndexLifecycleExplainResponse( | |||
lifecycleState.phase(), | |||
lifecycleState.action(), | |||
// treat a missing policy as if the index is in the error step | |||
indexLifecycleService.policyExists(policyName) == false ? ErrorStep.NAME : lifecycleState.step(), | |||
policyExists == false ? ErrorStep.NAME : lifecycleState.step(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IndexLifecycleService
only runs on the master node, which meant that policyExists
was always false
. I changed it to use the Metadata
to check for policy existence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I'm not really sure what the ClusterInfoAction
abstraction is for. Aren't there lots of other things that could be such an action? They don't really return info about a cluster either.
I think I'd rather we tried to separate out the remote-cluster side of this somehow. Maybe set up something that proxies to the local-cluster action and handles the wire protocol.
@Override | ||
public final void writeTo(StreamOutput out) throws IOException { | ||
public void writeTo(StreamOutput out) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I don't really like removing this final
. I think I'd rather we just made TransportGetIndexAction extends HandledTransportAction
rather than trying to generalize TransportClusterInfoAction
for this one special case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm that means we'd have to re-implement/copy the code to wait for cluster blocks. Also, the TransportClusterStateAction
faces the same issue -- and that one also needs to wait for the master in the cluster state.
We can try extracting that waiting logic so TransportLocalClusterStateAction
, TransportGetIndexAction
, and TransportClusterStateAction
can share it, but that might get a bit ugly.
I guess it's only to avoid storing |
It'd mean that we no longer had I think the proxy action idea should work out ok: separate out the remote-cluster get-index action and register this remote-only action with the transport service, then have it simply delegate into the local-node-only get-index action. |
@DaveCTurner alright, I'll work on removing the About your proxy action idea, the proxy action would use the same request and response classes, right? Where would you define the wire (de)serialization? |
I would have a different request class for the proxy action, extending I believe you will be able to register the proxy action with the |
Wouldn't that require duplicating all the fields between the I thought about the alternative of making |
I'd expect us to pull out a
Yeah that seems like it'd lead to worse duplication problems. |
Closing this in favor of #125652 as that's the last remaining The serialization issue we talked about in this PR is no longer relevant as the cross-cluster usage of the GET index API is obsolete and will be removed soon. See #125652 (comment) |
The actions
GetIndex
,GetMapping
, andExplainLifecycle
(ILM) solely need the cluster state, they can run on any node.