-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add 'cluster_manager_node' into ClusterState Metric as an alternative to 'master_node' #2415
Changes from all commits
c73c35c
e8dbdf2
9bc6994
d2c177a
97f0f37
d579487
0d66c0c
7531fb7
ac29883
40a04e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<Route> routes() { | ||
return singletonList(new Route(POST, "/_cluster/reroute")); | ||
|
@@ -104,6 +111,14 @@ 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<ClusterState.Metric> metrics = ClusterState.Metric.parseString(request.param("metric"), true); | ||
// 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); | ||
} | ||
} | ||
return channel -> client.admin().cluster().reroute(clusterRerouteRequest, new RestToXContentListener<>(channel)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For my understanding - are there no changes needed here to support/parse the new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new |
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted on a related PR, please create a Github issue to track changing these internal methods to be inclusive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my mind, it's not an internal method, because it's shown in the Javadoc (https://opensearch.org/javadocs/1.3.0/OpenSearch/server/build/docs/javadoc/org/opensearch/cluster/node/DiscoveryNodes.html#getMasterNodeId()).
I think method listed in Javadoc needs an enough period of time to deprecate in advance, before removing.
The issue to track the internal usages is #1548, and there is a PR out. Maybe I'd better update the description to list usages in different file directories.
(Pasted the related PR here #2453 (comment))