diff options
author | Zane Bitter <zbitter@redhat.com> | 2017-07-21 21:32:45 -0400 |
---|---|---|
committer | Zane Bitter <zbitter@redhat.com> | 2018-04-25 16:32:02 -0400 |
commit | e649574d4751ffd8578f63787621c3a26d383a34 (patch) | |
tree | adade36e7371158371048ab8a2fbadaa26a626e5 /heat/tests/test_resource.py | |
parent | 4fc271da8e056e15d695a5331a1a1b091b6407c4 (diff) | |
download | heat-e649574d4751ffd8578f63787621c3a26d383a34.tar.gz |
Merge before/after 'requires' list on update failure
If an update of a resource fails, its 'requires' should be set to a union
of the previous and new requires lists. This is because if the resource
depends on a resource that has been replaced in this stack update, we can't
know if the current resource now depends on the new or old version of the
replaced resource if the current resource failed.
This is achieved by splitting up the setting of 'requires' and
'current_template_id', and changing them directly in the update() method
instead of via a callback.
When the resource state is changed to UPDATE_IN_PROGRESS, the new
requirements are added to the old ones. When the state is changed to
UPDATE_COMPLETE, the new requirements replace the old ones altogether. If
the update fails or handle_update() raises UpdateReplace, the union of the
requirements is kept. If _needs_update() raises UpdateReplace, the old
requirements are kept.
The current_template_id is updated when the state is changed to either
UPDATE_COMPLETE or UPDATE_FAILED, or when no update is required
(_needs_update() returns False).
This also saves an extra database write when the update fails.
Change-Id: If70d457fba5c64611173e3f9a0ae6b155ec69e06
Closes-Bug: #1663388
Diffstat (limited to 'heat/tests/test_resource.py')
-rw-r--r-- | heat/tests/test_resource.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/heat/tests/test_resource.py b/heat/tests/test_resource.py index abbc1693d..317f8c94d 100644 --- a/heat/tests/test_resource.py +++ b/heat/tests/test_resource.py @@ -2365,10 +2365,10 @@ class ResourceTest(common.HeatTestCase): self.assertEqual(new_temp.id, res.current_template_id) # check if requires was updated - self.assertItemsEqual([3, 4], res.requires) + self.assertItemsEqual([2, 3, 4], res.requires) self.assertEqual(res.action, resource.Resource.UPDATE) self.assertEqual(res.status, resource.Resource.FAILED) - self._assert_resource_lock(res.id, None, 3) + self._assert_resource_lock(res.id, None, 2) def test_update_resource_convergence_update_replace(self): tmpl = template.Template({ |