Add a new REST API endpoint 'GET _cat/cluster_manager' as the replacement of 'GET _cat/master' (#2404)

* Add a new path `/_cat/cluster_manager` for the REST request handler `RestMasterAction`
* Deprecate the existing path `/_cat/master`
* Change the name of the `RestMasterAction` handler from `cat_master_action` to `cat_cluster_manager_action`
* Change the response of `GET _cat` to only show the new path `/_cat/cluster_manager`
* Rename the JSON rest-api-spec file `cat.master.json` to `cat.cluster_manager.json` and update the paths.
* Add YAML REST test. By default, it will run test for both endpoints `GET _cat/cluster_manager` and `GET _cat/master`

Signed-off-by: Tianli Feng <ftianli@amazon.com>
This commit is contained in:
Tianli Feng 2022-03-18 15:00:23 -07:00 committed by GitHub
parent 1193ec101b
commit 3da9eb642c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 66 additions and 9 deletions

View File

@ -1,17 +1,27 @@
{
"cat.master":{
"cat.cluster_manager":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html",
"description":"Returns information about the master node."
"url":"https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/",
"description":"Returns information about the cluster-manager node."
},
"stability":"stable",
"url":{
"paths":[
{
"path":"/_cat/master",
"path":"/_cat/cluster_manager",
"methods":[
"GET"
]
},
{
"path":"/_cat/master",
"methods":[
"GET"
],
"deprecated":{
"version":"2.0.0",
"description":"To promote inclusive language, please use '/_cat/cluster_manager' instead."
}
}
]
},
@ -22,7 +32,7 @@
},
"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 cluster-manager node (default: false)"
},
"master_timeout":{
"type":"time",

View File

@ -0,0 +1,46 @@
setup:
- skip:
features: allowed_warnings
---
"Help":
- skip:
version: " - 1.4.99"
reason: "path _cat/cluster_manager is introduced in 2.0.0"
- do:
cat.cluster_manager:
help: true
allowed_warnings:
- '[GET /_cat/master] is deprecated! Use [GET /_cat/cluster_manager] instead.'
- match:
$body: |
/^ id .+ \n
host .+ \n
ip .+ \n
node .+ \n
$/
---
"Test cat cluster_manager output":
- skip:
version: " - 1.4.99"
reason: "path _cat/cluster_manager is introduced in 2.0.0"
- do:
cat.cluster_manager: {}
allowed_warnings:
- '[GET /_cat/master] is deprecated! Use [GET /_cat/cluster_manager] instead.'
- match:
$body: |
/^
( \S+ \s+ # node id
[-\w.]+ \s+ # host name
(\d{1,3}\.){3}\d{1,3} \s+ # ip address
[-\w.]+ # node name
\n
)
$/

View File

@ -50,18 +50,19 @@ import static org.opensearch.rest.RestRequest.Method.GET;
public class RestMasterAction extends AbstractCatAction {
@Override
public List<Route> routes() {
return singletonList(new Route(GET, "/_cat/master"));
public List<ReplacedRoute> replacedRoutes() {
// The deprecated path will be removed in a future major version.
return singletonList(new ReplacedRoute(GET, "/_cat/cluster_manager", "/_cat/master"));
}
@Override
public String getName() {
return "cat_master_action";
return "cat_cluster_manager_action";
}
@Override
protected void documentation(StringBuilder sb) {
sb.append("/_cat/master\n");
sb.append("/_cat/cluster_manager\n");
}
@Override