Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace 'discovered_master' with 'discovered_cluster_manager' in 'GET Cat Health' API #2438

Merged
merged 9 commits into from
Mar 18, 2022
Original file line number Diff line number Diff line change
@@ -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: |
Expand All @@ -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":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ protected Table getTableWithHeader(final RestRequest request) {
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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the Cluster Health API - #2437 - we chose to add a "cluster_manager" field alongside the "master" one, but here we're replacing "master" with "cluster_manager". Why the difference in approach?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh, should've read the PR description more carefully 😅

To answer my own question - #2437 is adding a new field in the response, so we cannot replace it in-line. In this PR, the change affects the human-readable table header in the output, which we hardly expect to be parsed by code.

Feel free to ignore my question above 😄

Copy link
Collaborator Author

@tlfeng tlfeng Mar 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @kartg, I really appreciate your careful attitude, to put the explanation in detail.
It's also my negligence that I didn't explain more in this PR description, after add more description in anther PR with the same concern: #2441 (comment) .
I will update in this PR description to encourage users who wants to use the same API request to parse the response of CAT Health in 2.x nodes, to filter output by specifying table header, such as GET _cat/health?v&h=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");
Expand Down