Handle post-delete hooks correctly

This moves signal validation after hook handling, to be able to properly
get signals during DELETE actions.

Change-Id: I18e2284ab344f6c2e46e40744b771524b7bad9d9
Closes-Bug: #1690806
changes/70/465470/2
Thomas Herve 5 years ago
parent 30c87bae3d
commit 82fc15a540
  1. 3
      heat/engine/resource.py
  2. 8
      heat/tests/test_resource.py

@ -2273,11 +2273,12 @@ class Resource(status.ResourceStatus):
signal. The base-class raise an exception if no handler is implemented.
"""
if need_check:
self._signal_check_action()
self._signal_check_hook(details)
if details and 'unset_hook' in details:
self._unset_hook(details)
return False
if need_check:
self._signal_check_action()
self._handle_signal(details)
return self.signal_needs_metadata_updates

@ -3626,7 +3626,7 @@ class ResourceHookTest(common.HeatTestCase):
task.start()
task.step()
self.assertTrue(res.has_hook('pre-create'))
res.clear_hook('pre-create')
res.signal(details={'unset_hook': 'pre-create'})
task.run_to_completion()
self.assertEqual((res.CREATE, res.COMPLETE), res.state)
@ -3645,7 +3645,7 @@ class ResourceHookTest(common.HeatTestCase):
task.start()
task.step()
self.assertTrue(res.has_hook('pre-delete'))
res.clear_hook('pre-delete')
res.signal(details={'unset_hook': 'pre-delete'})
task.run_to_completion()
self.assertEqual((res.DELETE, res.COMPLETE), res.state)
@ -3662,7 +3662,7 @@ class ResourceHookTest(common.HeatTestCase):
task.start()
task.step()
self.assertTrue(res.has_hook('post-create'))
res.clear_hook('post-create')
res.signal(details={'unset_hook': 'post-create'})
task.run_to_completion()
self.assertEqual((res.CREATE, res.COMPLETE), res.state)
@ -3681,7 +3681,7 @@ class ResourceHookTest(common.HeatTestCase):
task.start()
task.step()
self.assertTrue(res.has_hook('post-delete'))
res.clear_hook('post-delete')
res.signal(details={'unset_hook': 'post-delete'})
task.run_to_completion()
self.assertEqual((res.DELETE, res.COMPLETE), res.state)

Loading…
Cancel
Save