fixes stack deletion failure, when vol in deleting

when an delete operation is requested on a stack, and the volume in stack
is already in 'deleting' state, heat fails to delete the stack and goes to
DELETE_FAILED state instantly.

Instead of going to DELETE_FAILED state instantly, heat needs to safely
wait for the volume to complete its deletion process, so that heat can
then go ahead and complete stack deletion successfully.

Closes-Bug: #1362708

Change-Id: I088eab90bee4bc804abe9e505fd61b17b266def1
This commit is contained in:
Rakesh H S 2014-09-02 20:06:53 +05:30
parent a6a3e9e9de
commit 6aca29e05b
2 changed files with 31 additions and 2 deletions

View File

@ -160,8 +160,10 @@ class Volume(resource.Resource):
if vol.status == 'in-use':
raise exception.Error(_('Volume in use'))
vol.delete()
# if the volume is already in deleting status,
# just wait for the deletion to complete
if vol.status != 'deleting':
vol.delete()
while True:
yield
vol.get()

View File

@ -488,6 +488,33 @@ class VolumeTest(BaseVolumeTest):
self.m.VerifyAll()
def test_volume_deleting_delete(self):
fv = FakeVolume('creating', 'available')
stack_name = 'test_volume_deleting_stack'
self._mock_create_volume(fv, stack_name)
self.cinder_fc.volumes.get('vol-123').AndReturn(fv)
self.m.ReplayAll()
stack = utils.parse_stack(self.t, stack_name=stack_name)
rsrc = self.create_volume(self.t, stack, 'DataVolume')
self.assertEqual('available', fv.status)
# make sure that delete was not called
self.m.StubOutWithMock(fv, 'delete')
self.m.StubOutWithMock(fv, 'get')
fv.get().AndReturn(None)
fv.get().AndRaise(cinder_exp.NotFound('Not found'))
self.m.ReplayAll()
fv.status = 'deleting'
scheduler.TaskRunner(rsrc.destroy)()
self.m.VerifyAll()
def test_volume_update_not_supported(self):
stack_name = 'test_volume_stack'
fv = FakeVolume('creating', 'available')