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>
This commit is contained in:
parent
1530a29cfd
commit
6e6d0b4222
|
@ -241,7 +241,7 @@ class Stack(object):
|
||||||
failures = []
|
failures = []
|
||||||
|
|
||||||
for res in reversed(self):
|
for res in reversed(self):
|
||||||
result = res.delete()
|
result = res.destroy()
|
||||||
if result:
|
if result:
|
||||||
failures.append(str(res))
|
failures.append(str(res))
|
||||||
|
|
||||||
|
|
|
@ -190,19 +190,26 @@ class Resource(object):
|
||||||
logger.exception('Delete %s', str(self))
|
logger.exception('Delete %s', str(self))
|
||||||
self.state_set(self.DELETE_FAILED, str(ex))
|
self.state_set(self.DELETE_FAILED, str(ex))
|
||||||
return 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):
|
def instance_id_set(self, inst):
|
||||||
self.instance_id = inst
|
self.instance_id = inst
|
||||||
|
|
Loading…
Reference in New Issue