diff --git a/glance_store/_drivers/rbd.py b/glance_store/_drivers/rbd.py index 0e3e4874..09dc9418 100644 --- a/glance_store/_drivers/rbd.py +++ b/glance_store/_drivers/rbd.py @@ -271,10 +271,16 @@ class Store(driver.Store): try: client.connect(timeout=self.connect_timeout) - except rados.Error: - msg = _LE("Error connecting to ceph cluster.") - LOG.exception(msg) - raise exceptions.BackendException() + except (rados.Error, rados.ObjectNotFound) as e: + if self.backend_group and len(self.conf.enabled_backends) > 1: + reason = _("Error in store configuration: %s") % e + LOG.debug(reason) + raise exceptions.BadStoreConfiguration( + store_name=self.backend_group, reason=reason) + else: + msg = _LE("Error connecting to ceph cluster.") + LOG.exception(msg) + raise exceptions.BackendException() try: yield client finally: diff --git a/glance_store/tests/unit/test_multistore_rbd.py b/glance_store/tests/unit/test_multistore_rbd.py index 4d4d74b2..39a55c57 100644 --- a/glance_store/tests/unit/test_multistore_rbd.py +++ b/glance_store/tests/unit/test_multistore_rbd.py @@ -35,6 +35,9 @@ class MockRados(object): class Error(Exception): pass + class ObjectNotFound(Exception): + pass + class ioctx(object): def __init__(self, *args, **kwargs): pass @@ -442,11 +445,12 @@ class TestMultiStore(base.MultiStoreBaseTest, @mock.patch.object(MockRados.Rados, 'connect', side_effect=MockRados.Error) def test_rados_connect_error(self, _): rbd_store.rados.Error = MockRados.Error + rbd_store.rados.ObjectNotFound = MockRados.ObjectNotFound def test(): with self.store.get_connection('conffile', 'rados_id'): pass - self.assertRaises(exceptions.BackendException, test) + self.assertRaises(exceptions.BadStoreConfiguration, test) def test_create_image_conf_features(self): # Tests that we use non-0 features from ceph.conf and cast to int. diff --git a/glance_store/tests/unit/test_rbd_store.py b/glance_store/tests/unit/test_rbd_store.py index 5af6bace..d7bd56ed 100644 --- a/glance_store/tests/unit/test_rbd_store.py +++ b/glance_store/tests/unit/test_rbd_store.py @@ -34,6 +34,9 @@ class MockRados(object): class Error(Exception): pass + class ObjectNotFound(Exception): + pass + class ioctx(object): def __init__(self, *args, **kwargs): pass @@ -450,6 +453,7 @@ class TestStore(base.StoreBaseTest, @mock.patch.object(MockRados.Rados, 'connect', side_effect=MockRados.Error) def test_rados_connect_error(self, _): rbd_store.rados.Error = MockRados.Error + rbd_store.rados.ObjectNotFound = MockRados.ObjectNotFound def test(): with self.store.get_connection('conffile', 'rados_id'):