]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Failed to initialize connection
authorRick Chen <rick.chen@prophetstor.com>
Sat, 16 Aug 2014 06:46:16 +0000 (14:46 +0800)
committerRick Chen <rick.chen@prophetstor.com>
Tue, 19 Aug 2014 16:22:36 +0000 (00:22 +0800)
Failed to initialize connection when the storage server heavy loading.
Changed related on:
  dpl_iscsi and dpl_fc
    initialize_connection
    terminate_connection

When storage server busy, the request api will receive httplib response
code accepted and the response body include event uuid. The operation
request use the event uuid to comfirm the job is completed or not.

Change-Id: I4ad8283d355d6b53390e69123ed7b3ed873d4c4e
Closes-Bug: 1357635

cinder/volume/drivers/prophetstor/dpl_fc.py
cinder/volume/drivers/prophetstor/dpl_iscsi.py
cinder/volume/drivers/prophetstor/dplcommon.py

index 8b040be3f9ce585e4823f2e32048b39bb67e5865..88e564ba6f41345eb2797f4b30f998abaae99112 100644 (file)
@@ -153,22 +153,27 @@ class DPLFCDriver(dplcommon.DPLCOMMONDriver,
             LOG.error(msg)
             ret = errno.EFAULT
 
-        if ret == 0:
-            ret, event_uuid = self._get_event_uuid(output)
-
         if ret == errno.EAGAIN:
-            status = self._wait_event(
-                self.dpl.get_vdev_status,
-                self._conver_uuid2hex(volumeid), event_uuid)
-            if status['state'] == 'error':
+            ret, event_uuid = self._get_event_uuid(output)
+            if len(event_uuid):
+                ret = 0
+                status = self._wait_event(
+                    self.dpl.get_vdev_status,
+                    self._conver_uuid2hex(volumeid), event_uuid)
+                if status['state'] == 'error':
+                    ret = errno.EFAULT
+                    msg = _('Flexvisor failed to assign volume %(id)s: '
+                            '%(status)s.') % {'id': volumeid,
+                                              'status': status}
+                    LOG.error(msg)
+                    raise exception.VolumeBackendAPIException(data=msg)
+            else:
                 ret = errno.EFAULT
-                msg = _('Flexvisor failed to assign volume %(id)s: '
-                        '%(status)s.') % {'id': volumeid,
-                                          'status': status}
+                msg = _('Flexvisor failed to assign volume %(id)s due to '
+                        'unable to query status by event '
+                        'id.') % {'id': volumeid}
                 LOG.error(msg)
                 raise exception.VolumeBackendAPIException(data=msg)
-            else:
-                ret = 0
         elif ret != 0:
             msg = _('Flexvisor assign volume failed:%(id)s:'
                     '%(status)s.') % {'id': volumeid, 'status': ret}
@@ -185,17 +190,16 @@ class DPLFCDriver(dplcommon.DPLCOMMONDriver,
             targetwwpns, initiatorwwpns)
         if ret == errno.EAGAIN:
             ret, event_uuid = self._get_event_uuid(output)
-            if ret == 0:
+            if ret == 0 and len(event_uuid):
                 status = self._wait_event(
                     self.dpl.get_vdev_status, volumeid, event_uuid)
                 if status['state'] == 'error':
+                    ret = errno.EFAULT
                     msg = _('Flexvisor failed to unassign volume %(id)s:'
                             ' %(status)s.') % {'id': volumeid,
                                                'status': status}
                     LOG.error(msg)
                     raise exception.VolumeBackendAPIException(data=msg)
-                else:
-                    ret = 0
             else:
                 msg = _('Flexvisor failed to unassign volume (get event) '
                         '%(id)s.') % {'id': volumeid}
index 0a5aefc5d561cc563c5a486d998a4a93cd8febce..01e354f87dff535e4dcfbd65a188d8ecc8056dfa 100644 (file)
@@ -44,18 +44,26 @@ class DPLISCSIDriver(dplcommon.DPLCOMMONDriver,
         ret, output = self.dpl.assign_vdev(self._conver_uuid2hex(
             volume['id']), connector['initiator'].lower(), volume['id'],
             '%s:%d' % (dpl_server, dpl_iscsi_port), 0)
-        if ret == 0:
-            ret, event_uuid = self._get_event_uuid(output)
 
         if ret == errno.EAGAIN:
-            status = self._wait_event(
-                self.dpl.get_vdev_status, self._conver_uuid2hex(
-                    volume['id']), event_uuid)
-            if status['state'] == 'error':
+            ret, event_uuid = self._get_event_uuid(output)
+            if len(event_uuid):
+                ret = 0
+                status = self._wait_event(
+                    self.dpl.get_vdev_status, self._conver_uuid2hex(
+                        volume['id']), event_uuid)
+                if status['state'] == 'error':
+                    ret = errno.EFAULT
+                    msg = _('Flexvisor failed to assign volume %(id)s: '
+                            '%(status)s.') % {'id': volume['id'],
+                                              'status': status}
+                    LOG.error(msg)
+                    raise exception.VolumeBackendAPIException(data=msg)
+            else:
                 ret = errno.EFAULT
-                msg = _('Flexvisor failed to assign volume %(id)s: '
-                        '%(status)s.') % {'id': volume['id'],
-                                          'status': status}
+                msg = _('Flexvisor failed to assign volume %(id)s due to '
+                        'unable to query status by event '
+                        'id.') % {'id': volume['id']}
                 LOG.error(msg)
                 raise exception.VolumeBackendAPIException(data=msg)
         elif ret != 0:
index 7a738c41b21909b05d49ff73f4d4afd68a182447..deaf0323e4f8b95f8e6aa29efe14a860d8db722a 100644 (file)
@@ -610,16 +610,19 @@ class DPLCOMMONDriver(driver.VolumeDriver):
             return None
 
     def _get_event_uuid(self, output):
+        ret = 0
         event_uuid = ""
-        if type(output) is not dict:
-            return -1, event_uuid
 
-        if output.get("metadata") and output["metadata"]:
+        if type(output) is dict and \
+                output.get("metadata") and output["metadata"]:
             if output["metadata"].get("event_uuid") and  \
                     output["metadata"]["event_uuid"]:
                 event_uuid = output["metadata"]["event_uuid"]
-                return 0, event_uuid
-        return -1, event_uuid
+            else:
+                ret = errno.EINVAL
+        else:
+            ret = errno.EINVAL
+        return ret, event_uuid
 
     def _wait_event(self, callFun, objuuid, eventid=None):
         nRetry = 30