Skip to content

Commit

Permalink
Remove role-rebalancing
Browse files Browse the repository at this point in the history
See #230

Implemented in a minimal, hacky way to proceed with testing. Will be implemented fully (i.e. unnecessary code removed) by @Mehdi-Bendriss in another PR
  • Loading branch information
carlcsaposs-canonical committed Apr 12, 2024
1 parent 268814d commit bffd78b
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions lib/charms/opensearch/v0/helper_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,7 @@ def suggest_roles(nodes: List[Node], planned_units: int) -> List[str]:
— odd: "all" the nodes are cm_eligible nodes.
— even: "all - 1" are cm_eligible and 1 data node.
"""
max_cms = ClusterTopology.max_cluster_manager_nodes(planned_units)

base_roles = ["data", "ingest", "ml", "coordinating_only"]
full_roles = base_roles + ["cluster_manager"]
nodes_by_roles = ClusterTopology.nodes_count_by_role(nodes)
if nodes_by_roles.get("cluster_manager", 0) == max_cms:
return base_roles
return full_roles
return ["data", "ingest", "ml", "coordinating_only", "cluster_manager"]

@staticmethod
def get_cluster_settings(
Expand Down Expand Up @@ -86,19 +79,11 @@ def recompute_nodes_conf(app_name: str, nodes: List[Node]) -> Dict[str, Node]:
else:
# Leave node unchanged
nodes_by_name[node.name] = node
base_roles = ["data", "ingest", "ml", "coordinating_only"]
full_roles = base_roles + ["cluster_manager"]
highest_unit_number = max(node.unit_number for node in current_cluster_nodes)
for node in current_cluster_nodes:
# we do this in order to remove any non-default role / add any missing default role
if len(current_cluster_nodes) % 2 == 0 and node.unit_number == highest_unit_number:
roles = base_roles
else:
roles = full_roles

nodes_by_name[node.name] = Node(
name=node.name,
roles=roles,
# we do this in order to remove any non-default role / add any missing default role
roles=["data", "ingest", "ml", "coordinating_only", "cluster_manager"],
ip=node.ip,
app_name=node.app_name,
unit_number=node.unit_number,
Expand Down

0 comments on commit bffd78b

Please sign in to comment.