-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Describe the bug
Context
As part of discussion in #17422 issue we have now two new types of node roles : search and warm. Here is the PRs #17573 and #17620. We already have data role.
DiscoveryNodeRole has a boolean property canContainData which is true for search and warm nodes.
OpenSearch/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeRole.java
Line 200 in d066743
public static final DiscoveryNodeRole DATA_ROLE = new DiscoveryNodeRole("data", "d", true) { OpenSearch/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeRole.java
Line 316 in d066743
public static final DiscoveryNodeRole SEARCH_ROLE = new DiscoveryNodeRole("search", "s", true) { OpenSearch/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeRole.java
Line 303 in d066743
public static final DiscoveryNodeRole WARM_ROLE = new DiscoveryNodeRole("warm", "w", true) {
for all the other roles we have canContainData is false.
Issue
isDataNode() method in DiscoveryNode class decides if its data node based on the canContainData property of the DiscoveryNodeRole, as shown bellow:
OpenSearch/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java
Lines 113 to 115 in d066743
| public static boolean isDataNode(final Settings settings) { | |
| return getRolesFromSettings(settings).stream().anyMatch(DiscoveryNodeRole::canContainData); | |
| } |
In DiscoveryNodes it uses the isDataNode() method to construct dataNodesBuilder map.
OpenSearch/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodes.java
Lines 812 to 814 in d066743
| if (nodeEntry.getValue().isDataNode()) { | |
| dataNodesBuilder.put(nodeEntry.getKey(), nodeEntry.getValue()); | |
| } |
So when we add search or warm node, they also counted as data nodes.
Solution
So we need to refactor to have two methods like this and use it accordingly depending on the usecase:
canContainData: Checks if the node with any role can contain dataisDataNode(): Checks if the node has data role
Before we can make above changes/refactor, I am trying to understand if we need to consider impact on any other components
@Bukhtawar @gbbafna @mch2 @andrross
Related component
Cluster Manager
Metadata
Metadata
Assignees
Labels
Type
Projects
Status