From 0c2a82a8bfd7edcff5b9eea029a849548cc2a276 Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Thu, 6 Sep 2018 11:41:37 +0200 Subject: [PATCH] Improve error message on unavailable This patch improves the error message returned when a device is not available after attaching it. In some cases this could be related to missing tools on the host system, like the rbd-common package, for example. --- HISTORY.rst | 7 +++++++ cinderlib/objects.py | 16 ++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index ac0df1c..4bd300e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,13 @@ History ======= +0.2.3 (2018-MM-DD) +------------------ + +- Features: + + - Provide better message when device is not available. + 0.2.2 (2018-07-24) ------------------ diff --git a/cinderlib/objects.py b/cinderlib/objects.py index a9a6c3a..51ac530 100644 --- a/cinderlib/objects.py +++ b/cinderlib/objects.py @@ -715,16 +715,20 @@ class Connection(Object, LazyVolumeAttr): device = self.connector.connect_volume(self.conn_info['data']) self.device_attached(device) try: - unavailable = not self.connector.check_valid_device(self.path) + if self.connector.check_valid_device(self.path): + error_msg = None + else: + error_msg = ('Unable to access the backend storage via path ' + '%s.' % self.path) except Exception: - unavailable = True - LOG.exception('Could not validate device %s', self.path) + error_msg = ('Could not validate device %s. There may be missing ' + 'packages on your host.' % self.path) + LOG.exception(error_msg) - if unavailable: + if error_msg: raise cinder_exception.DeviceUnavailable( path=self.path, attach_info=self._ovo.connection_information, - reason=('Unable to access the backend storage via path ' - '%s.') % self.path) + reason=error_msg) if self._volume: self.volume.local_attach = self