Skip to content

Commit 3da9eb6

Browse files
author
Tianli Feng
authored
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>
1 parent 1193ec1 commit 3da9eb6

File tree

3 files changed

+66
-9
lines changed

3 files changed

+66
-9
lines changed

rest-api-spec/src/main/resources/rest-api-spec/api/cat.master.json rest-api-spec/src/main/resources/rest-api-spec/api/cat.cluster_manager.json

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
{
2-
"cat.master":{
2+
"cat.cluster_manager":{
33
"documentation":{
4-
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html",
5-
"description":"Returns information about the master node."
4+
"url":"https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/",
5+
"description":"Returns information about the cluster-manager node."
66
},
77
"stability":"stable",
88
"url":{
99
"paths":[
1010
{
11-
"path":"/_cat/master",
11+
"path":"/_cat/cluster_manager",
1212
"methods":[
1313
"GET"
1414
]
15+
},
16+
{
17+
"path":"/_cat/master",
18+
"methods":[
19+
"GET"
20+
],
21+
"deprecated":{
22+
"version":"2.0.0",
23+
"description":"To promote inclusive language, please use '/_cat/cluster_manager' instead."
24+
}
1525
}
1626
]
1727
},
@@ -22,7 +32,7 @@
2232
},
2333
"local":{
2434
"type":"boolean",
25-
"description":"Return local information, do not retrieve the state from master node (default: false)"
35+
"description":"Return local information, do not retrieve the state from cluster-manager node (default: false)"
2636
},
2737
"master_timeout":{
2838
"type":"time",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
setup:
2+
- skip:
3+
features: allowed_warnings
4+
5+
---
6+
"Help":
7+
- skip:
8+
version: " - 1.4.99"
9+
reason: "path _cat/cluster_manager is introduced in 2.0.0"
10+
11+
- do:
12+
cat.cluster_manager:
13+
help: true
14+
allowed_warnings:
15+
- '[GET /_cat/master] is deprecated! Use [GET /_cat/cluster_manager] instead.'
16+
17+
- match:
18+
$body: |
19+
/^ id .+ \n
20+
host .+ \n
21+
ip .+ \n
22+
node .+ \n
23+
24+
$/
25+
26+
---
27+
"Test cat cluster_manager output":
28+
- skip:
29+
version: " - 1.4.99"
30+
reason: "path _cat/cluster_manager is introduced in 2.0.0"
31+
32+
- do:
33+
cat.cluster_manager: {}
34+
allowed_warnings:
35+
- '[GET /_cat/master] is deprecated! Use [GET /_cat/cluster_manager] instead.'
36+
37+
- match:
38+
$body: |
39+
/^
40+
( \S+ \s+ # node id
41+
[-\w.]+ \s+ # host name
42+
(\d{1,3}\.){3}\d{1,3} \s+ # ip address
43+
[-\w.]+ # node name
44+
\n
45+
)
46+
$/

server/src/main/java/org/opensearch/rest/action/cat/RestMasterAction.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,19 @@
5050
public class RestMasterAction extends AbstractCatAction {
5151

5252
@Override
53-
public List<Route> routes() {
54-
return singletonList(new Route(GET, "/_cat/master"));
53+
public List<ReplacedRoute> replacedRoutes() {
54+
// The deprecated path will be removed in a future major version.
55+
return singletonList(new ReplacedRoute(GET, "/_cat/cluster_manager", "/_cat/master"));
5556
}
5657

5758
@Override
5859
public String getName() {
59-
return "cat_master_action";
60+
return "cat_cluster_manager_action";
6061
}
6162

6263
@Override
6364
protected void documentation(StringBuilder sb) {
64-
sb.append("/_cat/master\n");
65+
sb.append("/_cat/cluster_manager\n");
6566
}
6667

6768
@Override

0 commit comments

Comments
 (0)