From 7a5383a70adce0a6284c9c10a0d352077aa9edea Mon Sep 17 00:00:00 2001 From: Rick Chen Date: Wed, 24 Sep 2014 17:08:52 +0800 Subject: [PATCH] Failed to re-detach volume when volume detached. When first request command detach the volume, but the back-end storage state is in-processing or busy. Next retry command will got the error code that describe the volume already detached. Change-Id: If340980ab2dcc844398254ff368ca6b78ca40ff6 Closes-Bug: 1373317 --- cinder/tests/test_prophetstor_dpl.py | 21 +++++++++++++++++++ .../volume/drivers/prophetstor/dpl_iscsi.py | 6 +++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/cinder/tests/test_prophetstor_dpl.py b/cinder/tests/test_prophetstor_dpl.py index 85d422f2c..8dc98d00c 100644 --- a/cinder/tests/test_prophetstor_dpl.py +++ b/cinder/tests/test_prophetstor_dpl.py @@ -12,10 +12,13 @@ # License for the specific language governing permissions and limitations # under the License. +import errno import httplib +import re import mock +from cinder import exception from cinder.openstack.common import units from cinder import test from cinder.volume import configuration as conf @@ -514,6 +517,24 @@ class TestProphetStorDPLDriver(test.TestCase): self._conver_uuid2hex(DATA_IN_VOLUME['id']), DATA_IN_CONNECTOR['initiator']) + def test_terminate_connection_volume_detached(self): + self.DPL_MOCK.unassign_vdev.return_value = errno.ENODATA, None + self.dpldriver.terminate_connection(DATA_IN_VOLUME, DATA_IN_CONNECTOR) + self.DPL_MOCK\ + .unassign_vdev\ + .assert_called_once_with( + self._conver_uuid2hex(DATA_IN_VOLUME['id']), + DATA_IN_CONNECTOR['initiator']) + + def test_terminate_connection_failed(self): + self.DPL_MOCK.unassign_vdev.return_value = errno.EFAULT, None + ex = self.assertRaises( + exception.VolumeBackendAPIException, + self.dpldriver.terminate_connection, + volume=DATA_IN_VOLUME, connector=DATA_IN_CONNECTOR) + self.assertTrue( + re.match(r".*Flexvisor failed", ex.msg)) + def test_get_pool_info(self): self.DPL_MOCK.get_pool.return_value = DATA_POOLINFO _, res = self.dpldriver._get_pool_info(POOLUUID) diff --git a/cinder/volume/drivers/prophetstor/dpl_iscsi.py b/cinder/volume/drivers/prophetstor/dpl_iscsi.py index 01e354f87..4b289be35 100644 --- a/cinder/volume/drivers/prophetstor/dpl_iscsi.py +++ b/cinder/volume/drivers/prophetstor/dpl_iscsi.py @@ -134,8 +134,12 @@ class DPLISCSIDriver(dplcommon.DPLCOMMONDriver, '%(id)s.') % {'id': volume['id']} LOG.error(msg) raise exception.VolumeBackendAPIException(data=msg) + elif ret == errno.ENODATA: + msg = _('Flexvisor already unassigned volume ' + '%(id)s.') % {'id': volume['id']} + LOG.info(msg) elif ret != 0: - msg = _('Flexvisor unassign volume failed:%(id)s:' + msg = _('Flexvisor failed to unassign volume:%(id)s:' '%(status)s.') % {'id': volume['id'], 'status': ret} LOG.error(msg) raise exception.VolumeBackendAPIException(data=msg) -- 2.45.2