Skip to content

Commit

Permalink
fix: upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaser committed Nov 7, 2022
1 parent 28ce8b0 commit bda670d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions magnum_cluster_api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
CLUSTER_CLASS_VERSION = "v0.0.0"
CLUSTER_CLASS_NAME = f"magnum-{CLUSTER_CLASS_VERSION}"

CLUSTER_UPGRADE_LABELS = {"kube_tag"}

PLACEHOLDER = "PLACEHOLDER"


Expand Down Expand Up @@ -1248,7 +1250,7 @@ def get_object(self) -> objects.Cluster:
},
{
"name": "imageUUID",
"value": self.cluster.cluster_template.image_id,
"value": self.cluster.default_ng_master.image_id,
},
{
"name": "nodeCidr",
Expand Down Expand Up @@ -1283,10 +1285,18 @@ def apply_cluster_from_magnum_cluster(
if cluster_template is None:
cluster_template = cluster.cluster_template

# TODO: intelligently determine the changing labels
# and only update those (use get_labels_diff)
cluster.labels = cluster_template.labels
cluster.cluster_template = cluster_template
# NOTE(mnaser): When using Cluster API, there is a 1:1 mapping between image
# and version of Kubernetes, therefore, we need to ignore the
# `image_id` field, as well as copy over any tags relating to
# the Kubernetes version.
#
# I hate this.
for label in CLUSTER_UPGRADE_LABELS:
cluster.labels[label] = cluster_template.labels[label]
for ng in cluster.nodegroups:
ng.image_id = cluster_template.image_id
ng.labels[label] = cluster_template.labels[label]
ng.save()
cluster.save()

Cluster(context, api, cluster).apply()
Expand Down

0 comments on commit bda670d

Please sign in to comment.