From 8ec07902cb0c3cd6c61850fa0a7ab46393182a12 Mon Sep 17 00:00:00 2001 From: whoami-rajat Date: Thu, 17 Mar 2022 16:20:57 +0530 Subject: [PATCH] Remove redundant try except around volume create The cinder volume create call was moved to the cinder_utils module to keep the driver code cleaner with commit[1]. A decorator was also added to handle NotFound exception which made the existing try/except block redundant. Also the current try/except block has misleading messages: 1) "Invalid volume type configured" 2) "Failed to create image-volume due to invalid `cinder_volume_type` configured." A volume create could fail because of many reasons and "invalid volume type" is just one of them. These messages will confuse the operators even if the configured volume type is correct. This patch removes them since the NotFound exception is already handled at[2] and the messages are misleading. [1] 1178f113c4fc3f5f0938f3dcc608cea4a73adb7f [2] https://github.com/openstack/glance_store/blob/c0c4969a4a6ce77c61f84fcb37b3efdac71d6418/glance_store/common/cinder_utils.py#L37 Change-Id: I39c9caec85f574fc717e60f11e5681860a20ed30 --- glance_store/_drivers/cinder.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/glance_store/_drivers/cinder.py b/glance_store/_drivers/cinder.py index 8a815439..1fe06b41 100644 --- a/glance_store/_drivers/cinder.py +++ b/glance_store/_drivers/cinder.py @@ -962,17 +962,10 @@ class Store(glance_store.driver.Store): LOG.info(_LI("Since image size is zero, we will be doing " "resize-before-write for each GB which " "will be considerably slower than normal.")) - try: - volume = self.volume_api.create(client, size_gb, name=name, - metadata=metadata, - volume_type=volume_type) - except cinder_exception.NotFound: - LOG.error(_LE("Invalid volume type %s configured. Please check " - "the `cinder_volume_type` configuration parameter." - % volume_type)) - msg = (_("Failed to create image-volume due to invalid " - "`cinder_volume_type` configured.")) - raise exceptions.BackendException(msg) + + volume = self.volume_api.create(client, size_gb, name=name, + metadata=metadata, + volume_type=volume_type) volume = self._wait_volume_status(volume, 'creating', 'available') size_gb = volume.size