From 5e580c7af4ddede8be3e24be10754b70728e18c8 Mon Sep 17 00:00:00 2001
From: Yuriy Nesenenko <ynesenenko@mirantis.com>
Date: Tue, 10 Mar 2015 12:27:51 +0200
Subject: [PATCH] Fix Cinder logs to show authentication error in RBD driver

The Cinder logs fail to report authentication error when working
with the RBD driver.

Change-Id: I3d190d6359c744efe0c6d0612bd0f2d2e6b0ab0d
Closes-Bug: #1389983
---
 cinder/volume/drivers/rbd.py | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/cinder/volume/drivers/rbd.py b/cinder/volume/drivers/rbd.py
index 55a626b74..8b3f93d83 100644
--- a/cinder/volume/drivers/rbd.py
+++ b/cinder/volume/drivers/rbd.py
@@ -280,13 +280,12 @@ class RBDDriver(driver.VolumeDriver):
         if rados is None:
             msg = _('rados and rbd python libraries not found')
             raise exception.VolumeBackendAPIException(data=msg)
-        try:
-            with RADOSClient(self):
-                pass
-        except self.rados.Error:
-            msg = _('error connecting to ceph cluster')
-            LOG.exception(msg)
-            raise exception.VolumeBackendAPIException(data=msg)
+
+        # NOTE: Checking connection to ceph
+        # RADOSClient __init__ method invokes _connect_to_rados
+        # so no need to check for self.rados.Error here.
+        with RADOSClient(self):
+            pass
 
     def _ceph_args(self):
         args = []
@@ -315,11 +314,12 @@ class RBDDriver(driver.VolumeDriver):
                 client.connect()
             ioctx = client.open_ioctx(pool)
             return client, ioctx
-        except self.rados.Error as exc:
-            LOG.error(_LE("error connecting to ceph cluster."))
+        except self.rados.Error:
+            msg = _("Error connecting to ceph cluster.")
+            LOG.exception(msg)
             # shutdown cannot raise an exception
             client.shutdown()
-            raise exception.VolumeBackendAPIException(data=str(exc))
+            raise exception.VolumeBackendAPIException(data=msg)
 
     def _disconnect_from_rados(self, client, ioctx):
         # closing an ioctx cannot raise an exception
-- 
2.45.2