Catch NotFound for every stack delete db operation

A stack delete can be interrupted by another delete request
at any stage, so a stack may be in any state of partial deletion.

This change ensures that every db operation in a stack delete
will catch NotFound exceptions so that the delete process can
continue.

Change-Id: I3b665acbc7979147f24793a314da37150d4efeb8
Partial-Bug: 1328983
This commit is contained in:
Steve Baker 2014-07-02 12:51:25 +12:00
parent b160972b08
commit 657b339967
1 changed files with 17 additions and 4 deletions

View File

@ -785,8 +785,13 @@ class Stack(collections.Mapping):
LOG.info(_("Tried to delete user_creds that do not exist "
"(stack=%(stack)s user_creds_id=%(uc)s)") %
{'stack': self.id, 'uc': self.user_creds_id})
self.user_creds_id = None
self.store()
try:
self.user_creds_id = None
self.store()
except exception.NotFound:
LOG.info(_("Tried to store a stack that does not exist "
"%s ") % self.id)
# If the stack has a domain project, delete it
if self.stack_user_project_id:
@ -798,11 +803,19 @@ class Stack(collections.Mapping):
stack_status = self.FAILED
reason = "Error deleting project: %s" % six.text_type(ex)
self.state_set(action, stack_status, reason)
try:
self.state_set(action, stack_status, reason)
except exception.NotFound:
LOG.info(_("Tried to delete stack that does not exist "
"%s ") % self.id)
if stack_status != self.FAILED:
# delete the stack
db_api.stack_delete(self.context, self.id)
try:
db_api.stack_delete(self.context, self.id)
except exception.NotFound:
LOG.info(_("Tried to delete stack that does not exist "
"%s ") % self.id)
self.id = None
def suspend(self):