Avoid double-write when updating FAILED rsrc with no change
In convergence, when a resource is traversed and left unchanged, we must still update the current template for it in the database. In addition, if the resource was unchanged in the template but already in a FAILED state and we elected not to replace it by returning False from needs_replace_failed(), we must also update the status to COMPLETE. Currently, we do those in two separate writes. This is an unnecessary overhead (albeit for a fairly rare case), and the two writes can be combined into one in the case where both changes are required. Change-Id: I9e2f1e27ce2c119647c9fe228484228d2c15d943 Related-Bug: #1763021
This commit is contained in:
parent
0e81c9529a
commit
4fc271da8e
|
@ -1640,9 +1640,10 @@ class Resource(status.ResourceStatus):
|
|||
raise failure
|
||||
|
||||
if not needs_update:
|
||||
is_failed = self.status == self.FAILED
|
||||
if update_templ_func is not None:
|
||||
update_templ_func(persist=True)
|
||||
if self.status == self.FAILED:
|
||||
update_templ_func(persist=not is_failed)
|
||||
if is_failed:
|
||||
status_reason = _('Update status to COMPLETE for '
|
||||
'FAILED resource neither update '
|
||||
'nor replace.')
|
||||
|
|
Loading…
Reference in New Issue