From ac29883cbf6df202f41ca6b0f5f47c2c7dd6e49c Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Sun, 13 Mar 2022 21:52:20 -0700 Subject: [PATCH] Fix yaml rest test by adding allow warnings Signed-off-by: Tianli Feng --- .../rest-api-spec/test/cluster.state/20_filtering.yml | 3 +++ .../rest/action/admin/cluster/RestClusterStateAction.java | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/20_filtering.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/20_filtering.yml index 5c0dd2bc04c23..3d20f1d0f7e52 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/20_filtering.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/20_filtering.yml @@ -158,6 +158,7 @@ setup: - skip: version: " - 6.3.99" reason: "cluster state including cluster_uuid at the top level is new in v6.4.0 and higher" + features: allowed_warnings # Get the current cluster_uuid - do: @@ -167,6 +168,8 @@ setup: - do: cluster.state: metric: [ master_node, version ] + allowed_warnings: + - 'Deprecated value [master_node] used for parameter [metric]. To promote inclusive language, please use [cluster_manager_node] instead. It will be unsupported in a future major version.' - match: { cluster_uuid: $cluster_uuid } - is_true: master_node diff --git a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterStateAction.java b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterStateAction.java index ee9aeb64462a2..17b88bbcf4be6 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterStateAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterStateAction.java @@ -125,7 +125,9 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC || metrics.contains(ClusterState.Metric.CLUSTER_MANAGER_NODE) ); // TODO: Remove the DeprecationLogger after removing MASTER_ROLE. - if (metrics.contains(ClusterState.Metric.MASTER_NODE)) { + // Because "_all" value will add all Metric into metrics set, for prevent deprecation message shown in that case, + // add the check of validating Metric.CLUSTER_MANAGER_NODE is not in the metrics set. + if (metrics.contains(ClusterState.Metric.MASTER_NODE) && !metrics.contains(ClusterState.Metric.CLUSTER_MANAGER_NODE)) { deprecationLogger.deprecate("cluster_state_metric_parameter_master_node_value", DEPRECATED_MESSAGE_MASTER_NODE); } /*