summaryrefslogtreecommitdiff
path: root/glance_store/common
diff options
context:
space:
mode:
authorRajat Dhasmana <rajatdhasmana@gmail.com>2022-12-28 14:30:18 +0530
committerwhoami-rajat <rajatdhasmana@gmail.com>2023-01-18 15:46:49 +0530
commita7edc87b0e97d537c1b26ca521e18605a352cdfa (patch)
tree92d9f04d1ff728008b3d528a74695a5941593d73 /glance_store/common
parentd0733a0f4f0c803ca0333605a21552dba1da931e (diff)
downloadglance_store-a7edc87b0e97d537c1b26ca521e18605a352cdfa.tar.gz
Cinder: Add support to extend attached volumes
While creating an image, if we want to extend the volume (to accomodate the image), we need to first detach the volume, perform the extend and attach it again. This is inefficient for backends that support extending attached volumes since we are performing 3 cinder operations (the attachment call includes 3 API calls which sum to a total of 5 API calls for 3 operations) instead of directly extending it which requires only 1 API call to cinder. The support for extending attached volumes was added in cinder microversion 3.42. This patch adds a new boolean config option ``cinder_do_extend_attached`` which allows operators to specify if the cinder backend they are using supports extending attached (in-use) volumes. By default this will be ``false``. Based on the parameter, we will perform the extend operation, online (if cinder_do_extend_attached is true) and offline otherwise. Spec: https://review.opendev.org/c/openstack/glance-specs/+/868901 Depends-On: https://review.opendev.org/c/openstack/glance/+/869021 Depends-On: https://review.opendev.org/c/openstack/cinder/+/869051 Change-Id: I5e70824e9abc5277ea25ba95704b358fe3686037
Diffstat (limited to 'glance_store/common')
-rw-r--r--glance_store/common/cinder_utils.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/glance_store/common/cinder_utils.py b/glance_store/common/cinder_utils.py
index b14aa23..c1c4186 100644
--- a/glance_store/common/cinder_utils.py
+++ b/glance_store/common/cinder_utils.py
@@ -208,3 +208,21 @@ class API(object):
{'id': attachment_id,
'msg': str(ex),
'code': getattr(ex, 'code', None)})
+
+ @handle_exceptions
+ def extend_volume(self, client, volume, new_size):
+ """Extend volume
+
+ :param client: cinderclient object
+ :param volume: UUID of the volume to extend
+ :param new_size: new size of the volume after extend
+ """
+ try:
+ client.volumes.extend(volume, new_size)
+ except cinder_exception.ClientException as ex:
+ with excutils.save_and_reraise_exception():
+ LOG.error(_LE('Extend volume failed for volume '
+ '%(id)s. Error: %(msg)s Code: %(code)s'),
+ {'id': volume.id,
+ 'msg': str(ex),
+ 'code': getattr(ex, 'code', None)})