Handle rbd.OSError on broken RBD image

With Rocky, cinder-volume began to fail again with another error type.
This patch adds rbd.OSError type for exception block of
_get_usage_info method.

Change-Id: I93b8afeddae18d098fe926a3219811cc8c8d9b63
Closes-Bug: 1698786
This commit is contained in:
Dmitriy Rabotjagov 2018-10-23 19:16:59 +03:00 committed by Dmitriy Rabotjagov (noonedeadpunk)
parent 7b84c0842b
commit 9e8c458922
2 changed files with 14 additions and 3 deletions

View File

@ -69,6 +69,10 @@ class MockImageExistsException(MockException):
"""Used as mock for rbd.ImageExists."""
class MockOSErrorException(MockException):
"""Used as mock for rbd.OSError."""
class KeyObject(object):
def get_encoded(arg):
return "asdf".encode('utf-8')
@ -2101,17 +2105,24 @@ class RBDTestCase(test.TestCase):
return mock.Mock(return_value=mock.Mock(
size=mock.Mock(side_effect=(size_or_exc,))))
volumes = ['volume-1', 'non-existent', 'non-cinder-volume']
volumes = [
'volume-1',
'non-existent',
'non-existent',
'non-cinder-volume'
]
client = client_mock.return_value.__enter__.return_value
rbdproxy_mock.return_value.list.return_value = volumes
with mock.patch.object(self.driver, 'rbd',
ImageNotFound=MockImageNotFoundException):
ImageNotFound=MockImageNotFoundException,
OSError=MockOSErrorException):
volproxy_mock.side_effect = [
mock.MagicMock(**{'__enter__': FakeVolProxy(s)})
for s in (1.0 * units.Gi,
self.driver.rbd.ImageNotFound,
self.driver.rbd.OSError,
2.0 * units.Gi)
]
total_provision = self.driver._get_usage_info()

View File

@ -410,7 +410,7 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD,
client=client.cluster,
ioctx=client.ioctx) as v:
size = v.size()
except self.rbd.ImageNotFound:
except (self.rbd.ImageNotFound, self.rbd.OSError):
LOG.debug("Image %s is not found.", t)
else:
total_provisioned += size