summaryrefslogtreecommitdiff
path: root/glance_store/_drivers
diff options
context:
space:
mode:
authorRajat Dhasmana <rajatdhasmana@gmail.com>2021-06-15 21:09:20 -0400
committerRajat Dhasmana <rajatdhasmana@gmail.com>2021-07-28 11:14:46 -0400
commit85c7a06687291eba30510d63d3ee8b9e9cb33c5f (patch)
treed21f453e0e0c178111db10fbd4d1f66ff9940fa1 /glance_store/_drivers
parent82d87230491eda4bbef63b0b1acce1ebaf5a6e72 (diff)
downloadglance_store-85c7a06687291eba30510d63d3ee8b9e9cb33c5f.tar.gz
Glance cinder nfs: Block creating qcow2 volumes
There's an issue when cinder nfs is configured as glance backend and the image is > 1GB i.e. extend operation is performed on volume. Currently glance writes the qcow2 header in the raw volume and cinder nfs driver used to work on format autodetection which is changed to manual detection here[1] This fixes the extend volume problem for raw volumes, however, if cinder nfs is configured to create qcow2 volumes then we will run into the same problem. This patch blocks creating images when the nfs volume is qcow2. Refactoring work: 1) attachment_delete call is removed in nfs related code as it was already done in the finally block 2) handle_exceptions decorator is removed from volume delete method as it raises BackendException and incase when volume is not found (possibly deleted manually), the image deletion fails so we don't want to raise any error in this case [1] https://review.opendev.org/c/openstack/cinder/+/761152 Closes-Bug: #1901138 Change-Id: I8ce6f36f1cb4b0ed6bcc5f3869fab3bb64fe3390
Diffstat (limited to 'glance_store/_drivers')
-rw-r--r--glance_store/_drivers/cinder.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/glance_store/_drivers/cinder.py b/glance_store/_drivers/cinder.py
index 0256ab1..d62feb3 100644
--- a/glance_store/_drivers/cinder.py
+++ b/glance_store/_drivers/cinder.py
@@ -713,12 +713,20 @@ class Store(glance_store.driver.Store):
connection_info['driver_volume_type'], root_helper,
conn=connection_info, use_multipath=use_multipath)
if connection_info['driver_volume_type'] == 'nfs':
- if volume.encrypted:
- self.volume_api.attachment_delete(client, attachment.id)
- msg = (_('Encrypted volume creation for cinder nfs is not '
- 'supported from glance_store. Failed to create '
- 'volume %(volume_id)s')
- % {'volume_id': volume_id})
+ # The format info of nfs volumes is exposed via attachment_get
+ # API hence it is not available in the connection info of
+ # attachment object received from attachment_update and we
+ # need to do this call
+ vol_attachment = self.volume_api.attachment_get(
+ client, attachment.id)
+ if (volume.encrypted or
+ vol_attachment.connection_info['format'] == 'qcow2'):
+ issue_type = 'Encrypted' if volume.encrypted else 'qcow2'
+ msg = (_('%(issue_type)s volume creation for cinder nfs '
+ 'is not supported from glance_store. Failed to '
+ 'create volume %(volume_id)s')
+ % {'issue_type': issue_type,
+ 'volume_id': volume_id})
LOG.error(msg)
raise exceptions.BackendException(msg)