Skip to content

Commit

Permalink
Add a new REST API endpoint 'GET _cat/cluster_manager' as the replace…
Browse files Browse the repository at this point in the history
…ment 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>
  • Loading branch information
Tianli Feng authored Mar 18, 2022
1 parent 1193ec1 commit 3da9eb6
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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."
}
}
]
},
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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
)
$/
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,19 @@
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
Expand Down

0 comments on commit 3da9eb6

Please sign in to comment.