From d45adaf08cce818f5c082fab467bd730052abaa1 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Mon, 12 Oct 2015 16:07:55 -0500 Subject: [PATCH] Only use LOG.exception in exception handler There were a few instances of the code calling LOG.exception in places where there was not an exception in context. This can cause errors and should just be LOG.error as it effectively ends up being. Some instances in vhdutils.py are being left as they are being addressed in Ib3113f2c4752d37e890f97d259da5d51cbfcfb96 under a different bug report. Change-Id: I1898c4d63c16c4d41b3e255a7de21429d1b04ddb Closes-bug: #1504735 --- cinder/volume/driver.py | 8 ++++---- cinder/volume/drivers/lvm.py | 2 +- cinder/volume/flows/manager/create_volume.py | 4 ++-- cinder/volume/manager.py | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index 2eba2cca301..f409c5b45ac 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -427,8 +427,8 @@ class BaseVD(object): # flag in the interface is for anticipation that it will be enabled # in the future. if remote: - LOG.exception(_LE("Detaching snapshot from a remote node " - "is not supported.")) + LOG.error(_LE("Detaching snapshot from a remote node " + "is not supported.")) raise exception.NotSupportedOperation( operation=_("detach snapshot from remote node")) else: @@ -995,8 +995,8 @@ class BaseVD(object): # flag in the interface is for anticipation that it will be enabled # in the future. if remote: - LOG.exception(_LE("Attaching snapshot from a remote node " - "is not supported.")) + LOG.error(_LE("Attaching snapshot from a remote node " + "is not supported.")) raise exception.NotSupportedOperation( operation=_("attach snapshot from remote node")) else: diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index 363ec3c3b9b..2c163788f64 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -697,7 +697,7 @@ class LVMVolumeDriver(driver.VolumeDriver): "check your configuration because source and " "destination are the same Volume Group: %(name)s.") % {'id': volume['id'], 'name': self.vg.vg_name}) - LOG.exception(message) + LOG.error(message) raise exception.VolumeBackendAPIException(data=message) def get_pool(self, volume): diff --git a/cinder/volume/flows/manager/create_volume.py b/cinder/volume/flows/manager/create_volume.py index 4fdc354285d..e7e69ef29d4 100644 --- a/cinder/volume/flows/manager/create_volume.py +++ b/cinder/volume/flows/manager/create_volume.py @@ -806,8 +806,8 @@ class CreateVolumeFromSpecTask(flow_utils.CinderTask): # we can't do anything if the driver didn't init if not self.driver.initialized: driver_name = self.driver.__class__.__name__ - LOG.exception(_LE("Unable to create volume. " - "Volume driver %s not initialized"), driver_name) + LOG.error(_LE("Unable to create volume. " + "Volume driver %s not initialized"), driver_name) raise exception.DriverNotInitialized() create_type = volume_spec.pop('type', None) diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 660fef3f5f1..75369c8f713 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -2626,9 +2626,9 @@ class VolumeManager(manager.SchedulerDependentManager): if model_update: if model_update['status'] in ['error_deleting', 'error']: msg = (_('Delete consistency group failed.')) - LOG.exception(msg, - resource={'type': 'consistency_group', - 'id': group.id}) + LOG.error(msg, + resource={'type': 'consistency_group', + 'id': group.id}) raise exception.VolumeDriverException(message=msg) else: group.update(model_update) @@ -2779,7 +2779,7 @@ class VolumeManager(manager.SchedulerDependentManager): if model_update['status'] in ['error']: msg = (_('Error occurred when updating consistency group ' '%s.') % group.id) - LOG.exception(msg) + LOG.error(msg) raise exception.VolumeDriverException(message=msg) group.update(model_update) group.save()