Skip to content

Commit 8c6f821

Browse files
authored
Remove the 'local' parameter of /_cat/nodes (#50594)
The cat nodes API performs a `ClusterStateAction` then a `NodesInfoAction`. Today it accepts the `?local` parameter and passes this to the `ClusterStateAction` but this parameter has no effect on the `NodesInfoAction`. This is surprising, because `GET _cat/nodes?local` looks like it might be a completely local call but in fact it still depends on every node in the cluster. This parameter was deprecated in 7.x in #50499 and this commit removes it. Relates #50088
1 parent 7309ce4 commit 8c6f821

File tree

6 files changed

+30
-35
lines changed

6 files changed

+30
-35
lines changed

docs/reference/cat/nodes.asciidoc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -285,18 +285,6 @@ Number of suggest operations, such as `0`.
285285

286286
include::{docdir}/rest-api/common-parms.asciidoc[tag=help]
287287

288-
include::{docdir}/rest-api/common-parms.asciidoc[tag=local]
289-
+
290-
--
291-
`local`::
292-
(Optional, boolean) If `true`, the request computes the list of selected nodes
293-
from the local cluster state. Defaults to `false`, which means the list of
294-
selected nodes is computed from the cluster state on the master node. In either
295-
case the coordinating node sends a request for further information to each
296-
selected node. deprecated::[8.0,This parameter does not cause this API to act
297-
locally. It will be removed in version 8.0.]
298-
--
299-
300288
include::{docdir}/rest-api/common-parms.asciidoc[tag=master-timeout]
301289

302290
include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-s]

docs/reference/migration/migrate_8_0.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ coming[8.0.0]
3030
* <<breaking_80_search_changes>>
3131
* <<breaking_80_settings_changes>>
3232
* <<breaking_80_indices_changes>>
33+
* <<breaking_80_api_changes>>
3334

3435
//NOTE: The notable-breaking-changes tagged regions are re-used in the
3536
//Installation and Upgrade Guide
@@ -81,3 +82,4 @@ include::migrate_8_0/reindex.asciidoc[]
8182
include::migrate_8_0/search.asciidoc[]
8283
include::migrate_8_0/settings.asciidoc[]
8384
include::migrate_8_0/indices.asciidoc[]
85+
include::migrate_8_0/api.asciidoc[]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[float]
2+
[[breaking_80_api_changes]]
3+
=== REST API changes
4+
5+
//NOTE: The notable-breaking-changes tagged regions are re-used in the
6+
//Installation and Upgrade Guide
7+
//tag::notable-breaking-changes[]
8+
9+
// end::notable-breaking-changes[]
10+
11+
[float]
12+
==== Deprecated `?local` parameter removed from `GET _cat/nodes` API
13+
14+
The `?local` parameter to the `GET _cat/nodes` API was deprecated in 7.x and is
15+
rejected in 8.0. This parameter caused the API to use the local cluster state
16+
to determine the nodes returned by the API rather than the cluster state from
17+
the master, but this API requests information from each selected node
18+
regardless of the `?local` parameter which means this API does not run in a
19+
fully node-local fashion.

rest-api-spec/src/main/resources/rest-api-spec/api/cat.nodes.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@
4141
"type":"boolean",
4242
"description":"Return the full node ID instead of the shortened version (default: false)"
4343
},
44-
"local":{
45-
"type":"boolean",
46-
"description":"Calculate the selected nodes using the local cluster state rather than the state from master node (default: false)",
47-
"deprecated":{
48-
"version":"8.0.0",
49-
"description":"This parameter does not cause this API to act locally."
50-
}
51-
},
5244
"master_timeout":{
5345
"type":"time",
5446
"description":"Explicit operation timeout for connection to master node"

server/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package org.elasticsearch.rest.action.cat;
2121

22-
import org.apache.logging.log4j.LogManager;
22+
import org.elasticsearch.Version;
2323
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
2424
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest;
2525
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
@@ -34,7 +34,6 @@
3434
import org.elasticsearch.cluster.node.DiscoveryNodes;
3535
import org.elasticsearch.common.Strings;
3636
import org.elasticsearch.common.Table;
37-
import org.elasticsearch.common.logging.DeprecationLogger;
3837
import org.elasticsearch.common.network.NetworkAddress;
3938
import org.elasticsearch.common.transport.TransportAddress;
4039
import org.elasticsearch.common.unit.ByteSizeValue;
@@ -69,10 +68,6 @@
6968
import static org.elasticsearch.rest.RestRequest.Method.GET;
7069

7170
public class RestNodesAction extends AbstractCatAction {
72-
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(
73-
LogManager.getLogger(RestNodesAction.class));
74-
static final String LOCAL_DEPRECATED_MESSAGE = "Deprecated parameter [local] used. This parameter does not cause this API to act " +
75-
"locally, and should not be used. It will be unsupported in version 8.0.";
7671

7772
public RestNodesAction(RestController controller) {
7873
controller.registerHandler(GET, "/_cat/nodes", this);
@@ -92,10 +87,9 @@ protected void documentation(StringBuilder sb) {
9287
public RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
9388
final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
9489
clusterStateRequest.clear().nodes(true);
95-
if (request.hasParam("local")) {
96-
deprecationLogger.deprecated(LOCAL_DEPRECATED_MESSAGE);
90+
if (request.hasParam("local") && Version.CURRENT.major == Version.V_7_0_0.major + 1) { // only needed in v8 to catch breaking usages
91+
throw new IllegalArgumentException("parameter [local] is not supported");
9792
}
98-
clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
9993
clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));
10094
final boolean fullId = request.paramAsBoolean("full_id", false);
10195
return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {

server/src/test/java/org/elasticsearch/rest/action/cat/RestNodesActionTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
import static java.util.Collections.emptyMap;
4242
import static java.util.Collections.emptySet;
43+
import static org.hamcrest.Matchers.is;
4344
import static org.mockito.Mockito.mock;
4445
import static org.mockito.Mockito.when;
4546

@@ -69,15 +70,14 @@ public void testBuildTableDoesNotThrowGivenNullNodeInfoAndStats() {
6970
action.buildTable(false, new FakeRestRequest(), clusterStateResponse, nodesInfoResponse, nodesStatsResponse);
7071
}
7172

72-
public void testCatNodesWithLocalDeprecationWarning() {
73+
public void testCatNodesRejectsLocalParameter() {
74+
assumeTrue("test is only needed in v8, can be removed in v9", Version.CURRENT.major == Version.V_7_0_0.major + 1);
7375
TestThreadPool threadPool = new TestThreadPool(RestNodesActionTests.class.getName());
7476
NodeClient client = new NodeClient(Settings.EMPTY, threadPool);
7577
FakeRestRequest request = new FakeRestRequest();
76-
request.params().put("local", randomFrom("", "true", "false"));
77-
78-
action.doCatRequest(request, client);
79-
assertWarnings(RestNodesAction.LOCAL_DEPRECATED_MESSAGE);
80-
78+
request.params().put("local", randomFrom("", "true", "false", randomAlphaOfLength(10)));
79+
assertThat(expectThrows(IllegalArgumentException.class, () -> action.doCatRequest(request, client)).getMessage(),
80+
is("parameter [local] is not supported"));
8181
terminate(threadPool);
8282
}
8383
}

0 commit comments

Comments
 (0)