summaryrefslogtreecommitdiff
path: root/heat/engine/stack.py
diff options
context:
space:
mode:
authorZane Bitter <zbitter@redhat.com>2018-07-30 20:48:25 -0400
committerZane Bitter <zbitter@redhat.com>2018-07-30 20:48:28 -0400
commite63778efc91869efbd41e2f96b0c554aef1c80e5 (patch)
tree002dab60a9705d25f22548b5ce3edaee2ebb831c /heat/engine/stack.py
parent15554a2debda84e3f49d3c0b2e056a1372f3de13 (diff)
downloadheat-e63778efc91869efbd41e2f96b0c554aef1c80e5.tar.gz
Eliminate client race condition in convergence delete
Previously when doing a delete in convergence, we spawned a new thread to start the delete. This was to ensure the request returned without waiting for potentially slow operations like deleting snapshots and stopping existing workers (which could have caused RPC timeouts). The result, however, was that the stack was not guaranteed to be DELETE_IN_PROGRESS by the time the request returned. In the case where a previous delete had failed, a client request to show the stack issued soon after the delete had returned would likely show the stack status as DELETE_FAILED still. Only a careful examination of the updated_at timestamp would reveal that this corresponded to the previous delete and not the one just issued. In the case of a nested stack, this could leave the parent stack effectively undeletable. (Since the updated_at time is not modified on delete in the legacy path, we never checked it when deleting a nested stack.) To prevent this, change the order of operations so that the stack is first put into the DELETE_IN_PROGRESS state before the delete_stack call returns. Only after the state is stored, spawn a thread to complete the operation. Since there is no stack lock in convergence, this gives us the flexibility to cancel other in-progress workers after we've already written to the Stack itself to start a new traversal. The previous patch in the series means that snapshots are now also deleted after the stack is marked as DELETE_IN_PROGRESS. This is consistent with the legacy path. Change-Id: Ib767ce8b39293c2279bf570d8399c49799cbaa70 Story: #1669608 Task: 23174
Diffstat (limited to 'heat/engine/stack.py')
-rw-r--r--heat/engine/stack.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/heat/engine/stack.py b/heat/engine/stack.py
index 6a1e954b9..7dab91a7d 100644
--- a/heat/engine/stack.py
+++ b/heat/engine/stack.py
@@ -1300,7 +1300,8 @@ class Stack(collections.Mapping):
updater()
@profiler.trace('Stack.converge_stack', hide_args=False)
- def converge_stack(self, template, action=UPDATE, new_stack=None):
+ def converge_stack(self, template, action=UPDATE, new_stack=None,
+ pre_converge=None):
"""Update the stack template and trigger convergence for resources."""
if action not in [self.CREATE, self.ADOPT]:
# no back-up template for create action
@@ -1354,9 +1355,10 @@ class Stack(collections.Mapping):
# TODO(later): lifecycle_plugin_utils.do_pre_ops
- self.thread_group_mgr.start(self.id, self._converge_create_or_update)
+ self.thread_group_mgr.start(self.id, self._converge_create_or_update,
+ pre_converge=pre_converge)
- def _converge_create_or_update(self):
+ def _converge_create_or_update(self, pre_converge=None):
current_resources = self._update_or_store_resources()
self._compute_convg_dependencies(self.ext_rsrcs_db, self.dependencies,
current_resources)
@@ -1373,6 +1375,8 @@ class Stack(collections.Mapping):
'action': self.action})
return
+ if callable(pre_converge):
+ pre_converge()
if self.action == self.DELETE:
try:
self.delete_all_snapshots()