Skip to content

Commit

Permalink
add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
okozachenko1203 committed Oct 31, 2024
1 parent 9bebeb5 commit e23efca
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
18 changes: 18 additions & 0 deletions docs/user/labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,24 @@ is often accomplished by deploying a driver on each node.

Default value: `10.0.0.0/24`

* `different_failure_domain`

Enable [failure domain filter](https://github.com/vexxhost/nova-scheduler-filters).
This spreads cluster nodes across different failure domains.

Default value: `false`

* `server_group_policies`

Specify the server group policies. A server group is created for each cluster node group.
Nodes in a node group are scheduled following the policies specified for the corresponding
server group.

Controlplane node group uses the cluster label while other node groups use labels at each
node group level. If node group label is not configured, cluster level label is applied.

Default value: `soft-anti-affinity`

## TODO

availability_zone
Expand Down
23 changes: 18 additions & 5 deletions magnum_cluster_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@

AVAILABLE_OPERATING_SYSTEMS = ["ubuntu", "flatcar", "rockylinux"]
DEFAULT_SERVER_GROUP_POLICIES = ["soft-anti-affinity"]
AVAILABLE_SERVER_GROUP_POLICIES = [
"affinity",
"anti-affinity",
"soft-affinity",
"soft-anti-affinity",
]
CONF = cfg.CONF


Expand Down Expand Up @@ -539,18 +545,22 @@ def _get_node_group_server_group_policies(
cluster: magnum_objects.Cluster,
):
policies = node_group.labels.get("server_group_policies", "")
policies = [s for s in policies.split(",") if s in AVAILABLE_SERVER_GROUP_POLICIES]
if policies:
policies = policies.split(",")
return policies
else:
policies = _get_controlplane_server_group_policies(cluster)
return policies
return _get_controlplane_server_group_policies(cluster)


def _get_controlplane_server_group_policies(
cluster: magnum_objects.Cluster,
):
policies = cluster.labels.get("server_group_policies", "")
return policies.split(",") or DEFAULT_SERVER_GROUP_POLICIES
policies = [s for s in policies.split(",") if s in AVAILABLE_SERVER_GROUP_POLICIES]
if policies:
return policies
else:
return DEFAULT_SERVER_GROUP_POLICIES


def is_node_group_different_failure_domain(
Expand Down Expand Up @@ -599,6 +609,7 @@ def delete_controlplane_server_group(
_delete_server_group(
name=cluster.stack_id,
ctx=ctx,
project_id=cluster.project_id,
)


Expand All @@ -610,6 +621,7 @@ def delete_worker_server_group(
_delete_server_group(
name=f"{cluster.stack_id}-{node_group.name}",
ctx=ctx,
project_id=cluster.project_id,
)


Expand Down Expand Up @@ -638,8 +650,9 @@ def _ensure_server_group(
def _delete_server_group(
name: string,
ctx: context.RequestContext,
project_id: string = None,
):
server_group_id = get_server_group_id(name)
server_group_id = get_server_group_id(ctx, name, project_id)
if server_group_id is None:
return

Expand Down

0 comments on commit e23efca

Please sign in to comment.