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.
This commit is contained in:
Gorka Eguileor 2018-09-06 11:41:37 +02:00
parent de1ee38d4d
commit 0c2a82a8bf
2 changed files with 17 additions and 6 deletions

View File

@ -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)
------------------

View File

@ -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