From c56f246eb14164d2630a6671336c10324d2d1931 Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Tue, 10 Nov 2020 08:08:56 -0600 Subject: [PATCH 1/2] Remove the deprecated local parameter for _cat/indices --- docs/reference/cat/indices.asciidoc | 5 ----- .../migration/migrate_8_0/api.asciidoc | 16 ++++++++++++++ .../rest-api-spec/api/cat.indices.json | 8 ------- .../rest/action/cat/RestIndicesAction.java | 22 ++++++------------- .../action/cat/RestIndicesActionTests.java | 11 ++++++---- 5 files changed, 30 insertions(+), 32 deletions(-) diff --git a/docs/reference/cat/indices.asciidoc b/docs/reference/cat/indices.asciidoc index 7c8bdef996b78..260e9c6440a20 100644 --- a/docs/reference/cat/indices.asciidoc +++ b/docs/reference/cat/indices.asciidoc @@ -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]] diff --git a/docs/reference/migration/migrate_8_0/api.asciidoc b/docs/reference/migration/migrate_8_0/api.asciidoc index d8dc474ac873c..1dc0e9abe1b12 100644 --- a/docs/reference/migration/migrate_8_0/api.asciidoc +++ b/docs/reference/migration/migrate_8_0/api.asciidoc @@ -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 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] ==== diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/cat.indices.json b/rest-api-spec/src/main/resources/rest-api-spec/api/cat.indices.json index ed821ca52ed53..5d79baf371bd4 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/cat.indices.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/cat.indices.json @@ -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" diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java index 444a6374c03dd..e72b150ef179e 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java @@ -19,6 +19,7 @@ package org.elasticsearch.rest.action.cat; +import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; @@ -39,7 +40,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; @@ -67,8 +67,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"); @@ -99,10 +97,10 @@ 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); + // needed only in v8 to catch breaking usages and may 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"); } - 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); @@ -114,7 +112,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 groupedListener = createGroupedListener(request, 4, listener); @@ -136,9 +134,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)); } @@ -160,14 +158,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 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()); @@ -176,7 +172,6 @@ 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 listener) { @@ -184,7 +179,6 @@ private void sendClusterStateRequest(final String[] indices, final ClusterStateRequest request = new ClusterStateRequest(); request.indices(indices); request.indicesOptions(indicesOptions); - request.local(local); request.masterNodeTimeout(masterNodeTimeout); client.admin().cluster().state(request, listener); @@ -192,7 +186,6 @@ private void sendClusterStateRequest(final String[] indices, private void sendClusterHealthRequest(final String[] indices, final IndicesOptions indicesOptions, - final boolean local, final TimeValue masterNodeTimeout, final NodeClient client, final ActionListener listener) { @@ -200,7 +193,6 @@ private void sendClusterHealthRequest(final String[] indices, final ClusterHealthRequest request = new ClusterHealthRequest(); request.indices(indices); request.indicesOptions(indicesOptions); - request.local(local); request.masterNodeTimeout(masterNodeTimeout); client.admin().cluster().health(request, listener); diff --git a/server/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java index 83aec285cd415..437989115dd0e 100644 --- a/server/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java +++ b/server/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java @@ -47,6 +47,7 @@ import java.util.stream.IntStream; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -177,14 +178,16 @@ public void testBuildTable() { } } - public void testCatIndicesWithLocalDeprecationWarning() { + public void testCatIndicesRejectsLocalParameter() { + 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(RestIndicesActionTests.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(RestIndicesAction.LOCAL_DEPRECATED_MESSAGE); + assertThat( + expectThrows(IllegalArgumentException.class, () -> action.doCatRequest(request, client)).getMessage(), + is("parameter [local] is not supported")); terminate(threadPool); } From ac537b84b50df519f21bd121d361be61da994266 Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Wed, 11 Nov 2020 11:03:22 -0600 Subject: [PATCH 2/2] remove redundant check --- .../rest/action/cat/RestIndicesAction.java | 5 ---- .../action/cat/RestIndicesActionTests.java | 25 ------------------- 2 files changed, 30 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java index e72b150ef179e..18421081a4e97 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java @@ -19,7 +19,6 @@ package org.elasticsearch.rest.action.cat; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; @@ -97,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()); - // needed only in v8 to catch breaking usages and may 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"); - } final TimeValue masterNodeTimeout = request.paramAsTime("master_timeout", DEFAULT_MASTER_NODE_TIMEOUT); final boolean includeUnloadedSegments = request.paramAsBoolean("include_unloaded_segments", false); diff --git a/server/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java index 437989115dd0e..61860aa7084f1 100644 --- a/server/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java +++ b/server/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java @@ -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; @@ -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; @@ -47,20 +44,12 @@ import java.util.stream.IntStream; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; 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 indicesSettings = new LinkedHashMap<>(); @@ -177,18 +166,4 @@ public void testBuildTable() { } } } - - public void testCatIndicesRejectsLocalParameter() { - 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(RestIndicesActionTests.class.getName()); - NodeClient client = new NodeClient(Settings.EMPTY, threadPool); - FakeRestRequest request = new FakeRestRequest(); - request.params().put("local", randomFrom("", "true", "false", randomAlphaOfLength(10))); - - assertThat( - expectThrows(IllegalArgumentException.class, () -> action.doCatRequest(request, client)).getMessage(), - is("parameter [local] is not supported")); - - terminate(threadPool); - } }