Skip to content

Commit 8e12274

Browse files
boicehuangdanhermann
authored andcommitted
Deprecate the 'local' parameter of /_cat/indices (elastic#62198)
1 parent cffa006 commit 8e12274

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

docs/reference/cat/indices.asciidoc

+5-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=help]
7474

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

77-
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=local]
77+
`local`::
78+
(Optional, boolean)
79+
+
80+
deprecated::[7.10.0,"This parameter does not affect the request. It will be removed in a future release."]
7881

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

@@ -112,4 +115,4 @@ yellow open my-index-000001 u8FNjxh8Rfy_awN11oDKYQ 1 1 1200
112115
green open my-index-000002 nYFWZEO7TUiOjLQXBaYJpA 1 0 0 0 260b 260b
113116
--------------------------------------------------
114117
// TESTRESPONSE[s/\d+(\.\d+)?[tgmk]?b/\\d+(\\.\\d+)?[tgmk]?b/]
115-
// TESTRESPONSE[s/u8FNjxh8Rfy_awN11oDKYQ|nYFWZEO7TUiOjLQXBaYJpA/.+/ non_json]
118+
// TESTRESPONSE[s/u8FNjxh8Rfy_awN11oDKYQ|nYFWZEO7TUiOjLQXBaYJpA/.+/ non_json]

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@
5151
},
5252
"local":{
5353
"type":"boolean",
54-
"description":"Return local information, do not retrieve the state from master node (default: false)"
54+
"description":"Return local information, do not retrieve the state from master node (default: false)",
55+
"deprecated":{
56+
"version":"8.0.0",
57+
"description":"This parameter does not affect the request. It will be removed in a future release."
58+
}
5559
},
5660
"master_timeout":{
5761
"type":"time",

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

+6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.elasticsearch.cluster.metadata.IndexMetadata;
4040
import org.elasticsearch.common.Strings;
4141
import org.elasticsearch.common.Table;
42+
import org.elasticsearch.common.logging.DeprecationLogger;
4243
import org.elasticsearch.common.settings.Settings;
4344
import org.elasticsearch.common.time.DateFormatter;
4445
import org.elasticsearch.common.unit.TimeValue;
@@ -67,6 +68,8 @@
6768
import static org.elasticsearch.rest.RestRequest.Method.GET;
6869

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

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

@@ -97,6 +100,9 @@ protected void documentation(StringBuilder sb) {
97100
public RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
98101
final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
99102
final IndicesOptions indicesOptions = IndicesOptions.fromRequest(request, IndicesOptions.strictExpand());
103+
if (request.hasParam("local")) {
104+
DEPRECATION_LOGGER.deprecate("local", LOCAL_DEPRECATED_MESSAGE);
105+
}
100106
final boolean local = request.paramAsBoolean("local", false);
101107
final TimeValue masterNodeTimeout = request.paramAsTime("master_timeout", DEFAULT_MASTER_NODE_TIMEOUT);
102108
final boolean includeUnloadedSegments = request.paramAsBoolean("include_unloaded_segments", false);

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

+22
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.elasticsearch.Version;
2323
import org.elasticsearch.action.admin.indices.stats.CommonStats;
2424
import org.elasticsearch.action.admin.indices.stats.IndexStats;
25+
import org.elasticsearch.client.node.NodeClient;
2526
import org.elasticsearch.cluster.health.ClusterHealthStatus;
2627
import org.elasticsearch.cluster.health.ClusterIndexHealth;
2728
import org.elasticsearch.cluster.metadata.IndexMetadata;
@@ -36,6 +37,8 @@
3637
import org.elasticsearch.index.shard.ShardId;
3738
import org.elasticsearch.test.ESTestCase;
3839
import org.elasticsearch.test.rest.FakeRestRequest;
40+
import org.elasticsearch.threadpool.TestThreadPool;
41+
import org.junit.Before;
3942

4043
import java.util.LinkedHashMap;
4144
import java.util.List;
@@ -50,6 +53,13 @@
5053

5154
public class RestIndicesActionTests extends ESTestCase {
5255

56+
private RestIndicesAction action;
57+
58+
@Before
59+
public void setUpAction() {
60+
action = new RestIndicesAction();
61+
}
62+
5363
public void testBuildTable() {
5464
final int numIndices = randomIntBetween(3, 20);
5565
final Map<String, Settings> indicesSettings = new LinkedHashMap<>();
@@ -166,4 +176,16 @@ public void testBuildTable() {
166176
}
167177
}
168178
}
179+
180+
public void testCatIndicesWithLocalDeprecationWarning() {
181+
TestThreadPool threadPool = new TestThreadPool(RestIndicesActionTests.class.getName());
182+
NodeClient client = new NodeClient(Settings.EMPTY, threadPool);
183+
FakeRestRequest request = new FakeRestRequest();
184+
request.params().put("local", randomFrom("", "true", "false"));
185+
186+
action.doCatRequest(request, client);
187+
assertWarnings(RestIndicesAction.LOCAL_DEPRECATED_MESSAGE);
188+
189+
terminate(threadPool);
190+
}
169191
}

0 commit comments

Comments
 (0)