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 (cherry picked from commit9e8c458922
) (cherry picked from commit71c99a85a0
) (cherry picked from commit3e174a0c4b
)
This commit is contained in:
parent
96fbdde2a0
commit
5e4d7e5e98
|
@ -66,6 +66,10 @@ class MockImageExistsException(MockException):
|
|||
"""Used as mock for rbd.ImageExists."""
|
||||
|
||||
|
||||
class MockOSErrorException(MockException):
|
||||
"""Used as mock for rbd.OSError."""
|
||||
|
||||
|
||||
def common_mocks(f):
|
||||
"""Decorator to set mocks common to all tests.
|
||||
|
||||
|
@ -1877,17 +1881,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()
|
||||
|
|
|
@ -388,7 +388,7 @@ class RBDDriver(driver.CloneableImageVD,
|
|||
try:
|
||||
with RBDVolumeProxy(self, t, read_only=True) 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
|
||||
|
|
Loading…
Reference in New Issue