diff options
author | Sushil Kumar <sushil.kumar2@globallogic.com> | 2014-04-23 11:18:31 +0000 |
---|---|---|
committer | Pavlo Shchelokovskyy <pshchelokovskyy@mirantis.com> | 2014-12-16 15:20:47 +0000 |
commit | 0b984b8c13338cf2ec3836e21e71c3c955a148b4 (patch) | |
tree | 7c3417bddd4b2544ebd08be172d8059adab8443e | |
parent | 931de32f213009ab7e798bd108d5bc61b533a259 (diff) | |
download | heat-0b984b8c13338cf2ec3836e21e71c3c955a148b4.tar.gz |
Call server volume detach only once
Changes:
- Removed duplicate delete calls to prevent race condition.
- Removed duplicate mocked calls from unit-test.
Closes-Bug: #1311533
Closes-Bug: #1298350
Conflicts:
heat/engine/resources/volume.py
heat/tests/test_volume.py
Change-Id: I5f16c528652f12440160f03b92f41b76d1c9100c
(cherry picked from commit d1ffbd4bfde0cd6b7a82a48b9d4f59cc8b310bd8)
-rw-r--r-- | heat/engine/resources/volume.py | 7 | ||||
-rw-r--r-- | heat/tests/test_volume.py | 17 |
2 files changed, 1 insertions, 23 deletions
diff --git a/heat/engine/resources/volume.py b/heat/engine/resources/volume.py index af76aae25..493759283 100644 --- a/heat/engine/resources/volume.py +++ b/heat/engine/resources/volume.py @@ -280,17 +280,10 @@ class VolumeDetachTask(object): yield try: - vol.get() while vol.status in ('in-use', 'detaching'): logger.debug(_('%s - volume still in use') % str(self)) yield - try: - server_api.delete_server_volume(self.server_id, - self.attachment_id) - except (clients.novaclient.exceptions.BadRequest, - clients.novaclient.exceptions.NotFound): - pass vol.get() logger.info(_('%(name)s - status: %(status)s') % { diff --git a/heat/tests/test_volume.py b/heat/tests/test_volume.py index 5d8cda797..c62697e13 100644 --- a/heat/tests/test_volume.py +++ b/heat/tests/test_volume.py @@ -332,10 +332,7 @@ class VolumeTest(HeatTestCase): self._mock_create_server_volume_script(fva) # delete script - fva = FakeVolume('i-use', 'available') - self.m.StubOutWithMock(fva, 'get') - fva.get().MultipleTimes() - fva.status = "in-use" + fva = FakeVolume('in-use', 'available') self.fc.volumes.get_server_volume(u'WikiDatabase', 'vol-123').AndReturn(fva) @@ -345,18 +342,6 @@ class VolumeTest(HeatTestCase): 'WikiDatabase', 'vol-123').AndRaise( clients.novaclient.exceptions.BadRequest('Already detached')) - self.fc.volumes.delete_server_volume( - 'WikiDatabase', 'vol-123').AndRaise( - clients.novaclient.exceptions.NotFound('Not found')) - - self.fc.volumes.delete_server_volume( - 'WikiDatabase', 'vol-123').AndRaise( - clients.novaclient.exceptions.NotFound('Not found')) - - self.fc.volumes.delete_server_volume( - 'WikiDatabase', 'vol-123').AndRaise( - clients.cinderclient.exceptions.NotFound('Not found')) - self.fc.volumes.get_server_volume(u'WikiDatabase', 'vol-123').AndReturn(fva) self.fc.volumes.get_server_volume( |