Fix a DB error when updating the resource attributes

This prevents the attributes from being stored sometimes, and is possibly
correlated with occasional random failures of the gate jobs.

Change-Id: I8f6567ec792bd015d59ffc04da9f2f37f5b0f13a
Related-Bug: #1660831
This commit is contained in:
Zane Bitter 2017-06-13 19:38:21 -04:00
parent fda92763c9
commit 118fc127b3
1 changed files with 4 additions and 3 deletions

View File

@ -486,11 +486,12 @@ def engine_get_all_locked_by_stack(context, stack_id):
def resource_prop_data_create_or_update(context, values, rpd_id=None):
if rpd_id is None:
obj_ref = models.ResourcePropertiesData()
else:
obj_ref = None
if rpd_id is not None:
obj_ref = context.session.query(
models.ResourcePropertiesData).filter_by(id=rpd_id).first()
if obj_ref is None:
obj_ref = models.ResourcePropertiesData()
obj_ref.update(values)
obj_ref.save(context.session)
return obj_ref