Skip to content
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

chore: Drop MachineDeployment annotation workaround #147

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions magnum_cluster_api/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,6 @@ def update_nodegroup_status(self, context, cluster, nodegroup):
elif phase in ("Failed", "Unknown"):
nodegroup.status = f"{action}_FAILED"

# TODO(mnaser): We can remove this once we support Cluster API 1.4.0
# https://github.com/kubernetes-sigs/cluster-api/pull/7917
resources.set_autoscaler_metadata_in_machinedeployment(
context, self.k8s_api, cluster, nodegroup
)

nodegroup.save()

return nodegroup
Expand Down
29 changes: 0 additions & 29 deletions magnum_cluster_api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -1775,35 +1775,6 @@ def delete(self):
capi_cluster.delete()


def set_autoscaler_metadata_in_machinedeployment(
context: context.RequestContext,
api: pykube.HTTPClient,
cluster: magnum_objects.Cluster,
nodegroup: magnum_objects.NodeGroup,
):
if not utils.get_auto_scaling_enabled(cluster):
return
mds = objects.MachineDeployment.objects(api).filter(
namespace="magnum-system",
selector={
"cluster.x-k8s.io/cluster-name": cluster.stack_id,
"topology.cluster.x-k8s.io/deployment-name": nodegroup.name,
},
)
for md in mds:
# NOTE(mnaser): The autoscaler will not scale under the minimum number
# of nodes, so we do that ourselves here.
if AUTOSCALE_ANNOTATION_MIN not in md.obj["metadata"]["annotations"]:
md.obj["spec"]["replicas"] = nodegroup.node_count
md.obj["metadata"]["annotations"][AUTOSCALE_ANNOTATION_MIN] = str(
utils.get_node_group_min_node_count(nodegroup)
)
md.obj["metadata"]["annotations"][AUTOSCALE_ANNOTATION_MAX] = str(
utils.get_node_group_max_node_count(context, nodegroup)
)
md.update()


def apply_cluster_from_magnum_cluster(
context: context.RequestContext,
api: pykube.HTTPClient,
Expand Down