Fix for resources stuck in progress after engine crash

When a stack is IN_PROGRESS and an UPDATE or RESTORE is called
after an engine crash, we set status of the stack and all of its
IN_PROGRESS resources to FAILED

Change-Id: Ia3adbfeff16c69719f9e5365657ab46a0932ec9b
Closes-Bug: #1570576
This commit is contained in:
Tanvir Talukder
2017-01-04 11:27:04 -06:00
parent 841492ea32
commit d6a90cc6ac
4 changed files with 55 additions and 64 deletions

View File

@@ -1426,6 +1426,14 @@ class Stack(collections.Mapping):
return self._convg_deps
def reset_stack_and_resources_in_progress(self, reason):
for name, rsrc in six.iteritems(self.resources):
if rsrc.status == rsrc.IN_PROGRESS:
rsrc.state_set(rsrc.action,
rsrc.FAILED,
six.text_type(reason))
self.state_set(self.action, self.FAILED, six.text_type(reason))
@scheduler.wrappertask
def update_task(self, newstack, action=UPDATE, msg_queue=None):
if action not in (self.UPDATE, self.ROLLBACK, self.RESTORE):
@@ -1445,8 +1453,9 @@ class Stack(collections.Mapping):
if action == self.ROLLBACK:
LOG.debug("Starting update rollback for %s" % self.name)
else:
self.state_set(action, self.FAILED,
'State invalid for %s' % action)
reason = _('Attempted to %s an IN_PROGRESS '
'stack') % action
self.reset_stack_and_resources_in_progress(reason)
return
# Save a copy of the new template. To avoid two DB writes