From 1cdc0628a28da32ef52324244a4c97b0794c2542 Mon Sep 17 00:00:00 2001 From: Bharat Kunwar Date: Thu, 30 Jul 2020 09:59:09 +0000 Subject: [PATCH] [fix] Sync nodegroup status before delete_complete Magnum cluster deletion is not behaving as expected. While it appears to delete successfully, _delete_complete routine in magnum/drivers/heat/driver.py is never called because the status of nodegroups have not had the chance to sync with Heat before _check_delete_complete is called. As a result, for example, trustee user accounts are left orphaned. This PS changes or order of activities so that _delete_complete is invoked successfully. Story: 2007965 Task: 40459 Change-Id: Ibadd5b57fe175bb0b100266e2dbcc2e1ea4efcf9 --- magnum/drivers/heat/driver.py | 18 +++++++++--------- ...nsure-delete-complete-2f9bb53616e1e02b.yaml | 5 +++++ 2 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/ensure-delete-complete-2f9bb53616e1e02b.yaml diff --git a/magnum/drivers/heat/driver.py b/magnum/drivers/heat/driver.py index 4ff4110808..a0bf499b51 100755 --- a/magnum/drivers/heat/driver.py +++ b/magnum/drivers/heat/driver.py @@ -520,15 +520,6 @@ class HeatPoller(object): stack = self.openstack_client.heat().stacks.get( self.nodegroup.stack_id, resolve_outputs=False) - # poll_and_check is detached and polling long time to check - # status, so another user/client can call delete cluster/stack. - if stack.stack_status == fields.ClusterStatus.DELETE_COMPLETE: - if self.nodegroup.is_default: - self._check_delete_complete() - else: - self.nodegroup.destroy() - return - if stack.stack_status in (fields.ClusterStatus.CREATE_COMPLETE, fields.ClusterStatus.UPDATE_COMPLETE): # Resolve all outputs if the stack is COMPLETE @@ -543,6 +534,15 @@ class HeatPoller(object): nodegroups=[self.nodegroup]) self._sync_cluster_status(stack) + # poll_and_check is detached and polling long time to check + # status, so another user/client can call delete cluster/stack. + if stack.stack_status == fields.ClusterStatus.DELETE_COMPLETE: + if self.nodegroup.is_default: + self._check_delete_complete() + else: + self.nodegroup.destroy() + return + if stack.stack_status in (fields.ClusterStatus.CREATE_FAILED, fields.ClusterStatus.DELETE_FAILED, fields.ClusterStatus.UPDATE_FAILED, diff --git a/releasenotes/notes/ensure-delete-complete-2f9bb53616e1e02b.yaml b/releasenotes/notes/ensure-delete-complete-2f9bb53616e1e02b.yaml new file mode 100644 index 0000000000..d6ca68134d --- /dev/null +++ b/releasenotes/notes/ensure-delete-complete-2f9bb53616e1e02b.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes a regression which left behind trustee user accounts and certificates + when a cluster is deleted.