diff --git a/cinder/tests/unit/volume/drivers/test_rbd.py b/cinder/tests/unit/volume/drivers/test_rbd.py index 5aa644eea3f..fdab2d1370e 100644 --- a/cinder/tests/unit/volume/drivers/test_rbd.py +++ b/cinder/tests/unit/volume/drivers/test_rbd.py @@ -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() diff --git a/cinder/volume/drivers/rbd.py b/cinder/volume/drivers/rbd.py index 4278d025764..2b66d5a3204 100644 --- a/cinder/volume/drivers/rbd.py +++ b/cinder/volume/drivers/rbd.py @@ -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