From ee048851f5c5e0019f0e212fee8efc63c752d057 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Fri, 18 Mar 2022 15:04:03 -0700 Subject: [PATCH] Replace 'discovered_master' with 'discovered_cluster_manager' in 'GET Cat Health' API (#2438) * Replace 'discovered_master' with 'discovered_cluster_manager' in the table header of `GET Cat Health` API, to promote inclusive language. * Add `dcm` as the alias for the table header `discovered_cluster_manager` * Add `discovered_master` as the alias for the table header `discovered_cluster_manager`, for keeping compatibility when using `GET _cat/nodes?v&h=discovered_master` to show the specific column only. * Add YAML rest test Signed-off-by: Tianli Feng --- .../test/cat.health/10_basic.yml | 42 +++++++++++++++++-- .../rest/action/cat/RestHealthAction.java | 7 +++- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.health/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.health/10_basic.yml index 731fc5d166e..0d945d01a6d 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.health/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.health/10_basic.yml @@ -1,11 +1,19 @@ --- -"Help": +"Help - before 2.0.0": - skip: - version: " - 7.10.99" - reason: "discovered_master added in OpenSearch 1.0.0" + version: " - 7.10.99 , 2.0.0 - " + reason: "discovered_master added in OpenSearch 1.0.0, and renamed to discovered_cluster_manager in 2.0.0" + features: node_selector - do: cat.health: help: true + node_selector: + # Only send request to nodes in <2.0 versions, especially during ':qa:mixed-cluster:v1.x.x#mixedClusterTest'. + # Because YAML REST test takes the minimum OpenSearch version in the cluster to apply the filter in 'skip' section, + # see OpenSearchClientYamlSuiteTestCase#initAndResetContext() for detail. + # During 'mixedClusterTest', the cluster can be mixed with nodes in 1.x and 2.x versions, + # so node_selector is required, and only filtering version in 'skip' is not enough. + version: "1.0.0 - 1.4.99" - match: $body: | @@ -27,6 +35,34 @@ $/ +--- +"Help": + - skip: + version: " - 1.4.99" + reason: "discovered_cluster_manager is added in OpenSearch 2.0.0" + - do: + cat.health: + help: true + + - match: + $body: | + /^ epoch .+ \n + timestamp .+ \n + cluster .+ \n + status .+ \n + node.total .+ \n + node.data .+ \n + discovered_cluster_manager .+ \n + shards .+ \n + pri .+ \n + relo .+ \n + init .+ \n + unassign .+ \n + pending_tasks .+ \n + max_task_wait_time .+ \n + active_shards_percent .+ \n + + $/ --- "Empty cluster": diff --git a/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java b/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java index b6e945620f9..c05b0b9c771 100644 --- a/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java +++ b/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java @@ -88,7 +88,12 @@ public class RestHealthAction extends AbstractCatAction { t.addCell("status", "alias:st;desc:health status"); t.addCell("node.total", "alias:nt,nodeTotal;text-align:right;desc:total number of nodes"); t.addCell("node.data", "alias:nd,nodeData;text-align:right;desc:number of nodes that can store data"); - t.addCell("discovered_master", "alias:dm;text-align:right;desc:discovered master"); + // TODO: Remove the header alias 'discovered_master', after removing MASTER_ROLE. + // The alias 'discovered_master' is added for compatibility when using request parameter 'h=discovered_master'. + t.addCell( + "discovered_cluster_manager", + "alias:dcm,dm,discovered_master;text-align:right;desc:cluster manager is discovered or not" + ); t.addCell("shards", "alias:t,sh,shards.total,shardsTotal;text-align:right;desc:total number of shards"); t.addCell("pri", "alias:p,shards.primary,shardsPrimary;text-align:right;desc:number of primary shards"); t.addCell("relo", "alias:r,shards.relocating,shardsRelocating;text-align:right;desc:number of relocating nodes");