From 651f41a95a1703c5717fc47b8d9847d4da98c7de Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sun, 5 Nov 2023 14:25:42 +0900 Subject: [PATCH] cinder: Catch missing dependencies Cinder store requires a few additional dependencies. - cinderclient - os.brick - oslo.provsep Currently the driver handles missing cinderclient, but it does not properly treat in case one of the other two libraries is unavailable. Note that oslo.rootwrap is also part of the additional dependencies but this library is not directly imported. So we do not implement check at store initialization. Closes-Bug: #2043583 Change-Id: I4ea0a9749fdd821f3f958f77a2923b0fafefa471 --- glance_store/_drivers/cinder/store.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/glance_store/_drivers/cinder/store.py b/glance_store/_drivers/cinder/store.py index bfcadc60..ad0f1b16 100644 --- a/glance_store/_drivers/cinder/store.py +++ b/glance_store/_drivers/cinder/store.py @@ -50,8 +50,10 @@ try: from os_brick.initiator import connector from oslo_privsep import priv_context except ImportError: + api_versions = None cinder_exception = None cinderclient = None + os_brick = None connector = None priv_context = None @@ -495,7 +497,8 @@ class Store(glance_store.driver.Store): else: self.store_conf = self.conf.glance_store self.volume_api = cinder_utils.API() - getattr(os_brick, 'setup', lambda x: None)(CONF) + if os_brick: + os_brick.setup(CONF) # The purpose of this map is to store the connector object for a # particular volume as we will need to call os-brick extend_volume # method for the kernel to realize the new size change after cinder @@ -514,11 +517,14 @@ class Store(glance_store.driver.Store): Check to verify if the volume types configured for the cinder store exist in deployment and if not, log a warning. """ - if cinderclient is None: - reason = _("cinderclient is not available.") - LOG.error(reason) - raise exceptions.BadStoreConfiguration(store_name="cinder", - reason=reason) + for module_name, module in [('cinderclient', cinderclient), + ('os-brick', os_brick), + ('oslo-privsep', priv_context)]: + if module is None: + reason = _("%s is not available." % module_name) + LOG.error(reason) + raise exceptions.BadStoreConfiguration(store_name="cinder", + reason=reason) cinder_volume_type = self.store_conf.cinder_volume_type if cinder_volume_type: