Merge "Do not attempt deletion of a DELETE_COMPLETE stack in service api"

This commit is contained in:
Jenkins 2016-09-22 12:50:35 +00:00 committed by Gerrit Code Review
commit 9cf9981167
2 changed files with 15 additions and 0 deletions

View File

@ -1358,6 +1358,10 @@ class EngineService(service.Service):
"""
st = self._get_stack(cnxt, stack_identity)
if (st.status == parser.Stack.COMPLETE and
st.action == parser.Stack.DELETE):
raise exception.EntityNotFound(entity='Stack', name=st.name)
LOG.info(_LI('Deleting stack %s'), st.name)
stack = parser.Stack.load(cnxt, stack=st)
self.resource_enforcer.enforce_stack(stack)

View File

@ -975,6 +975,17 @@ class StackServiceTest(common.HeatTestCase):
outputs = self.eng.list_outputs(self.ctx, mock.ANY)
self.assertEqual([], outputs)
def test_stack_delete_complete_is_not_found(self):
mock_get_stack = self.patchobject(self.eng, '_get_stack')
mock_get_stack.return_value = mock.MagicMock()
mock_get_stack.return_value.status = parser.Stack.COMPLETE
mock_get_stack.return_value.action = parser.Stack.DELETE
ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.delete_stack,
'irrelevant',
'irrelevant')
self.assertEqual(exception.EntityNotFound, ex.exc_info[0])
def test_get_environment(self):
# Setup
t = template_format.parse(tools.wp_template)