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

- Deprecate the request parameter `master_timeout` that used in Index Template APIs which have got the parameter. 
(The other Index APIs are addressed in PR https://github.com/opensearch-project/OpenSearch/pull/2660) 
- Add alternative new request parameter `cluster_manager_timeout`.
- Add unit tests.
Signed-off-by: Tianli Feng <ftianli@amazon.com>
This commit is contained in:
Tianli Feng 2022-04-11 17:29:06 -07:00 committed by GitHub
parent ba8657aca5
commit ba3ed8a9cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 249 additions and 24 deletions

View File

@ -28,7 +28,15 @@
}, },
"master_timeout":{ "master_timeout":{
"type":"time", "type":"time",
"description":"Specify timeout for connection to master" "description":"Specify timeout for connection to master node",
"deprecated":{
"version":"2.0.0",
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
}
},
"cluster_manager_timeout":{
"type":"time",
"description":"Specify timeout for connection to cluster-manager node"
} }
} }
} }

View File

@ -30,7 +30,15 @@
"params":{ "params":{
"master_timeout":{ "master_timeout":{
"type":"time", "type":"time",
"description":"Explicit operation timeout for connection to master node" "description":"Explicit operation timeout for connection to master node",
"deprecated":{
"version":"2.0.0",
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
}
},
"cluster_manager_timeout":{
"type":"time",
"description":"Explicit operation timeout for connection to cluster-manager node"
}, },
"local":{ "local":{
"type":"boolean", "type":"boolean",

View File

@ -34,7 +34,15 @@
}, },
"master_timeout":{ "master_timeout":{
"type":"time", "type":"time",
"description":"Specify timeout for connection to master" "description":"Specify timeout for connection to master node",
"deprecated":{
"version":"2.0.0",
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
}
},
"cluster_manager_timeout":{
"type":"time",
"description":"Specify timeout for connection to cluster-manager node"
} }
}, },
"body":{ "body":{

View File

@ -28,7 +28,15 @@
}, },
"master_timeout":{ "master_timeout":{
"type":"time", "type":"time",
"description":"Specify timeout for connection to master" "description":"Specify timeout for connection to master node",
"deprecated":{
"version":"2.0.0",
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
}
},
"cluster_manager_timeout":{
"type":"time",
"description":"Specify timeout for connection to cluster-manager node"
} }
} }
} }

View File

@ -28,7 +28,15 @@
}, },
"master_timeout":{ "master_timeout":{
"type":"time", "type":"time",
"description":"Specify timeout for connection to master" "description":"Specify timeout for connection to master node",
"deprecated":{
"version":"2.0.0",
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
}
},
"cluster_manager_timeout":{
"type":"time",
"description":"Specify timeout for connection to cluster-manager node"
} }
} }
} }

View File

@ -34,7 +34,15 @@
}, },
"master_timeout":{ "master_timeout":{
"type":"time", "type":"time",
"description":"Explicit operation timeout for connection to master node" "description":"Explicit operation timeout for connection to master node",
"deprecated":{
"version":"2.0.0",
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
}
},
"cluster_manager_timeout":{
"type":"time",
"description":"Explicit operation timeout for connection to cluster-manager node"
}, },
"local":{ "local":{
"type":"boolean", "type":"boolean",

View File

@ -37,7 +37,7 @@
"description":"Explicit operation timeout for connection to master node", "description":"Explicit operation timeout for connection to master node",
"deprecated":{ "deprecated":{
"version":"2.0.0", "version":"2.0.0",
"description":"To promote inclusive language, use 'cluster_manager_timeout' instead." "description":"To support inclusive language, use 'cluster_manager_timeout' instead."
} }
}, },
"cluster_manager_timeout":{ "cluster_manager_timeout":{

View File

@ -35,7 +35,15 @@
}, },
"master_timeout":{ "master_timeout":{
"type":"time", "type":"time",
"description":"Specify timeout for connection to master" "description":"Specify timeout for connection to master node",
"deprecated":{
"version":"2.0.0",
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
}
},
"cluster_manager_timeout":{
"type":"time",
"description":"Specify timeout for connection to cluster-manager node"
} }
}, },
"body":{ "body":{

View File

@ -34,7 +34,15 @@
}, },
"master_timeout":{ "master_timeout":{
"type":"time", "type":"time",
"description":"Specify timeout for connection to master" "description":"Specify timeout for connection to master node",
"deprecated":{
"version":"2.0.0",
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
}
},
"cluster_manager_timeout":{
"type":"time",
"description":"Specify timeout for connection to cluster-manager node"
} }
}, },
"body":{ "body":{

View File

@ -34,7 +34,15 @@
}, },
"master_timeout":{ "master_timeout":{
"type":"time", "type":"time",
"description":"Specify timeout for connection to master" "description":"Specify timeout for connection to master node",
"deprecated":{
"version":"2.0.0",
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
}
},
"cluster_manager_timeout":{
"type":"time",
"description":"Specify timeout for connection to cluster-manager node"
} }
}, },
"body":{ "body":{

View File

@ -40,7 +40,15 @@
}, },
"master_timeout":{ "master_timeout":{
"type":"time", "type":"time",
"description":"Specify timeout for connection to master" "description":"Specify timeout for connection to master node",
"deprecated":{
"version":"2.0.0",
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
}
},
"cluster_manager_timeout":{
"type":"time",
"description":"Specify timeout for connection to cluster-manager node"
} }
}, },
"body":{ "body":{

View File

@ -169,7 +169,7 @@ setup:
cluster.state: cluster.state:
metric: [ master_node, version ] metric: [ master_node, version ]
allowed_warnings: allowed_warnings:
- 'Deprecated value [master_node] used for parameter [metric]. To promote inclusive language, please use [cluster_manager_node] instead. It will be unsupported in a future major version.' - 'Parameter [master_timeout] is deprecated and will be removed in 3.0. To support inclusive language, please use [cluster_manager_timeout] instead.'
- match: { cluster_uuid: $cluster_uuid } - match: { cluster_uuid: $cluster_uuid }
- is_true: master_node - is_true: master_node

View File

@ -6,6 +6,8 @@ setup:
ignore: [404] ignore: [404]
--- ---
"Test indices.exists_template": "Test indices.exists_template":
- skip:
features: allowed_warnings
- do: - do:
indices.exists_template: indices.exists_template:
@ -23,6 +25,8 @@ setup:
number_of_replicas: 0 number_of_replicas: 0
- do: - do:
allowed_warnings:
- "Parameter [master_timeout] is deprecated and will be removed in 3.0. To support inclusive language, please use [cluster_manager_timeout] instead."
indices.exists_template: indices.exists_template:
name: test name: test
master_timeout: 1m master_timeout: 1m

View File

@ -72,8 +72,12 @@ setup:
--- ---
"Get template with flat settings and master timeout": "Get template with flat settings and master timeout":
- skip:
features: allowed_warnings
- do: - do:
allowed_warnings:
- "Parameter [master_timeout] is deprecated and will be removed in 3.0. To support inclusive language, please use [cluster_manager_timeout] instead."
indices.get_template: indices.get_template:
name: test name: test
flat_settings: true flat_settings: true

View File

@ -34,6 +34,7 @@ package org.opensearch.rest.action.admin.indices;
import org.opensearch.action.admin.indices.template.delete.DeleteComponentTemplateAction; import org.opensearch.action.admin.indices.template.delete.DeleteComponentTemplateAction;
import org.opensearch.client.node.NodeClient; import org.opensearch.client.node.NodeClient;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest;
import org.opensearch.rest.action.RestToXContentListener; import org.opensearch.rest.action.RestToXContentListener;
@ -46,6 +47,8 @@ import static org.opensearch.rest.RestRequest.Method.DELETE;
public class RestDeleteComponentTemplateAction extends BaseRestHandler { public class RestDeleteComponentTemplateAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestDeleteComponentTemplateAction.class);
@Override @Override
public List<Route> routes() { public List<Route> routes() {
return Collections.singletonList(new Route(DELETE, "/_component_template/{name}")); return Collections.singletonList(new Route(DELETE, "/_component_template/{name}"));
@ -60,7 +63,8 @@ public class RestDeleteComponentTemplateAction extends BaseRestHandler {
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
DeleteComponentTemplateAction.Request deleteReq = new DeleteComponentTemplateAction.Request(request.param("name")); 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)); return channel -> client.execute(DeleteComponentTemplateAction.INSTANCE, deleteReq, new RestToXContentListener<>(channel));
} }

View File

@ -34,6 +34,7 @@ package org.opensearch.rest.action.admin.indices;
import org.opensearch.action.admin.indices.template.delete.DeleteComposableIndexTemplateAction; import org.opensearch.action.admin.indices.template.delete.DeleteComposableIndexTemplateAction;
import org.opensearch.client.node.NodeClient; import org.opensearch.client.node.NodeClient;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest;
import org.opensearch.rest.action.RestToXContentListener; import org.opensearch.rest.action.RestToXContentListener;
@ -46,6 +47,8 @@ import static org.opensearch.rest.RestRequest.Method.DELETE;
public class RestDeleteComposableIndexTemplateAction extends BaseRestHandler { public class RestDeleteComposableIndexTemplateAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestDeleteComposableIndexTemplateAction.class);
@Override @Override
public List<Route> routes() { public List<Route> routes() {
return Collections.singletonList(new Route(DELETE, "/_index_template/{name}")); return Collections.singletonList(new Route(DELETE, "/_index_template/{name}"));
@ -60,7 +63,8 @@ public class RestDeleteComposableIndexTemplateAction extends BaseRestHandler {
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
DeleteComposableIndexTemplateAction.Request deleteReq = new DeleteComposableIndexTemplateAction.Request(request.param("name")); 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)); return channel -> client.execute(DeleteComposableIndexTemplateAction.INSTANCE, deleteReq, new RestToXContentListener<>(channel));
} }

View File

@ -33,6 +33,7 @@ package org.opensearch.rest.action.admin.indices;
import org.opensearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest; import org.opensearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest;
import org.opensearch.client.node.NodeClient; import org.opensearch.client.node.NodeClient;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest;
import org.opensearch.rest.action.RestToXContentListener; import org.opensearch.rest.action.RestToXContentListener;
@ -45,6 +46,8 @@ import static org.opensearch.rest.RestRequest.Method.DELETE;
public class RestDeleteIndexTemplateAction extends BaseRestHandler { public class RestDeleteIndexTemplateAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestDeleteIndexTemplateAction.class);
@Override @Override
public List<Route> routes() { public List<Route> routes() {
return singletonList(new Route(DELETE, "/_template/{name}")); return singletonList(new Route(DELETE, "/_template/{name}"));
@ -58,7 +61,10 @@ public class RestDeleteIndexTemplateAction extends BaseRestHandler {
@Override @Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
DeleteIndexTemplateRequest deleteIndexTemplateRequest = new DeleteIndexTemplateRequest(request.param("name")); 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)); return channel -> client.admin().indices().deleteTemplate(deleteIndexTemplateRequest, new RestToXContentListener<>(channel));
} }
} }

View File

@ -34,6 +34,7 @@ package org.opensearch.rest.action.admin.indices;
import org.opensearch.action.admin.indices.template.get.GetComponentTemplateAction; import org.opensearch.action.admin.indices.template.get.GetComponentTemplateAction;
import org.opensearch.client.node.NodeClient; import org.opensearch.client.node.NodeClient;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.common.settings.Settings; import org.opensearch.common.settings.Settings;
import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest;
@ -52,6 +53,8 @@ import static org.opensearch.rest.RestStatus.OK;
public class RestGetComponentTemplateAction extends BaseRestHandler { public class RestGetComponentTemplateAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGetComponentTemplateAction.class);
@Override @Override
public List<Route> routes() { public List<Route> routes() {
return Arrays.asList( return Arrays.asList(
@ -72,7 +75,8 @@ public class RestGetComponentTemplateAction extends BaseRestHandler {
final GetComponentTemplateAction.Request getRequest = new GetComponentTemplateAction.Request(request.param("name")); final GetComponentTemplateAction.Request getRequest = new GetComponentTemplateAction.Request(request.param("name"));
getRequest.local(request.paramAsBoolean("local", getRequest.local())); 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; final boolean implicitAll = getRequest.name() == null;

View File

@ -34,6 +34,7 @@ package org.opensearch.rest.action.admin.indices;
import org.opensearch.action.admin.indices.template.get.GetComposableIndexTemplateAction; import org.opensearch.action.admin.indices.template.get.GetComposableIndexTemplateAction;
import org.opensearch.client.node.NodeClient; import org.opensearch.client.node.NodeClient;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.common.settings.Settings; import org.opensearch.common.settings.Settings;
import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest;
@ -52,6 +53,8 @@ import static org.opensearch.rest.RestStatus.OK;
public class RestGetComposableIndexTemplateAction extends BaseRestHandler { public class RestGetComposableIndexTemplateAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGetComposableIndexTemplateAction.class);
@Override @Override
public List<Route> routes() { public List<Route> routes() {
return Arrays.asList( return Arrays.asList(
@ -71,7 +74,8 @@ public class RestGetComposableIndexTemplateAction extends BaseRestHandler {
final GetComposableIndexTemplateAction.Request getRequest = new GetComposableIndexTemplateAction.Request(request.param("name")); final GetComposableIndexTemplateAction.Request getRequest = new GetComposableIndexTemplateAction.Request(request.param("name"));
getRequest.local(request.paramAsBoolean("local", getRequest.local())); 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; final boolean implicitAll = getRequest.name() == null;

View File

@ -36,6 +36,7 @@ import org.opensearch.action.admin.indices.template.get.GetIndexTemplatesRequest
import org.opensearch.action.admin.indices.template.get.GetIndexTemplatesResponse; import org.opensearch.action.admin.indices.template.get.GetIndexTemplatesResponse;
import org.opensearch.client.node.NodeClient; import org.opensearch.client.node.NodeClient;
import org.opensearch.common.Strings; import org.opensearch.common.Strings;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.common.settings.Settings; import org.opensearch.common.settings.Settings;
import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest;
@ -58,6 +59,8 @@ import static org.opensearch.rest.RestStatus.OK;
*/ */
public class RestGetIndexTemplateAction extends BaseRestHandler { public class RestGetIndexTemplateAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGetIndexTemplateAction.class);
@Override @Override
public List<Route> routes() { public List<Route> routes() {
return unmodifiableList( return unmodifiableList(
@ -76,7 +79,10 @@ public class RestGetIndexTemplateAction extends BaseRestHandler {
final GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest(names); final GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest(names);
getIndexTemplatesRequest.local(request.paramAsBoolean("local", getIndexTemplatesRequest.local())); 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; final boolean implicitAll = getIndexTemplatesRequest.names().length == 0;

View File

@ -35,6 +35,7 @@ package org.opensearch.rest.action.admin.indices;
import org.opensearch.action.admin.indices.template.put.PutComponentTemplateAction; import org.opensearch.action.admin.indices.template.put.PutComponentTemplateAction;
import org.opensearch.client.node.NodeClient; import org.opensearch.client.node.NodeClient;
import org.opensearch.cluster.metadata.ComponentTemplate; import org.opensearch.cluster.metadata.ComponentTemplate;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest;
import org.opensearch.rest.action.RestToXContentListener; import org.opensearch.rest.action.RestToXContentListener;
@ -48,6 +49,8 @@ import static org.opensearch.rest.RestRequest.Method.PUT;
public class RestPutComponentTemplateAction extends BaseRestHandler { public class RestPutComponentTemplateAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestPutComponentTemplateAction.class);
@Override @Override
public List<Route> routes() { public List<Route> routes() {
return Arrays.asList(new Route(POST, "/_component_template/{name}"), new Route(PUT, "/_component_template/{name}")); return Arrays.asList(new Route(POST, "/_component_template/{name}"), new Route(PUT, "/_component_template/{name}"));
@ -62,7 +65,8 @@ public class RestPutComponentTemplateAction extends BaseRestHandler {
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
PutComponentTemplateAction.Request putRequest = new PutComponentTemplateAction.Request(request.param("name")); 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.create(request.paramAsBoolean("create", false));
putRequest.cause(request.param("cause", "api")); putRequest.cause(request.param("cause", "api"));
putRequest.componentTemplate(ComponentTemplate.parse(request.contentParser())); putRequest.componentTemplate(ComponentTemplate.parse(request.contentParser()));

View File

@ -35,6 +35,7 @@ package org.opensearch.rest.action.admin.indices;
import org.opensearch.action.admin.indices.template.put.PutComposableIndexTemplateAction; import org.opensearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
import org.opensearch.client.node.NodeClient; import org.opensearch.client.node.NodeClient;
import org.opensearch.cluster.metadata.ComposableIndexTemplate; import org.opensearch.cluster.metadata.ComposableIndexTemplate;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest;
import org.opensearch.rest.action.RestToXContentListener; import org.opensearch.rest.action.RestToXContentListener;
@ -48,6 +49,8 @@ import static org.opensearch.rest.RestRequest.Method.PUT;
public class RestPutComposableIndexTemplateAction extends BaseRestHandler { public class RestPutComposableIndexTemplateAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestPutComposableIndexTemplateAction.class);
@Override @Override
public List<Route> routes() { public List<Route> routes() {
return Arrays.asList(new Route(POST, "/_index_template/{name}"), new Route(PUT, "/_index_template/{name}")); return Arrays.asList(new Route(POST, "/_index_template/{name}"), new Route(PUT, "/_index_template/{name}"));
@ -62,7 +65,8 @@ public class RestPutComposableIndexTemplateAction extends BaseRestHandler {
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
PutComposableIndexTemplateAction.Request putRequest = new PutComposableIndexTemplateAction.Request(request.param("name")); 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.create(request.paramAsBoolean("create", false));
putRequest.cause(request.param("cause", "api")); putRequest.cause(request.param("cause", "api"));
putRequest.indexTemplate(ComposableIndexTemplate.parse(request.contentParser())); putRequest.indexTemplate(ComposableIndexTemplate.parse(request.contentParser()));

View File

@ -78,7 +78,8 @@ public class RestPutIndexTemplateAction extends BaseRestHandler {
putRequest.patterns(Arrays.asList(request.paramAsStringArray("index_patterns", Strings.EMPTY_ARRAY))); putRequest.patterns(Arrays.asList(request.paramAsStringArray("index_patterns", Strings.EMPTY_ARRAY)));
} }
putRequest.order(request.paramAsInt("order", putRequest.order())); 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.create(request.paramAsBoolean("create", false));
putRequest.cause(request.param("cause", "")); putRequest.cause(request.param("cause", ""));

View File

@ -37,6 +37,7 @@ import org.opensearch.action.admin.indices.template.post.SimulateIndexTemplateRe
import org.opensearch.action.admin.indices.template.put.PutComposableIndexTemplateAction; import org.opensearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
import org.opensearch.client.node.NodeClient; import org.opensearch.client.node.NodeClient;
import org.opensearch.cluster.metadata.ComposableIndexTemplate; import org.opensearch.cluster.metadata.ComposableIndexTemplate;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest;
import org.opensearch.rest.action.RestToXContentListener; import org.opensearch.rest.action.RestToXContentListener;
@ -48,6 +49,8 @@ import static org.opensearch.rest.RestRequest.Method.POST;
public class RestSimulateIndexTemplateAction extends BaseRestHandler { public class RestSimulateIndexTemplateAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestSimulateIndexTemplateAction.class);
@Override @Override
public List<Route> routes() { public List<Route> routes() {
return org.opensearch.common.collect.List.of(new Route(POST, "/_index_template/_simulate_index/{name}")); return org.opensearch.common.collect.List.of(new Route(POST, "/_index_template/_simulate_index/{name}"));
@ -62,8 +65,9 @@ public class RestSimulateIndexTemplateAction extends BaseRestHandler {
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
SimulateIndexTemplateRequest simulateIndexTemplateRequest = new SimulateIndexTemplateRequest(request.param("name")); SimulateIndexTemplateRequest simulateIndexTemplateRequest = new SimulateIndexTemplateRequest(request.param("name"));
simulateIndexTemplateRequest.masterNodeTimeout( simulateIndexTemplateRequest.masterNodeTimeout(
request.paramAsTime("master_timeout", simulateIndexTemplateRequest.masterNodeTimeout()) request.paramAsTime("cluster_manager_timeout", simulateIndexTemplateRequest.masterNodeTimeout())
); );
parseDeprecatedMasterTimeoutParameter(simulateIndexTemplateRequest, request, deprecationLogger, getName());
if (request.hasContent()) { if (request.hasContent()) {
PutComposableIndexTemplateAction.Request indexTemplateRequest = new PutComposableIndexTemplateAction.Request( PutComposableIndexTemplateAction.Request indexTemplateRequest = new PutComposableIndexTemplateAction.Request(
"simulating_template" "simulating_template"

View File

@ -36,6 +36,7 @@ import org.opensearch.action.admin.indices.template.post.SimulateTemplateAction;
import org.opensearch.action.admin.indices.template.put.PutComposableIndexTemplateAction; import org.opensearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
import org.opensearch.client.node.NodeClient; import org.opensearch.client.node.NodeClient;
import org.opensearch.cluster.metadata.ComposableIndexTemplate; import org.opensearch.cluster.metadata.ComposableIndexTemplate;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest;
import org.opensearch.rest.action.RestToXContentListener; import org.opensearch.rest.action.RestToXContentListener;
@ -47,6 +48,8 @@ import java.util.List;
import static org.opensearch.rest.RestRequest.Method.POST; import static org.opensearch.rest.RestRequest.Method.POST;
public class RestSimulateTemplateAction extends BaseRestHandler { public class RestSimulateTemplateAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestSimulateTemplateAction.class);
@Override @Override
public List<Route> routes() { public List<Route> routes() {
return Arrays.asList(new Route(POST, "/_index_template/_simulate"), new Route(POST, "/_index_template/_simulate/{name}")); return Arrays.asList(new Route(POST, "/_index_template/_simulate"), new Route(POST, "/_index_template/_simulate/{name}"));
@ -58,7 +61,7 @@ public class RestSimulateTemplateAction extends BaseRestHandler {
} }
@Override @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(); SimulateTemplateAction.Request simulateRequest = new SimulateTemplateAction.Request();
simulateRequest.templateName(request.param("name")); simulateRequest.templateName(request.param("name"));
if (request.hasContent()) { if (request.hasContent()) {
@ -71,7 +74,8 @@ public class RestSimulateTemplateAction extends BaseRestHandler {
simulateRequest.indexTemplateRequest(indexTemplateRequest); 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)); return channel -> client.execute(SimulateTemplateAction.INSTANCE, simulateRequest, new RestToXContentListener<>(channel));
} }

View File

@ -41,6 +41,17 @@ import org.opensearch.rest.action.admin.indices.RestPutMappingAction;
import org.opensearch.rest.action.admin.indices.RestResizeHandler; import org.opensearch.rest.action.admin.indices.RestResizeHandler;
import org.opensearch.rest.action.admin.indices.RestRolloverIndexAction; import org.opensearch.rest.action.admin.indices.RestRolloverIndexAction;
import org.opensearch.rest.action.admin.indices.RestUpdateSettingsAction; import org.opensearch.rest.action.admin.indices.RestUpdateSettingsAction;
import org.opensearch.rest.action.admin.indices.RestDeleteComponentTemplateAction;
import org.opensearch.rest.action.admin.indices.RestDeleteComposableIndexTemplateAction;
import org.opensearch.rest.action.admin.indices.RestDeleteIndexTemplateAction;
import org.opensearch.rest.action.admin.indices.RestGetComponentTemplateAction;
import org.opensearch.rest.action.admin.indices.RestGetComposableIndexTemplateAction;
import org.opensearch.rest.action.admin.indices.RestGetIndexTemplateAction;
import org.opensearch.rest.action.admin.indices.RestPutComponentTemplateAction;
import org.opensearch.rest.action.admin.indices.RestPutComposableIndexTemplateAction;
import org.opensearch.rest.action.admin.indices.RestPutIndexTemplateAction;
import org.opensearch.rest.action.admin.indices.RestSimulateIndexTemplateAction;
import org.opensearch.rest.action.admin.indices.RestSimulateTemplateAction;
import org.opensearch.rest.action.cat.RestAllocationAction; import org.opensearch.rest.action.cat.RestAllocationAction;
import org.opensearch.rest.action.cat.RestRepositoriesAction; import org.opensearch.rest.action.cat.RestRepositoriesAction;
import org.opensearch.rest.action.cat.RestThreadPoolAction; import org.opensearch.rest.action.cat.RestThreadPoolAction;
@ -425,6 +436,87 @@ public class RenamedTimeoutRequestParameterTests extends OpenSearchTestCase {
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE); assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
} }
public void testDeleteComponentTemplate() {
RestDeleteComponentTemplateAction action = new RestDeleteComponentTemplateAction();
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
}
public void testDeleteComposableIndexTemplate() {
RestDeleteComposableIndexTemplateAction action = new RestDeleteComposableIndexTemplateAction();
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
}
public void testDeleteIndexTemplate() {
RestDeleteIndexTemplateAction action = new RestDeleteIndexTemplateAction();
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
}
public void testGetComponentTemplate() {
RestGetComponentTemplateAction action = new RestGetComponentTemplateAction();
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
}
public void testGetComposableIndexTemplate() {
RestGetComposableIndexTemplateAction action = new RestGetComposableIndexTemplateAction();
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
}
public void testGetIndexTemplate() {
RestGetIndexTemplateAction action = new RestGetIndexTemplateAction();
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
}
public void testPutComponentTemplate() {
RestPutComponentTemplateAction action = new RestPutComponentTemplateAction();
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
}
public void testPutComposableIndexTemplate() {
RestPutComposableIndexTemplateAction action = new RestPutComposableIndexTemplateAction();
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
}
public void testPutIndexTemplate() {
RestPutIndexTemplateAction action = new RestPutIndexTemplateAction();
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
}
public void testSimulateIndexTemplate() {
FakeRestRequest request = new FakeRestRequest();
request.params().put("cluster_manager_timeout", randomFrom("1h", "2m"));
request.params().put("master_timeout", "3s");
request.params().put("name", "test");
RestSimulateIndexTemplateAction action = new RestSimulateIndexTemplateAction();
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(request, client));
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
}
public void testSimulateTemplate() {
RestSimulateTemplateAction action = new RestSimulateTemplateAction();
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
}
private MasterNodeRequest getMasterNodeRequest() { private MasterNodeRequest getMasterNodeRequest() {
return new MasterNodeRequest() { return new MasterNodeRequest() {
@Override @Override