]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Failed to re-detach volume when volume detached.
authorRick Chen <rick.chen@prophetstor.com>
Wed, 24 Sep 2014 09:08:52 +0000 (17:08 +0800)
committerRick Chen <rick.chen@prophetstor.com>
Thu, 25 Sep 2014 09:06:52 +0000 (17:06 +0800)
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
cinder/volume/drivers/prophetstor/dpl_iscsi.py

index 85d422f2cace265b539bc2b6d4b533f63bf98591..8dc98d00c873a6bcd7c39aa98816deda4532ee76 100644 (file)
 #    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)
index 01e354f87dff535e4dcfbd65a188d8ecc8056dfa..4b289be350d6dc5ae8ce930b4001797fe9e9ed67 100644 (file)
@@ -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)