Skip to content

Remove the deprecated local parameter for _cat/indices #64868

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

Merged
merged 6 commits into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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/indices.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=help]

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

`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]

[[pri-flag]]
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 @@ -40,6 +40,22 @@ Discontinue use of the `?local` query parameter. {ref}/cat-shards.html[cat shard
API] requests that include this parameter will return an error.
====

.The cat indices API's `local` query parameter has been removed.
[%collapsible]
====
*Details* +
The `?local` parameter to the `GET _cat/indices` 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-indices.html[cat indices
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 @@ -39,7 +39,6 @@
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.Table;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.common.unit.TimeValue;
Expand Down Expand Up @@ -67,8 +66,6 @@
import static org.elasticsearch.rest.RestRequest.Method.GET;

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

private static final DateFormatter STRICT_DATE_TIME_FORMATTER = DateFormatter.forPattern("strict_date_time");

Expand Down Expand Up @@ -99,10 +96,6 @@ protected void documentation(StringBuilder sb) {
public RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
final IndicesOptions indicesOptions = IndicesOptions.fromRequest(request, IndicesOptions.strictExpand());
if (request.hasParam("local")) {
DEPRECATION_LOGGER.deprecate("local", LOCAL_DEPRECATED_MESSAGE);
}
final boolean local = request.paramAsBoolean("local", false);
final TimeValue masterNodeTimeout = request.paramAsTime("master_timeout", DEFAULT_MASTER_NODE_TIMEOUT);
final boolean includeUnloadedSegments = request.paramAsBoolean("include_unloaded_segments", false);

Expand All @@ -114,7 +107,7 @@ public RestResponse buildResponse(final Table table) throws Exception {
}
});

sendGetSettingsRequest(indices, indicesOptions, local, masterNodeTimeout, client, new ActionListener<>() {
sendGetSettingsRequest(indices, indicesOptions, masterNodeTimeout, client, new ActionListener<>() {
@Override
public void onResponse(final GetSettingsResponse getSettingsResponse) {
final GroupedActionListener<ActionResponse> groupedListener = createGroupedListener(request, 4, listener);
Expand All @@ -136,9 +129,9 @@ public void onResponse(final GetSettingsResponse getSettingsResponse) {
// index names with the same indices options that we used for the initial cluster state request (strictExpand).
sendIndicesStatsRequest(indices, subRequestIndicesOptions, includeUnloadedSegments, client,
ActionListener.wrap(groupedListener::onResponse, groupedListener::onFailure));
sendClusterStateRequest(indices, subRequestIndicesOptions, local, masterNodeTimeout, client,
sendClusterStateRequest(indices, subRequestIndicesOptions, masterNodeTimeout, client,
ActionListener.wrap(groupedListener::onResponse, groupedListener::onFailure));
sendClusterHealthRequest(indices, subRequestIndicesOptions, local, masterNodeTimeout, client,
sendClusterHealthRequest(indices, subRequestIndicesOptions, masterNodeTimeout, client,
ActionListener.wrap(groupedListener::onResponse, groupedListener::onFailure));
}

Expand All @@ -160,14 +153,12 @@ public void onFailure(final Exception e) {
*/
private void sendGetSettingsRequest(final String[] indices,
final IndicesOptions indicesOptions,
final boolean local,
final TimeValue masterNodeTimeout,
final NodeClient client,
final ActionListener<GetSettingsResponse> listener) {
final GetSettingsRequest request = new GetSettingsRequest();
request.indices(indices);
request.indicesOptions(indicesOptions);
request.local(local);
request.masterNodeTimeout(masterNodeTimeout);
request.names(IndexSettings.INDEX_SEARCH_THROTTLED.getKey());

Expand All @@ -176,31 +167,27 @@ private void sendGetSettingsRequest(final String[] indices,

private void sendClusterStateRequest(final String[] indices,
final IndicesOptions indicesOptions,
final boolean local,
final TimeValue masterNodeTimeout,
final NodeClient client,
final ActionListener<ClusterStateResponse> listener) {

final ClusterStateRequest request = new ClusterStateRequest();
request.indices(indices);
request.indicesOptions(indicesOptions);
request.local(local);
request.masterNodeTimeout(masterNodeTimeout);

client.admin().cluster().state(request, listener);
}

private void sendClusterHealthRequest(final String[] indices,
final IndicesOptions indicesOptions,
final boolean local,
final TimeValue masterNodeTimeout,
final NodeClient client,
final ActionListener<ClusterHealthResponse> listener) {

final ClusterHealthRequest request = new ClusterHealthRequest();
request.indices(indices);
request.indicesOptions(indicesOptions);
request.local(local);
request.masterNodeTimeout(masterNodeTimeout);

client.admin().cluster().health(request, listener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.elasticsearch.Version;
import org.elasticsearch.action.admin.indices.stats.CommonStats;
import org.elasticsearch.action.admin.indices.stats.IndexStats;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.cluster.health.ClusterIndexHealth;
import org.elasticsearch.cluster.metadata.IndexMetadata;
Expand All @@ -37,8 +36,6 @@
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.FakeRestRequest;
import org.elasticsearch.threadpool.TestThreadPool;
import org.junit.Before;

import java.util.LinkedHashMap;
import java.util.List;
Expand All @@ -53,13 +50,6 @@

public class RestIndicesActionTests extends ESTestCase {

private RestIndicesAction action;

@Before
public void setUpAction() {
action = new RestIndicesAction();
}

public void testBuildTable() {
final int numIndices = randomIntBetween(3, 20);
final Map<String, Settings> indicesSettings = new LinkedHashMap<>();
Expand Down Expand Up @@ -176,16 +166,4 @@ public void testBuildTable() {
}
}
}

public void testCatIndicesWithLocalDeprecationWarning() {
TestThreadPool threadPool = new TestThreadPool(RestIndicesActionTests.class.getName());
NodeClient client = new NodeClient(Settings.EMPTY, threadPool);
FakeRestRequest request = new FakeRestRequest();
request.params().put("local", randomFrom("", "true", "false"));

action.doCatRequest(request, client);
assertWarnings(RestIndicesAction.LOCAL_DEPRECATED_MESSAGE);

terminate(threadPool);
}
}