Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions docs/reference/cat/shards.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,6 @@ Reason the shard is unassigned. Returned values are:

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=help]

`local`::
(Optional, boolean)
+
deprecated::[7.11.0,"This parameter does not affect the request. It will be removed in a future release."]

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-s]
Expand Down
16 changes: 16 additions & 0 deletions docs/reference/migration/migrate_8_0/api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ Discontinue use of the `?local` query parameter. {ref}/cat-nodes.html[cat node
API] requests that include this parameter will return an error.
====

.The cat shard API's `local` query parameter has been removed.
[%collapsible]
====
*Details* +
The `?local` parameter to the `GET _cat/shards` API was deprecated in 7.x and is
rejected in 8.0. This parameter caused the API to use the local cluster state
to determine the nodes returned by the API rather than the cluster state from
the master, but this API requests information from each selected node
regardless of the `?local` parameter which means this API does not run in a
fully node-local fashion.

*Impact* +
Discontinue use of the `?local` query parameter. {ref}/cat-shards.html[cat shards
API] requests that include this parameter will return an error.
====

.The get field mapping API's `local` query parameter has been removed.
[%collapsible]
====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@
"pb"
]
},
"local":{
"type":"boolean",
"description":"Return local information, do not retrieve the state from master node (default: false)",
"deprecated":{
"version":"7.11.0",
"description":"This parameter does not affect the request. It will be removed in a future release."
}
},
"master_timeout":{
"type":"time",
"description":"Explicit operation timeout for connection to master node"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.elasticsearch.rest.action.cat;

import org.elasticsearch.Version;
import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest;
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
import org.elasticsearch.action.admin.indices.stats.CommonStats;
Expand All @@ -30,7 +31,6 @@
import org.elasticsearch.cluster.routing.UnassignedInfo;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.Table;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.bulk.stats.BulkStats;
import org.elasticsearch.index.cache.query.QueryCacheStats;
Expand Down Expand Up @@ -61,8 +61,6 @@
import static org.elasticsearch.rest.RestRequest.Method.GET;

public class RestShardsAction extends AbstractCatAction {
private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(RestShardsAction.class);
static final String LOCAL_DEPRECATED_MESSAGE = "The parameter [local] is deprecated and will be removed in a future release.";

@Override
public List<Route> routes() {
Expand Down Expand Up @@ -90,10 +88,10 @@ protected void documentation(StringBuilder sb) {
public RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
if (request.hasParam("local")) {
DEPRECATION_LOGGER.deprecate("local", LOCAL_DEPRECATED_MESSAGE);
// needed only in v8 to catch breaking usages and can be removed in v9
if (request.hasParam("local") && Version.CURRENT.major == Version.V_7_0_0.major + 1) {
throw new IllegalArgumentException("parameter [local] is not supported");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to add this I believe, we automatically throw exceptions on unrecognized parameters:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "request [/_cat/shards] contains unrecognized parameter: [aoeu]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "request [/_cat/shards] contains unrecognized parameter: [aoeu]"
  },
  "status" : 400
}

}
clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));
clusterStateRequest.clear().nodes(true).routingTable(true).indices(indices);
return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import java.util.Map;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -130,14 +131,15 @@ public void testBuildTable() {
}
}

public void testCatNodesWithLocalDeprecationWarning() {
public void testCatShardsRejectsLocalParameter() {
assumeTrue("test is needed only in v8 and can be removed in v9", Version.CURRENT.major == Version.V_7_0_0.major + 1);
TestThreadPool threadPool = new TestThreadPool(RestNodesActionTests.class.getName());
NodeClient client = new NodeClient(Settings.EMPTY, threadPool);
FakeRestRequest request = new FakeRestRequest();
request.params().put("local", randomFrom("", "true", "false"));
request.params().put("local", randomFrom("", "true", "false", randomAlphaOfLength(10)));

action.doCatRequest(request, client);
assertWarnings(RestShardsAction.LOCAL_DEPRECATED_MESSAGE);
assertThat(expectThrows(IllegalArgumentException.class, () -> action.doCatRequest(request, client)).getMessage(),
is("parameter [local] is not supported"));

terminate(threadPool);
}
Expand Down