Skip to content

Commit

Permalink
Catch additional connect fail cases.
Browse files Browse the repository at this point in the history
When fixing bug/1195910, some other failure
cases weren't considered (ie not authorized,
unreachable dest etc).

We should fix this up to handle the various
connection error states accordingly and also
add some hints to the log output to help
determine where to look in case of failure.

Fixes bug: 1201592

Change-Id: Ib099c7af705e7c49be4d0f723c8a20262c942e7f
(cherry picked from commit 5edbc4e)
  • Loading branch information
j-griffith committed Jul 16, 2013
1 parent 82c6ffe commit 559b0fa
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions cinder/volume/drivers/solidfire.py
Expand Up @@ -79,9 +79,7 @@ def __init__(self, *args, **kwargs):
self.configuration.append_config_values(sf_opts)
try:
self._update_cluster_status()
except Exception as ex:
LOG.error(_("Update SolidFire Cluster stats failed: %s"),
ex.strerror)
except exception.SolidFireAPIException:
pass

def _issue_api_request(self, method_name, params):
Expand Down Expand Up @@ -130,13 +128,28 @@ def _issue_api_request(self, method_name, params):
LOG.debug(_("Payload for SolidFire API call: %s"), payload)

connection = httplib.HTTPSConnection(host, port)
connection.request('POST', '/json-rpc/1.0', payload, header)
try:
connection.request('POST', '/json-rpc/1.0', payload, header)
except Exception as ex:
LOG.error(_('Failed to make httplib connection '
'SolidFire Cluster: %s (verify san_ip '
'settings)') % ex.message)
msg = _("Failed to make httplib connection: %s") % ex.message
raise exception.SolidFireAPIException(msg)
response = connection.getresponse()

data = {}
if response.status != 200:
connection.close()
raise exception.SolidFireAPIException(status=response.status)
LOG.error(_('Request to SolidFire cluster returned '
'bad status: %(status)s / %(reason)s (check '
'san_login/san_password settings)') %
{'status': response.status,
'reason': response.reason})
msg = (_("HTTP request failed, with status: %(status)s "
"and reason: %(reason)s") %
{'status': response.status, 'reason': response.reason})
raise exception.SolidFireAPIException(msg)

else:
data = response.read()
Expand Down Expand Up @@ -234,7 +247,8 @@ def _get_cluster_info(self):
params = {}
data = self._issue_api_request('GetClusterInfo', params)
if 'result' not in data:
raise exception.SolidFireAPIDataException(data=data)
msg = _("API response: %s") % data
raise exception.SolidFireAPIException(msg)

return data['result']

Expand Down Expand Up @@ -318,7 +332,8 @@ def _do_clone_volume(self, src_uuid, src_project_id, v_ref):
data = self._issue_api_request('CloneVolume', params)

if (('result' not in data) or ('volumeID' not in data['result'])):
raise exception.SolidFireAPIDataException(data=data)
msg = _("API response: %s") % data
raise exception.SolidFireAPIException(msg)
sf_volume_id = data['result']['volumeID']

if (self.configuration.sf_allow_tenant_qos and
Expand Down Expand Up @@ -348,7 +363,7 @@ def _do_clone_volume(self, src_uuid, src_project_id, v_ref):
model_update = self._get_model_info(sfaccount, sf_volume_id)
if model_update is None:
mesg = _('Failed to get model update from clone')
raise exception.SolidFireAPIDataException(mesg)
raise exception.SolidFireAPIException(mesg)

return (data, sfaccount, model_update)

Expand All @@ -359,7 +374,8 @@ def _do_volume_create(self, project_id, params):
data = self._issue_api_request('CreateVolume', params)

if (('result' not in data) or ('volumeID' not in data['result'])):
raise exception.SolidFireAPIDataException(data=data)
msg = _("Failed volume create: %s") % data
raise exception.SolidFireAPIException(msg)

sf_volume_id = data['result']['volumeID']
return self._get_model_info(sfaccount, sf_volume_id)
Expand Down Expand Up @@ -398,7 +414,8 @@ def _set_qos_by_volume_type(self, ctxt, type_id):
def _get_sf_volume(self, uuid, params):
data = self._issue_api_request('ListVolumesForAccount', params)
if 'result' not in data:
raise exception.SolidFireAPIDataException(data=data)
msg = _("Failed to get SolidFire Volume: %s") % data
raise exception.SolidFireAPIException(msg)

found_count = 0
sf_volref = None
Expand Down Expand Up @@ -504,7 +521,8 @@ def delete_volume(self, volume):
data = self._issue_api_request('DeleteVolume', params)

if 'result' not in data:
raise exception.SolidFireAPIDataException(data=data)
msg = _("Failed to delete SolidFire Volume: %s") % data
raise exception.SolidFireAPIException(msg)
else:
LOG.error(_("Volume ID %s was not found on "
"the SolidFire Cluster!"), volume['id'])
Expand Down Expand Up @@ -562,9 +580,7 @@ def get_volume_stats(self, refresh=False):
if refresh:
try:
self._update_cluster_status()
except Exception as ex:
LOG.error(_("Update SolidFire Cluster stats failed: %s"),
ex.strerror)
except exception.SolidFireAPIException:
pass

return self.cluster_stats
Expand Down

0 comments on commit 559b0fa

Please sign in to comment.