From 6440379ca12f38745b31903ebb8755cddd269110 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Thu, 19 May 2016 09:51:19 -0400 Subject: [PATCH] NetApp: Log unexpected errors from backend When an exception other than an HTTP response occurs, such as a timeout, the NetApp driver does not log the original exception. Change-Id: I13d8366355eaa07d338a95e2765fbe9eae6ddd2d Closes-Bug: 1583615 --- .../unit/volume/drivers/netapp/dataontap/client/test_api.py | 3 ++- cinder/volume/drivers/netapp/dataontap/client/api.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py index 155e19195..aa59c83a9 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py @@ -214,7 +214,7 @@ class NetAppApiServerTests(test.TestCase): na_element = zapi_fakes.FAKE_NA_ELEMENT self.mock_object(self.root, '_create_request', mock.Mock( return_value=('abc', zapi_fakes.FAKE_NA_ELEMENT))) - self.mock_object(netapp_api, 'LOG') + mock_log = self.mock_object(netapp_api, 'LOG') self.root._opener = zapi_fakes.FAKE_HTTP_OPENER self.mock_object(self.root, '_build_opener') self.mock_object(self.root._opener, 'open', mock.Mock( @@ -222,6 +222,7 @@ class NetAppApiServerTests(test.TestCase): self.assertRaises(netapp_api.NaApiError, self.root.send_http_request, na_element) + self.assertEqual(1, mock_log.exception.call_count) def test_send_http_request_valid(self): """Tests the method send_http_request with valid parameters""" diff --git a/cinder/volume/drivers/netapp/dataontap/client/api.py b/cinder/volume/drivers/netapp/dataontap/client/api.py index f148149e9..cf775c846 100644 --- a/cinder/volume/drivers/netapp/dataontap/client/api.py +++ b/cinder/volume/drivers/netapp/dataontap/client/api.py @@ -32,7 +32,7 @@ import six from six.moves import urllib from cinder import exception -from cinder.i18n import _ +from cinder.i18n import _, _LE from cinder import ssh_utils from cinder import utils @@ -224,6 +224,7 @@ class NaServer(object): except urllib.error.HTTPError as e: raise NaApiError(e.code, e.msg) except Exception: + LOG.exception(_LE("Error communicating with NetApp filer.")) raise NaApiError('Unexpected error') response_xml = response.read()