Make sure the resource exists before trying to update it.
Change-Id: I5d8bdc0f4ceff61cab0b909dcaaf8ab5952ba4af Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
parent
f0b75758f6
commit
4a19ab5903
@ -137,11 +137,14 @@ class Resource(object):
|
||||
|
||||
except Exception as ex:
|
||||
logger.warn('db error %s' % str(ex))
|
||||
elif new_state is not self.CREATE_IN_PROGRESS:
|
||||
rs = db_api.resource_get(None, self.id)
|
||||
rs.update_and_save({'state': new_state})
|
||||
if rs.stack:
|
||||
rs.stack.update_and_save({'updated_at': datetime.utcnow()})
|
||||
elif self.id is not None:
|
||||
try:
|
||||
rs = db_api.resource_get(self.stack.context, self.id)
|
||||
rs.update_and_save({'state': new_state})
|
||||
if rs.stack:
|
||||
rs.stack.update_and_save({'updated_at': datetime.utcnow()})
|
||||
except Exception as ex:
|
||||
logger.warn('db error %s' % str(ex))
|
||||
|
||||
if new_state != self.state:
|
||||
ev = {}
|
||||
|
Loading…
Reference in New Issue
Block a user