Skip to content
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

Deprecate the 'local' parameter of /_cat/indices #62198

Merged
merged 7 commits into from
Oct 29, 2020
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
8 changes: 8 additions & 0 deletions docs/reference/cat/indices.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.]
--
Copy link
Contributor

Choose a reason for hiding this comment

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

This creates two entries for the local parameter, one pulled from the common-parms file and this one. I'll solicit some input from our documentation writers on how best to handle this.

Copy link
Contributor

@danhermann danhermann Sep 22, 2020

Choose a reason for hiding this comment

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

@jrodewig, do you have any suggestions on how to handle this documentation case where a parameter pulled in from a common file needs to be marked as deprecated on a specific API?

Copy link
Contributor

Choose a reason for hiding this comment

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

I left a suggestion here: #62198 (comment)

jrodewig marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be the release in which we deprecate the parameter? That should be before 8.0.0.

Copy link
Contributor

Choose a reason for hiding this comment

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

We typically update the version when backporting to a release branch and then come back and update the master branch.

"description":"This parameter does not cause this API to act locally."
}
},
"master_timeout":{
"type":"time",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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");

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<String, Settings> indicesSettings = new LinkedHashMap<>();
Expand Down Expand Up @@ -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);
}
}