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] 1178f113c4
[2] c0c4969a4a/glance_store/common/cinder_utils.py (L37)

Change-Id: I39c9caec85f574fc717e60f11e5681860a20ed30
This commit is contained in:
whoami-rajat 2022-03-17 16:20:57 +05:30
parent c0c4969a4a
commit 8ec07902cb
1 changed files with 4 additions and 11 deletions

View File

@ -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