From c73c35c8af2b703b5fe4aff30c278ebd558a36d4 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Tue, 8 Mar 2022 16:36:18 -0800 Subject: [PATCH 1/8] Add cluster_manager_node into cluster state metric Signed-off-by: Tianli Feng --- .../rest-api-spec/api/cluster.reroute.json | 1 + .../rest-api-spec/api/cluster.state.json | 1 + .../test/cluster.reroute/10_basic.yml | 15 +++++++++++++++ .../cluster.reroute/20_response_filtering.yml | 13 +++++++++++++ .../rest-api-spec/test/cluster.state/10_basic.yml | 15 +++++++++++++++ .../test/cluster.state/20_filtering.yml | 13 +++++++++++++ .../java/org/opensearch/cluster/ClusterState.java | 6 ++++++ .../admin/cluster/RestClusterStateAction.java | 6 +++++- .../org/opensearch/cluster/ClusterStateTests.java | 4 ++++ 9 files changed, 73 insertions(+), 1 deletion(-) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.reroute.json b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.reroute.json index b0e8054fc9e53..bcf2704110664 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.reroute.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.reroute.json @@ -37,6 +37,7 @@ "nodes", "routing_table", "master_node", + "cluster_manager_node", "version" ], "description":"Limit the information returned to the specified metrics. Defaults to all but metadata" diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.state.json b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.state.json index 017705082d189..c17e5b073e361 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.state.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.state.json @@ -55,6 +55,7 @@ "routing_table", "routing_nodes", "master_node", + "cluster_manager_node", "version" ], "description":"Limit the information returned to the specified metrics" diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/10_basic.yml index 771f647a952c7..1b45e19c24acf 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/10_basic.yml @@ -2,3 +2,18 @@ "Basic sanity check": - do: cluster.reroute: {} + +--- +"Cluster reroute returns cluster_manager_node": + - skip: + version: " - 1.4.99" + reason: "The metric cluster_manager_node is added to cluster state in version 2.0.0" + + - do: + cluster.reroute: {} + + - set: + state.cluster_manager_node: node_id + + - match: {state.master_node: $node_id} + - match: {state.cluster_manager_node: $node_id} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/20_response_filtering.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/20_response_filtering.yml index 437b78e6119a7..c05d1db51142e 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/20_response_filtering.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/20_response_filtering.yml @@ -3,6 +3,7 @@ - do: cluster.reroute: {} - is_false: state.metadata + --- "return metadata if requested": - do: @@ -12,3 +13,15 @@ - is_true: state.metadata - is_false: state.nodes +--- +"Filter the cluster reroute by cluster_manager_node only should work": + - skip: + version: " - 1.4.99" + reason: "The metric cluster_manager_node is added to cluster state in version 2.0.0" + + - do: + cluster.reroute: + metric: [ cluster_manager_node ] + + - is_true: state.cluster_manager_node + - is_false: state.master_node diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/10_basic.yml index b443e322f80f6..fa973454cfba5 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/10_basic.yml @@ -17,3 +17,18 @@ - is_true: cluster_uuid - is_true: master_node + +--- +"Get cluster state returns cluster_manager_node": + - skip: + version: " - 1.4.99" + reason: "The metric cluster_manager_node is added to cluster state in version 2.0.0" + + - do: + cluster.state: {} + + - set: + cluster_manager_node: node_id + + - match: {master_node: $node_id} + - match: {cluster_manager_node: $node_id} 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 88da42ee876be..5c0dd2bc04c23 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 @@ -180,3 +180,16 @@ setup: - match: { cluster_uuid: $cluster_uuid } - is_true: routing_table + +--- +"Filter the cluster state by cluster_manager_node only should work": + - skip: + version: " - 1.4.99" + reason: "The metric cluster_manager_node is added to cluster state in version 2.0.0" + + - do: + cluster.state: + metric: [ cluster_manager_node ] + + - is_true: cluster_manager_node + - is_false: master_node diff --git a/server/src/main/java/org/opensearch/cluster/ClusterState.java b/server/src/main/java/org/opensearch/cluster/ClusterState.java index 6e17be690dd9d..246889115fdbd 100644 --- a/server/src/main/java/org/opensearch/cluster/ClusterState.java +++ b/server/src/main/java/org/opensearch/cluster/ClusterState.java @@ -403,6 +403,7 @@ public boolean supersedes(ClusterState other) { public enum Metric { VERSION("version"), MASTER_NODE("master_node"), + CLUSTER_MANAGER_NODE("cluster_manager_node"), BLOCKS("blocks"), NODES("nodes"), METADATA("metadata"), @@ -467,6 +468,11 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field("master_node", nodes().getMasterNodeId()); } + // Value of the field is identical with the above, and aims to replace the above field. + if (metrics.contains(Metric.CLUSTER_MANAGER_NODE)) { + builder.field("cluster_manager_node", nodes().getMasterNodeId()); + } + if (metrics.contains(Metric.BLOCKS)) { builder.startObject("blocks"); 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 5056e29d47dce..892bcd4f342e9 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 @@ -112,7 +112,11 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC if (request.hasParam("metric")) { EnumSet metrics = ClusterState.Metric.parseString(request.param("metric"), true); // do not ask for what we do not need. - clusterStateRequest.nodes(metrics.contains(ClusterState.Metric.NODES) || metrics.contains(ClusterState.Metric.MASTER_NODE)); + clusterStateRequest.nodes( + metrics.contains(ClusterState.Metric.NODES) + || metrics.contains(ClusterState.Metric.MASTER_NODE) + || metrics.contains(ClusterState.Metric.CLUSTER_MANAGER_NODE) + ); /* * there is no distinction in Java api between routing_table and routing_nodes, it's the same info set over the wire, one single * flag to ask for it diff --git a/server/src/test/java/org/opensearch/cluster/ClusterStateTests.java b/server/src/test/java/org/opensearch/cluster/ClusterStateTests.java index 03db6b22bc8bd..b343467e5e96e 100644 --- a/server/src/test/java/org/opensearch/cluster/ClusterStateTests.java +++ b/server/src/test/java/org/opensearch/cluster/ClusterStateTests.java @@ -147,6 +147,7 @@ public void testToXContent() throws IOException { + " \"version\" : 0,\n" + " \"state_uuid\" : \"stateUUID\",\n" + " \"master_node\" : \"masterNodeId\",\n" + + " \"cluster_manager_node\" : \"masterNodeId\",\n" + " \"blocks\" : {\n" + " \"global\" : {\n" + " \"1\" : {\n" @@ -354,6 +355,7 @@ public void testToXContent_FlatSettingTrue_ReduceMappingFalse() throws IOExcepti + " \"version\" : 0,\n" + " \"state_uuid\" : \"stateUUID\",\n" + " \"master_node\" : \"masterNodeId\",\n" + + " \"cluster_manager_node\" : \"masterNodeId\",\n" + " \"blocks\" : {\n" + " \"global\" : {\n" + " \"1\" : {\n" @@ -554,6 +556,7 @@ public void testToXContent_FlatSettingFalse_ReduceMappingTrue() throws IOExcepti + " \"version\" : 0,\n" + " \"state_uuid\" : \"stateUUID\",\n" + " \"master_node\" : \"masterNodeId\",\n" + + " \"cluster_manager_node\" : \"masterNodeId\",\n" + " \"blocks\" : {\n" + " \"global\" : {\n" + " \"1\" : {\n" @@ -780,6 +783,7 @@ public void testToXContentSameTypeName() throws IOException { + " \"version\" : 0,\n" + " \"state_uuid\" : \"stateUUID\",\n" + " \"master_node\" : null,\n" + + " \"cluster_manager_node\" : null,\n" + " \"blocks\" : { },\n" + " \"nodes\" : { },\n" + " \"metadata\" : {\n" From e8dbdf27258c77ce484e9b894801b10a9e383c0b Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Tue, 8 Mar 2022 17:04:12 -0800 Subject: [PATCH 2/8] Add deprecation notice to MASTER_NODE enum value Signed-off-by: Tianli Feng --- .../src/main/java/org/opensearch/cluster/ClusterState.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/src/main/java/org/opensearch/cluster/ClusterState.java b/server/src/main/java/org/opensearch/cluster/ClusterState.java index 246889115fdbd..d6db5e0933332 100644 --- a/server/src/main/java/org/opensearch/cluster/ClusterState.java +++ b/server/src/main/java/org/opensearch/cluster/ClusterState.java @@ -402,6 +402,11 @@ public boolean supersedes(ClusterState other) { public enum Metric { VERSION("version"), + + /** + * @deprecated Use CLUSTER_MANAGER_NODE instead, for promoting inclusive language. + */ + @Deprecated MASTER_NODE("master_node"), CLUSTER_MANAGER_NODE("cluster_manager_node"), BLOCKS("blocks"), From 9bc6994ad32d49df3b291be233446b9ae54a8e7d Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Tue, 8 Mar 2022 19:19:21 -0800 Subject: [PATCH 3/8] Fix ClusterRerouteResponseTests Signed-off-by: Tianli Feng --- .../admin/cluster/reroute/ClusterRerouteResponseTests.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java index f0384f249879d..7a7bc18876932 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java @@ -94,6 +94,7 @@ public void testToXContent() throws IOException { + clusterState.stateUUID() + "\",\n" + " \"master_node\" : \"node0\",\n" + + " \"cluster_manager_node\" : \"node0\",\n" + " \"blocks\" : { },\n" + " \"nodes\" : {\n" + " \"node0\" : {\n" @@ -173,7 +174,7 @@ public void testToXContent() throws IOException { XContentBuilder builder = JsonXContent.contentBuilder().prettyPrint(); Map params = new HashMap<>(); params.put("explain", "true"); - params.put("metric", "version,master_node"); + params.put("metric", "version,cluster_manager_node"); clusterRerouteResponse.toXContent(builder, new ToXContent.MapParams(params)); assertEquals( "{\n" @@ -184,7 +185,7 @@ public void testToXContent() throws IOException { + " \"state_uuid\" : \"" + clusterState.stateUUID() + "\",\n" - + " \"master_node\" : \"node0\"\n" + + " \"cluster_manager_node\" : \"node0\"\n" + " },\n" + " \"explanations\" : [\n" + " {\n" From d2c177aee5ea62e5971835713089dceb246fec1b Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Wed, 9 Mar 2022 18:04:08 +0000 Subject: [PATCH 4/8] Modify deprecation javadoc Signed-off-by: Tianli Feng --- server/src/main/java/org/opensearch/cluster/ClusterState.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/cluster/ClusterState.java b/server/src/main/java/org/opensearch/cluster/ClusterState.java index d6db5e0933332..a7c04e12247a4 100644 --- a/server/src/main/java/org/opensearch/cluster/ClusterState.java +++ b/server/src/main/java/org/opensearch/cluster/ClusterState.java @@ -404,7 +404,7 @@ public enum Metric { VERSION("version"), /** - * @deprecated Use CLUSTER_MANAGER_NODE instead, for promoting inclusive language. + * @deprecated As of 2.0, because promoting inclusive language, replaced by {@link CLUSTER_MANAGER_NODE} */ @Deprecated MASTER_NODE("master_node"), From d579487a574d8e604515d810a763275a0ebffed6 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Sat, 12 Mar 2022 23:28:06 -0800 Subject: [PATCH 5/8] Add deprecation notice when using metric=master_node Signed-off-by: Tianli Feng --- .../java/org/opensearch/cluster/ClusterState.java | 3 ++- .../admin/cluster/RestClusterRerouteAction.java | 13 +++++++++++++ .../admin/cluster/RestClusterStateAction.java | 11 +++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/cluster/ClusterState.java b/server/src/main/java/org/opensearch/cluster/ClusterState.java index a7c04e12247a4..d6883988dcdf8 100644 --- a/server/src/main/java/org/opensearch/cluster/ClusterState.java +++ b/server/src/main/java/org/opensearch/cluster/ClusterState.java @@ -60,6 +60,7 @@ import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.VersionedNamedWriteable; +import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.ToXContentFragment; import org.opensearch.common.xcontent.XContentBuilder; @@ -404,7 +405,7 @@ public enum Metric { VERSION("version"), /** - * @deprecated As of 2.0, because promoting inclusive language, replaced by {@link CLUSTER_MANAGER_NODE} + * @deprecated As of 2.0, because promoting inclusive language, replaced by {@link #CLUSTER_MANAGER_NODE} */ @Deprecated MASTER_NODE("master_node"), diff --git a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java index 1d1feff36f239..e6cdfa92636f0 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java @@ -39,6 +39,7 @@ import org.opensearch.cluster.routing.allocation.command.AllocationCommands; import org.opensearch.common.ParseField; import org.opensearch.common.Strings; +import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.common.settings.SettingsFilter; import org.opensearch.common.xcontent.ObjectParser; @@ -78,6 +79,12 @@ public RestClusterRerouteAction(SettingsFilter settingsFilter) { this.settingsFilter = settingsFilter; } + // TODO: Remove the DeprecationLogger after removing MASTER_ROLE. + // It's used to log deprecation when request parameter 'metric' contains 'master_node'. + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestClusterRerouteAction.class); + private static final String DEPRECATED_MESSAGE_MASTER_NODE = + "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."; + @Override public List routes() { return singletonList(new Route(POST, "/_cluster/reroute")); @@ -104,6 +111,12 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC final String metric = request.param("metric"); if (metric == null) { request.params().put("metric", DEFAULT_METRICS); + } else { + // TODO: Remove the statements in 'else' after removing MASTER_ROLE. + EnumSet metrics = ClusterState.Metric.parseString(request.param("metric"), true); + if (metrics.contains(ClusterState.Metric.MASTER_NODE)) { + deprecationLogger.deprecate("cluster_reroute_metric_parameter_master_node_value", DEPRECATED_MESSAGE_MASTER_NODE); + } } return channel -> client.admin().cluster().reroute(clusterRerouteRequest, new RestToXContentListener<>(channel)); } 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 892bcd4f342e9..be2f773312042 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 @@ -40,6 +40,7 @@ import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.metadata.Metadata; import org.opensearch.common.Strings; +import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.common.settings.SettingsFilter; import org.opensearch.common.xcontent.ToXContent; @@ -71,6 +72,12 @@ public RestClusterStateAction(SettingsFilter settingsFilter) { this.settingsFilter = settingsFilter; } + // TODO: Remove the DeprecationLogger after removing MASTER_ROLE. + // It's used to log deprecation when request parameter 'metric' contains 'master_node'. + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestClusterStateAction.class); + private static final String DEPRECATED_MESSAGE_MASTER_NODE = + "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."; + @Override public String getName() { return "cluster_state_action"; @@ -117,6 +124,10 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC || metrics.contains(ClusterState.Metric.MASTER_NODE) || metrics.contains(ClusterState.Metric.CLUSTER_MANAGER_NODE) ); + // TODO: Remove the DeprecationLogger after removing MASTER_ROLE. + if (metrics.contains(ClusterState.Metric.MASTER_NODE)) { + deprecationLogger.deprecate("cluster_state_metric_parameter_master_node_value", DEPRECATED_MESSAGE_MASTER_NODE); + } /* * there is no distinction in Java api between routing_table and routing_nodes, it's the same info set over the wire, one single * flag to ask for it From 0d66c0cb53fcc1200d1b930457e31d452eef4ef2 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Sat, 12 Mar 2022 23:40:48 -0800 Subject: [PATCH 6/8] Adjust format by spotlessApply task Signed-off-by: Tianli Feng --- server/src/main/java/org/opensearch/cluster/ClusterState.java | 1 - .../rest/action/admin/cluster/RestClusterRerouteAction.java | 4 ++-- .../rest/action/admin/cluster/RestClusterStateAction.java | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/org/opensearch/cluster/ClusterState.java b/server/src/main/java/org/opensearch/cluster/ClusterState.java index d6883988dcdf8..459c0b9502acf 100644 --- a/server/src/main/java/org/opensearch/cluster/ClusterState.java +++ b/server/src/main/java/org/opensearch/cluster/ClusterState.java @@ -60,7 +60,6 @@ import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.VersionedNamedWriteable; -import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.ToXContentFragment; import org.opensearch.common.xcontent.XContentBuilder; diff --git a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java index e6cdfa92636f0..796501ef2e187 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java @@ -80,10 +80,10 @@ public RestClusterRerouteAction(SettingsFilter settingsFilter) { } // TODO: Remove the DeprecationLogger after removing MASTER_ROLE. - // It's used to log deprecation when request parameter 'metric' contains 'master_node'. + // It's used to log deprecation when request parameter 'metric' contains 'master_node'. private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestClusterRerouteAction.class); private static final String DEPRECATED_MESSAGE_MASTER_NODE = - "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."; + "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."; @Override public List routes() { 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 be2f773312042..ee9aeb64462a2 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 @@ -73,10 +73,10 @@ public RestClusterStateAction(SettingsFilter settingsFilter) { } // TODO: Remove the DeprecationLogger after removing MASTER_ROLE. - // It's used to log deprecation when request parameter 'metric' contains 'master_node'. + // It's used to log deprecation when request parameter 'metric' contains 'master_node'. private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestClusterStateAction.class); private static final String DEPRECATED_MESSAGE_MASTER_NODE = - "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."; + "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."; @Override public String getName() { From ac29883cbf6df202f41ca6b0f5f47c2c7dd6e49c Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Sun, 13 Mar 2022 21:52:20 -0700 Subject: [PATCH 7/8] 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); } /* From 40a04e4f9293a0e7ed3335021d7bf82a3e53201b Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Mon, 14 Mar 2022 15:50:25 -0700 Subject: [PATCH 8/8] modify the condition to show deprecation notice Signed-off-by: Tianli Feng --- .../rest/action/admin/cluster/RestClusterRerouteAction.java | 4 +++- .../rest/action/admin/cluster/RestClusterStateAction.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java index 796501ef2e187..f519da109ba09 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java @@ -114,7 +114,9 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC } else { // TODO: Remove the statements in 'else' after removing MASTER_ROLE. EnumSet metrics = ClusterState.Metric.parseString(request.param("metric"), true); - 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 metrics set doesn't contain all enum elements. + if (!metrics.equals(EnumSet.allOf(ClusterState.Metric.class)) && metrics.contains(ClusterState.Metric.MASTER_NODE)) { deprecationLogger.deprecate("cluster_reroute_metric_parameter_master_node_value", DEPRECATED_MESSAGE_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 17b88bbcf4be6..32aa055c18300 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 @@ -126,8 +126,8 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC ); // TODO: Remove the DeprecationLogger after removing MASTER_ROLE. // 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)) { + // add the check of validating metrics set doesn't contain all enum elements. + if (!metrics.equals(EnumSet.allOf(ClusterState.Metric.class)) && metrics.contains(ClusterState.Metric.MASTER_NODE)) { deprecationLogger.deprecate("cluster_state_metric_parameter_master_node_value", DEPRECATED_MESSAGE_MASTER_NODE); } /*