Merge pull request #10 from Akrog/attach_unavailable

Improve cases of volume being unavailable
This commit is contained in:
Gorka Eguileor 2018-09-06 12:44:21 +02:00 committed by GitHub
commit dc8b749157
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 6 deletions

View File

@ -2,6 +2,17 @@
History
=======
0.2.3 (2018-MM-DD)
------------------
- Bug fixes:
- Detach a volume when it's unavailable.
- Features:
- Provide better message when device is not available.
0.2.2 (2018-07-24)
------------------

View File

@ -715,16 +715,21 @@ 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:
self.detach(force=True, ignore_errors=True)
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