Add a field discovered_cluster_manager in get cluster health api (#2437)

* Add a new field discovered_cluster_manager to the response of `GET _cluster/health` API, which has got the same value with the existing discovered_master field, aims to replace the non-inclusive term "master" in the API response field.
* Add yaml rest test to validate `discovered_cluster_manager` and `discovered_master` field have got the same value.

Signed-off-by: Tianli Feng <ftianli@amazon.com>
This commit is contained in:
Tianli Feng 2022-03-18 15:03:06 -07:00 committed by GitHub
parent a87c9d4455
commit 1c2bdd8642
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -275,3 +275,16 @@
cluster.health:
index: index-2
- match: { status: yellow }
---
"Get cluster health has same value for discovered_master and discovered_cluster_manager":
- skip:
version: " - 1.4.99"
reason: "discovered_cluster_manager is added in 2.0.0"
- do:
cluster.health: {}
- set:
discovered_master: discovered_or_not
- match: { discovered_master: $discovered_or_not }
- match: { discovered_cluster_manager: $discovered_or_not }

View File

@ -67,6 +67,7 @@ public class ClusterHealthResponse extends ActionResponse implements StatusToXCo
private static final String NUMBER_OF_NODES = "number_of_nodes";
private static final String NUMBER_OF_DATA_NODES = "number_of_data_nodes";
private static final String DISCOVERED_MASTER = "discovered_master";
private static final String DISCOVERED_CLUSTER_MANAGER = "discovered_cluster_manager";
private static final String NUMBER_OF_PENDING_TASKS = "number_of_pending_tasks";
private static final String NUMBER_OF_IN_FLIGHT_FETCH = "number_of_in_flight_fetch";
private static final String DELAYED_UNASSIGNED_SHARDS = "delayed_unassigned_shards";
@ -376,7 +377,8 @@ public class ClusterHealthResponse extends ActionResponse implements StatusToXCo
builder.field(TIMED_OUT, isTimedOut());
builder.field(NUMBER_OF_NODES, getNumberOfNodes());
builder.field(NUMBER_OF_DATA_NODES, getNumberOfDataNodes());
builder.field(DISCOVERED_MASTER, hasDiscoveredMaster());
builder.field(DISCOVERED_MASTER, hasDiscoveredMaster()); // the field will be removed in a future major version
builder.field(DISCOVERED_CLUSTER_MANAGER, hasDiscoveredMaster());
builder.field(ACTIVE_PRIMARY_SHARDS, getActivePrimaryShards());
builder.field(ACTIVE_SHARDS, getActiveShards());
builder.field(RELOCATING_SHARDS, getRelocatingShards());