From 4687421c7d7c5bd7f777f0da7eba0ad7a61665b6 Mon Sep 17 00:00:00 2001 From: boicehuang Date: Thu, 10 Sep 2020 10:23:30 +0800 Subject: [PATCH 1/5] Deprecate the 'local' parameter of /_cat/indices --- docs/reference/cat/indices.asciidoc | 8 +++++++ .../rest-api-spec/api/cat.indices.json | 6 ++++- .../rest/action/cat/RestIndicesAction.java | 7 ++++++ .../action/cat/RestIndicesActionTests.java | 22 +++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/docs/reference/cat/indices.asciidoc b/docs/reference/cat/indices.asciidoc index 5515b23618326..9240e4c41315d 100644 --- a/docs/reference/cat/indices.asciidoc +++ b/docs/reference/cat/indices.asciidoc @@ -75,6 +75,14 @@ include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=help] include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=include-unloaded-segments] include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=local] ++ +-- +`local`:: +(Optional, boolean) If true, the request retrieves information from the local node +only. Defaults to false, which means information is retrieved from the master node. +deprecated::[8.0,This parameter does not cause this API to act locally. It will be +removed in version 8.0.] +-- include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=master-timeout] 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 a92189134f88f..d1c92e608ed35 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 @@ -51,7 +51,11 @@ }, "local":{ "type":"boolean", - "description":"Return local information, do not retrieve the state from master node (default: false)" + "description":"Return local information, do not retrieve the state from master node (default: false)", + "deprecated":{ + "version":"8.0.0", + "description":"This parameter does not cause this API to act locally." + } }, "master_timeout":{ "type":"time", 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 d313cb900f613..0fbf755c75d16 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 @@ -39,6 +39,7 @@ 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; @@ -66,6 +67,9 @@ 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 = "Deprecated parameter [local] used. This parameter does not cause this API to act " + + "locally, and should not be used. It will be unsupported in version 8.0."; private static final DateFormatter STRICT_DATE_TIME_FORMATTER = DateFormatter.forPattern("strict_date_time"); @@ -91,6 +95,9 @@ 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); 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 61860aa7084f1..83aec285cd415 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,6 +22,7 @@ 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; @@ -36,6 +37,8 @@ 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; @@ -50,6 +53,13 @@ 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<>(); @@ -166,4 +176,16 @@ 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); + } } From 00e4e36879c40c7e40ec2ac82482ee6b365a9a6c Mon Sep 17 00:00:00 2001 From: boicehuang Date: Fri, 16 Oct 2020 18:09:48 +0800 Subject: [PATCH 2/5] fix indices.asciidoc --- docs/reference/cat/indices.asciidoc | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/docs/reference/cat/indices.asciidoc b/docs/reference/cat/indices.asciidoc index 9240e4c41315d..15e3f2f7ef931 100644 --- a/docs/reference/cat/indices.asciidoc +++ b/docs/reference/cat/indices.asciidoc @@ -74,15 +74,10 @@ include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=help] include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=include-unloaded-segments] -include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=local] -+ --- `local`:: -(Optional, boolean) If true, the request retrieves information from the local node -only. Defaults to false, which means information is retrieved from the master node. -deprecated::[8.0,This parameter does not cause this API to act locally. It will be -removed in version 8.0.] --- +(Optional, boolean) ++ +deprecated::[7.10.0,"This parameter does not affect the request. It will be removed in version 8.0.0."] include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=master-timeout] From 4a4604b670f973851b8e5d50c23ca2d3e4bb34ed Mon Sep 17 00:00:00 2001 From: boicehuang Date: Fri, 16 Oct 2020 18:11:34 +0800 Subject: [PATCH 3/5] fix deprecated log --- .../org/elasticsearch/rest/action/cat/RestIndicesAction.java | 3 +-- 1 file changed, 1 insertion(+), 2 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 0fbf755c75d16..907c98bca8d6a 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 @@ -68,8 +68,7 @@ public class RestIndicesAction extends AbstractCatAction { private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(RestIndicesAction.class); - static final String LOCAL_DEPRECATED_MESSAGE = "Deprecated parameter [local] used. This parameter does not cause this API to act " + - "locally, and should not be used. It will be unsupported in version 8.0."; + 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"); From a1376c765ba5313d67e94a263eae248858c73d6f Mon Sep 17 00:00:00 2001 From: boicehuang Date: Wed, 28 Oct 2020 15:37:05 +0800 Subject: [PATCH 4/5] fix description --- .../src/main/resources/rest-api-spec/api/cat.indices.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d1c92e608ed35..165bf1a3f235a 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 @@ -54,7 +54,7 @@ "description":"Return local information, do not retrieve the state from master node (default: false)", "deprecated":{ "version":"8.0.0", - "description":"This parameter does not cause this API to act locally." + "description":"This parameter does not affect the request. It will be removed in a future release." } }, "master_timeout":{ From 742df9f997c1c3f50e8facb172b30728aa326d4e Mon Sep 17 00:00:00 2001 From: boicehuang Date: Thu, 29 Oct 2020 18:02:05 +0800 Subject: [PATCH 5/5] fix doc --- docs/reference/cat/indices.asciidoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference/cat/indices.asciidoc b/docs/reference/cat/indices.asciidoc index 15e3f2f7ef931..db615097e285e 100644 --- a/docs/reference/cat/indices.asciidoc +++ b/docs/reference/cat/indices.asciidoc @@ -77,7 +77,7 @@ include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=include-unloaded-segme `local`:: (Optional, boolean) + -deprecated::[7.10.0,"This parameter does not affect the request. It will be removed in version 8.0.0."] +deprecated::[7.10.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] @@ -115,4 +115,4 @@ yellow open my-index-000001 u8FNjxh8Rfy_awN11oDKYQ 1 1 1200 green open my-index-000002 nYFWZEO7TUiOjLQXBaYJpA 1 0 0 0 260b 260b -------------------------------------------------- // TESTRESPONSE[s/\d+(\.\d+)?[tgmk]?b/\\d+(\\.\\d+)?[tgmk]?b/] -// TESTRESPONSE[s/u8FNjxh8Rfy_awN11oDKYQ|nYFWZEO7TUiOjLQXBaYJpA/.+/ non_json] \ No newline at end of file +// TESTRESPONSE[s/u8FNjxh8Rfy_awN11oDKYQ|nYFWZEO7TUiOjLQXBaYJpA/.+/ non_json]