diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.health/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.health/10_basic.yml index db74e51cc2f91..0f12a87bd8771 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.health/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.health/10_basic.yml @@ -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 } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java index 6296fcd34fb23..d9094e307fff1 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java @@ -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 XContentBuilder toXContent(XContentBuilder builder, Params params) throws 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());