From: Rick Chen Date: Sat, 16 Aug 2014 06:46:16 +0000 (+0800) Subject: Failed to initialize connection X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=d9561b151e9b82258d60f73a961be92ab797b954;p=openstack-build%2Fcinder-build.git Failed to initialize connection 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 --- diff --git a/cinder/volume/drivers/prophetstor/dpl_fc.py b/cinder/volume/drivers/prophetstor/dpl_fc.py index 8b040be3f..88e564ba6 100644 --- a/cinder/volume/drivers/prophetstor/dpl_fc.py +++ b/cinder/volume/drivers/prophetstor/dpl_fc.py @@ -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} diff --git a/cinder/volume/drivers/prophetstor/dpl_iscsi.py b/cinder/volume/drivers/prophetstor/dpl_iscsi.py index 0a5aefc5d..01e354f87 100644 --- a/cinder/volume/drivers/prophetstor/dpl_iscsi.py +++ b/cinder/volume/drivers/prophetstor/dpl_iscsi.py @@ -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: diff --git a/cinder/volume/drivers/prophetstor/dplcommon.py b/cinder/volume/drivers/prophetstor/dplcommon.py index 7a738c41b..deaf0323e 100644 --- a/cinder/volume/drivers/prophetstor/dplcommon.py +++ b/cinder/volume/drivers/prophetstor/dplcommon.py @@ -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