Don't remove resources from the DB during HA restart

This was broken by 3b91d100a6. Resources
should be removed from the DB only when the stack is deleted.

Change-Id: I6822aee8453afd6076793cff9206a035cff33588
Signed-off-by: Zane Bitter <zbitter@redhat.com>
changes/05/205/1
Zane Bitter 10 years ago
parent 1530a29cfd
commit 6e6d0b4222
  1. 2
      heat/engine/parser.py
  2. 31
      heat/engine/resources.py

@ -241,7 +241,7 @@ class Stack(object):
failures = []
for res in reversed(self):
result = res.delete()
result = res.destroy()
if result:
failures.append(str(res))

@ -190,19 +190,26 @@ class Resource(object):
logger.exception('Delete %s', str(self))
self.state_set(self.DELETE_FAILED, str(ex))
return str(ex)
else:
try:
db_api.resource_get(self.stack.context, self.id).delete()
except exception.NotFound:
# Don't fail on delete if the db entry has
# not been created yet.
pass
except Exception as ex:
self.state_set(self.DELETE_FAILED)
logger.exception('Delete %s from DB' % str(self))
return str(ex)
self.state_set(self.DELETE_COMPLETE)
self.state_set(self.DELETE_COMPLETE)
def destroy(self):
'''
Delete the resource and remove it from the database.
'''
result = self.delete()
if result:
return result
try:
db_api.resource_get(self.stack.context, self.id).delete()
except exception.NotFound:
# Don't fail on delete if the db entry has
# not been created yet.
pass
except Exception as ex:
logger.exception('Delete %s from DB' % str(self))
return str(ex)
def instance_id_set(self, inst):
self.instance_id = inst

Loading…
Cancel
Save