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

Add request parameter 'cluster_manager_timeout' and deprecate 'master_timeout' - in Index Template APIs #2678

Merged
merged 17 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from 13 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ setup:
ignore: [404]
---
"Test indices.exists_template":
- skip:
features: allowed_warnings

- do:
indices.exists_template:
Expand All @@ -23,6 +25,8 @@ setup:
number_of_replicas: 0

- do:
allowed_warnings:
- "Deprecated parameter [master_timeout] used. To promote inclusive language, please use [cluster_manager_timeout] instead. It will be unsupported in a future major version."
Copy link
Member

Choose a reason for hiding this comment

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

in the next major version 3.0

Copy link
Collaborator Author

@tlfeng tlfeng Apr 11, 2022

Choose a reason for hiding this comment

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

@anasalkouz Thanks for this idea. My concern is once the deprecated parameter can not be removed in version 3.0, the warning message will become inaccurate.
I'm just worrying about there will be resistance of the old usage removal from the users, which make the removal postponed.
If you think it's better to specify the version number in the warning message, I will change it to It will be removed in 3.0.
The message is defined in this file, I will create a separate PR to change it.

Copy link
Collaborator Author

@tlfeng tlfeng Apr 11, 2022

Choose a reason for hiding this comment

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

Changed the deprecation message in a separate PR #2863 . I will update this PR accordingly once that is merged. 😁

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed the deprecation message in YAML rest api test in commit 07fc06d 👍

indices.exists_template:
name: test
master_timeout: 1m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ setup:

---
"Get template with flat settings and master timeout":
- skip:
features: allowed_warnings

- do:
allowed_warnings:
- "Deprecated parameter [master_timeout] used. To promote inclusive language, please use [cluster_manager_timeout] instead. It will be unsupported in a future major version."
indices.get_template:
name: test
flat_settings: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import org.opensearch.action.admin.indices.template.delete.DeleteComponentTemplateAction;
import org.opensearch.client.node.NodeClient;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest;
import org.opensearch.rest.action.RestToXContentListener;
Expand All @@ -46,6 +47,8 @@

public class RestDeleteComponentTemplateAction extends BaseRestHandler {

private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestDeleteComponentTemplateAction.class);

@Override
public List<Route> routes() {
return Collections.singletonList(new Route(DELETE, "/_component_template/{name}"));
Expand All @@ -60,7 +63,8 @@ public String getName() {
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {

DeleteComponentTemplateAction.Request deleteReq = new DeleteComponentTemplateAction.Request(request.param("name"));
deleteReq.masterNodeTimeout(request.paramAsTime("master_timeout", deleteReq.masterNodeTimeout()));
deleteReq.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", deleteReq.masterNodeTimeout()));
parseDeprecatedMasterTimeoutParameter(deleteReq, request, deprecationLogger, getName());

return channel -> client.execute(DeleteComponentTemplateAction.INSTANCE, deleteReq, new RestToXContentListener<>(channel));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import org.opensearch.action.admin.indices.template.delete.DeleteComposableIndexTemplateAction;
import org.opensearch.client.node.NodeClient;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest;
import org.opensearch.rest.action.RestToXContentListener;
Expand All @@ -46,6 +47,8 @@

public class RestDeleteComposableIndexTemplateAction extends BaseRestHandler {

private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestDeleteComposableIndexTemplateAction.class);

@Override
public List<Route> routes() {
return Collections.singletonList(new Route(DELETE, "/_index_template/{name}"));
Expand All @@ -60,7 +63,8 @@ public String getName() {
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {

DeleteComposableIndexTemplateAction.Request deleteReq = new DeleteComposableIndexTemplateAction.Request(request.param("name"));
deleteReq.masterNodeTimeout(request.paramAsTime("master_timeout", deleteReq.masterNodeTimeout()));
deleteReq.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", deleteReq.masterNodeTimeout()));
parseDeprecatedMasterTimeoutParameter(deleteReq, request, deprecationLogger, getName());

return channel -> client.execute(DeleteComposableIndexTemplateAction.INSTANCE, deleteReq, new RestToXContentListener<>(channel));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import org.opensearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest;
import org.opensearch.client.node.NodeClient;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest;
import org.opensearch.rest.action.RestToXContentListener;
Expand All @@ -45,6 +46,8 @@

public class RestDeleteIndexTemplateAction extends BaseRestHandler {

private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestDeleteIndexTemplateAction.class);

@Override
public List<Route> routes() {
return singletonList(new Route(DELETE, "/_template/{name}"));
Expand All @@ -58,7 +61,10 @@ public String getName() {
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
DeleteIndexTemplateRequest deleteIndexTemplateRequest = new DeleteIndexTemplateRequest(request.param("name"));
deleteIndexTemplateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteIndexTemplateRequest.masterNodeTimeout()));
deleteIndexTemplateRequest.masterNodeTimeout(
request.paramAsTime("cluster_manager_timeout", deleteIndexTemplateRequest.masterNodeTimeout())
);
parseDeprecatedMasterTimeoutParameter(deleteIndexTemplateRequest, request, deprecationLogger, getName());
return channel -> client.admin().indices().deleteTemplate(deleteIndexTemplateRequest, new RestToXContentListener<>(channel));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import org.opensearch.action.admin.indices.template.get.GetComponentTemplateAction;
import org.opensearch.client.node.NodeClient;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.common.settings.Settings;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest;
Expand All @@ -52,6 +53,8 @@

public class RestGetComponentTemplateAction extends BaseRestHandler {

private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGetComponentTemplateAction.class);

@Override
public List<Route> routes() {
return Arrays.asList(
Expand All @@ -72,7 +75,8 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
final GetComponentTemplateAction.Request getRequest = new GetComponentTemplateAction.Request(request.param("name"));

getRequest.local(request.paramAsBoolean("local", getRequest.local()));
getRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getRequest.masterNodeTimeout()));
getRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", getRequest.masterNodeTimeout()));
parseDeprecatedMasterTimeoutParameter(getRequest, request, deprecationLogger, getName());

final boolean implicitAll = getRequest.name() == null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import org.opensearch.action.admin.indices.template.get.GetComposableIndexTemplateAction;
import org.opensearch.client.node.NodeClient;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.common.settings.Settings;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest;
Expand All @@ -52,6 +53,8 @@

public class RestGetComposableIndexTemplateAction extends BaseRestHandler {

private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGetComposableIndexTemplateAction.class);

@Override
public List<Route> routes() {
return Arrays.asList(
Expand All @@ -71,7 +74,8 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
final GetComposableIndexTemplateAction.Request getRequest = new GetComposableIndexTemplateAction.Request(request.param("name"));

getRequest.local(request.paramAsBoolean("local", getRequest.local()));
getRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getRequest.masterNodeTimeout()));
getRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", getRequest.masterNodeTimeout()));
parseDeprecatedMasterTimeoutParameter(getRequest, request, deprecationLogger, getName());

final boolean implicitAll = getRequest.name() == null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.opensearch.action.admin.indices.template.get.GetIndexTemplatesResponse;
import org.opensearch.client.node.NodeClient;
import org.opensearch.common.Strings;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.common.settings.Settings;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest;
Expand All @@ -58,6 +59,8 @@
*/
public class RestGetIndexTemplateAction extends BaseRestHandler {

private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGetIndexTemplateAction.class);

@Override
public List<Route> routes() {
return unmodifiableList(
Expand All @@ -76,7 +79,10 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC

final GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest(names);
getIndexTemplatesRequest.local(request.paramAsBoolean("local", getIndexTemplatesRequest.local()));
getIndexTemplatesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getIndexTemplatesRequest.masterNodeTimeout()));
getIndexTemplatesRequest.masterNodeTimeout(
request.paramAsTime("cluster_manager_timeout", getIndexTemplatesRequest.masterNodeTimeout())
);
parseDeprecatedMasterTimeoutParameter(getIndexTemplatesRequest, request, deprecationLogger, getName());

final boolean implicitAll = getIndexTemplatesRequest.names().length == 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.opensearch.action.admin.indices.template.put.PutComponentTemplateAction;
import org.opensearch.client.node.NodeClient;
import org.opensearch.cluster.metadata.ComponentTemplate;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest;
import org.opensearch.rest.action.RestToXContentListener;
Expand All @@ -48,6 +49,8 @@

public class RestPutComponentTemplateAction extends BaseRestHandler {

private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestPutComponentTemplateAction.class);

@Override
public List<Route> routes() {
return Arrays.asList(new Route(POST, "/_component_template/{name}"), new Route(PUT, "/_component_template/{name}"));
Expand All @@ -62,7 +65,8 @@ public String getName() {
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {

PutComponentTemplateAction.Request putRequest = new PutComponentTemplateAction.Request(request.param("name"));
putRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putRequest.masterNodeTimeout()));
putRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", putRequest.masterNodeTimeout()));
parseDeprecatedMasterTimeoutParameter(putRequest, request, deprecationLogger, getName());
putRequest.create(request.paramAsBoolean("create", false));
putRequest.cause(request.param("cause", "api"));
putRequest.componentTemplate(ComponentTemplate.parse(request.contentParser()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.opensearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
import org.opensearch.client.node.NodeClient;
import org.opensearch.cluster.metadata.ComposableIndexTemplate;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest;
import org.opensearch.rest.action.RestToXContentListener;
Expand All @@ -48,6 +49,8 @@

public class RestPutComposableIndexTemplateAction extends BaseRestHandler {

private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestPutComposableIndexTemplateAction.class);

@Override
public List<Route> routes() {
return Arrays.asList(new Route(POST, "/_index_template/{name}"), new Route(PUT, "/_index_template/{name}"));
Expand All @@ -62,7 +65,8 @@ public String getName() {
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {

PutComposableIndexTemplateAction.Request putRequest = new PutComposableIndexTemplateAction.Request(request.param("name"));
putRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putRequest.masterNodeTimeout()));
putRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", putRequest.masterNodeTimeout()));
parseDeprecatedMasterTimeoutParameter(putRequest, request, deprecationLogger, getName());
putRequest.create(request.paramAsBoolean("create", false));
putRequest.cause(request.param("cause", "api"));
putRequest.indexTemplate(ComposableIndexTemplate.parse(request.contentParser()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
putRequest.patterns(Arrays.asList(request.paramAsStringArray("index_patterns", Strings.EMPTY_ARRAY)));
}
putRequest.order(request.paramAsInt("order", putRequest.order()));
putRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putRequest.masterNodeTimeout()));
putRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", putRequest.masterNodeTimeout()));
parseDeprecatedMasterTimeoutParameter(putRequest, request, deprecationLogger, getName());
putRequest.create(request.paramAsBoolean("create", false));
putRequest.cause(request.param("cause", ""));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.opensearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
import org.opensearch.client.node.NodeClient;
import org.opensearch.cluster.metadata.ComposableIndexTemplate;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest;
import org.opensearch.rest.action.RestToXContentListener;
Expand All @@ -48,6 +49,8 @@

public class RestSimulateIndexTemplateAction extends BaseRestHandler {

private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestSimulateIndexTemplateAction.class);

@Override
public List<Route> routes() {
return org.opensearch.common.collect.List.of(new Route(POST, "/_index_template/_simulate_index/{name}"));
Expand All @@ -62,8 +65,9 @@ public String getName() {
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
SimulateIndexTemplateRequest simulateIndexTemplateRequest = new SimulateIndexTemplateRequest(request.param("name"));
simulateIndexTemplateRequest.masterNodeTimeout(
request.paramAsTime("master_timeout", simulateIndexTemplateRequest.masterNodeTimeout())
request.paramAsTime("cluster_manager_timeout", simulateIndexTemplateRequest.masterNodeTimeout())
);
parseDeprecatedMasterTimeoutParameter(simulateIndexTemplateRequest, request, deprecationLogger, getName());
if (request.hasContent()) {
PutComposableIndexTemplateAction.Request indexTemplateRequest = new PutComposableIndexTemplateAction.Request(
"simulating_template"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.opensearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
import org.opensearch.client.node.NodeClient;
import org.opensearch.cluster.metadata.ComposableIndexTemplate;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest;
import org.opensearch.rest.action.RestToXContentListener;
Expand All @@ -47,6 +48,8 @@
import static org.opensearch.rest.RestRequest.Method.POST;

public class RestSimulateTemplateAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestSimulateTemplateAction.class);

@Override
public List<Route> routes() {
return Arrays.asList(new Route(POST, "/_index_template/_simulate"), new Route(POST, "/_index_template/_simulate/{name}"));
Expand All @@ -58,7 +61,7 @@ public String getName() {
}

@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
SimulateTemplateAction.Request simulateRequest = new SimulateTemplateAction.Request();
simulateRequest.templateName(request.param("name"));
if (request.hasContent()) {
Expand All @@ -71,7 +74,8 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli

simulateRequest.indexTemplateRequest(indexTemplateRequest);
}
simulateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", simulateRequest.masterNodeTimeout()));
simulateRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", simulateRequest.masterNodeTimeout()));
parseDeprecatedMasterTimeoutParameter(simulateRequest, request, deprecationLogger, getName());

return channel -> client.execute(SimulateTemplateAction.INSTANCE, simulateRequest, new RestToXContentListener<>(channel));
}
Expand Down
Loading