Skip to content

Commit

Permalink
fix: Set the cluster status as in_progress at the end of update_nodeg…
Browse files Browse the repository at this point in the history
…roup handler

nodegroup_conductor.Handler.nodegroup_update() sets the cluster obj status
as `UPDATE_IN_PROGRESS` and saves it immediately.
But it only sets the nodegroup(ng) obj status as `UPDATE_IN_PROGRESS` and
saves it after cluster_driver.update_nodegroup() finished.
On the other side, Magnum periodic ClusterUpdateJob will trigger
cluster_driver.update_cluster_status().

In the driver, if update_cluster_status() has been finished before
update_nodegroup(), the nodegroup status could be set as `UPDATE_IN_PROGRESS`
after cluster status has been set to `UPDATE_COMPLETED`.
It means update_cluster_status() is never called again which is
responsible for ng status update even if ng status is not COMPLETED.

This PR saves the ng status first in the update_nodegroup handler, and
sets the cluster status as in_progress again at the end to requeue the
cluster in the periodic ClusterUpdateJob again.
  • Loading branch information
okozachenko1203 committed Jun 22, 2023
1 parent cabd872 commit 9d3312c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions magnum_cluster_api/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,15 @@ def update_nodegroup_status(self, context, cluster, nodegroup):
def update_nodegroup(self, context, cluster, nodegroup):
# TODO

# NOTE(okozachenko1203): First we save the nodegroup status because update_cluster_status()
# could be finished before update_nodegroup().
nodegroup.save()
resources.apply_cluster_from_magnum_cluster(context, self.k8s_api, cluster)
# NOTE(okozachenko1203): We set the cluster status as UPDATE_IN_PROGRESS again at the end because
# update_cluster_status() could be finished and cluster status has been set as
# UPDATE_COMPLETE before nodegroup_conductor.Handler.nodegroup_update finished.
cluster.status = "UPDATE_IN_PROGRESS"
cluster.save()

def delete_nodegroup(self, context, cluster, nodegroup):
nodegroup.status = "DELETE_IN_PROGRESS"
Expand Down

0 comments on commit 9d3312c

Please sign in to comment.