Add the "really detach" patch, update the attach/detach one.
Change-Id: I8de05d4d40f7d7f9ee2249b07b421bc031a162a3
diff --git a/patches/openstack/cinder/leave-it-to-brick.patch b/patches/openstack/cinder/leave-it-to-brick.patch
index 52fc120..c5603a5 100644
--- a/patches/openstack/cinder/leave-it-to-brick.patch
+++ b/patches/openstack/cinder/leave-it-to-brick.patch
@@ -1,7 +1,7 @@
-From d38aa0fff72db40f4501bfac661313c5aeda51f3 Mon Sep 17 00:00:00 2001
+From b0710f215a9bea69bfdb35d0485c38cd8a87204e Mon Sep 17 00:00:00 2001
From: Peter Penchev <openstack-dev@storpool.com>
Date: Tue, 20 Apr 2021 17:46:41 +0300
-Subject: [PATCH] StorPool: drop _attach_volume() and _detach_volume().
+Subject: [PATCH 3/8] StorPool: drop _attach_volume() and _detach_volume()
Our os-brick connector already handles the "keep track of which volume
is attached for what reason" calls to storpool.spopenstack. However,
@@ -14,10 +14,13 @@
in the attachment info...
Change-Id: I5da7ae04b87b4fd52a682a6545060e852174f6c8
+Closes-Bug: #1939241
---
.../unit/volume/drivers/test_storpool.py | 6 ++-
- cinder/volume/drivers/storpool.py | 44 ++-----------------
- 2 files changed, 8 insertions(+), 42 deletions(-)
+ cinder/volume/drivers/storpool.py | 46 ++-----------------
+ ...ch-encrypted-volumes-783c723683b8f9a9.yaml | 7 +++
+ 3 files changed, 16 insertions(+), 43 deletions(-)
+ create mode 100644 releasenotes/notes/bug-1939241-storpool-attach-encrypted-volumes-783c723683b8f9a9.yaml
diff --git a/cinder/tests/unit/volume/drivers/test_storpool.py b/cinder/tests/unit/volume/drivers/test_storpool.py
index a5f763b96..843283db4 100644
@@ -41,7 +44,7 @@
def test_noop_functions(self):
self.driver.terminate_connection(None, None)
diff --git a/cinder/volume/drivers/storpool.py b/cinder/volume/drivers/storpool.py
-index cf5707cbc..a1388677b 100644
+index 47685cb3f..4d79a82f8 100644
--- a/cinder/volume/drivers/storpool.py
+++ b/cinder/volume/drivers/storpool.py
@@ -1,4 +1,4 @@
@@ -50,7 +53,7 @@
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
-@@ -90,6 +90,8 @@ class StorPoolDriver(driver.VolumeDriver):
+@@ -91,9 +91,11 @@ class StorPoolDriver(driver.VolumeDriver):
1.2.2 - Reintroduce the driver into OpenStack Queens,
add ignore_errors to the internal _detach_volume() method
1.2.3 - Advertise some more driver capabilities.
@@ -58,8 +61,12 @@
+ connector will handle this.
"""
- VERSION = '1.2.3'
-@@ -167,6 +169,7 @@ class StorPoolDriver(driver.VolumeDriver):
+- VERSION = '1.2.3'
++ VERSION = '2.0.0'
+ CI_WIKI_NAME = 'StorPool_distributed_storage_CI'
+
+ def __init__(self, *args, **kwargs):
+@@ -168,6 +170,7 @@ class StorPoolDriver(driver.VolumeDriver):
'data': {
'client_id': self._storpool_client_id(connector),
'volume': volume['id'],
@@ -67,7 +74,7 @@
}}
def terminate_connection(self, volume, connector, **kwargs):
-@@ -312,45 +315,6 @@ class StorPoolDriver(driver.VolumeDriver):
+@@ -313,45 +316,6 @@ class StorPoolDriver(driver.VolumeDriver):
'pools': pools
}
@@ -113,6 +120,19 @@
def backup_volume(self, context, backup, backup_service):
volume = self.db.volume_get(context, backup['volume_id'])
req_id = context.request_id
+diff --git a/releasenotes/notes/bug-1939241-storpool-attach-encrypted-volumes-783c723683b8f9a9.yaml b/releasenotes/notes/bug-1939241-storpool-attach-encrypted-volumes-783c723683b8f9a9.yaml
+new file mode 100644
+index 000000000..b19904041
+--- /dev/null
++++ b/releasenotes/notes/bug-1939241-storpool-attach-encrypted-volumes-783c723683b8f9a9.yaml
+@@ -0,0 +1,7 @@
++---
++fixes:
++ - |
++ StorPool driver `bug #1939241
++ <https://bugs.launchpad.net/cinder/+bug/1939241>`_: Fixed the creation of
++ encrypted StorPool volumes by dropping the needlessly and incompletely
++ overridden `_attach_volume()` and `_detach_volume()` methods.
--
-2.30.2
+2.35.1
diff --git a/patches/openstack/cinder/storpool-do-detach.patch b/patches/openstack/cinder/storpool-do-detach.patch
new file mode 100644
index 0000000..6678eb7
--- /dev/null
+++ b/patches/openstack/cinder/storpool-do-detach.patch
@@ -0,0 +1,109 @@
+From 37a2ad8ba2de741e90421e4d0590af02a69e4ba9 Mon Sep 17 00:00:00 2001
+From: Peter Penchev <openstack-dev@storpool.com>
+Date: Wed, 15 Jun 2022 16:07:34 +0300
+Subject: [PATCH 4/8] StorPool: really detach after copy to/from image.
+
+When copying a volume to an image, detach the temporary snapshot after
+the copy operation, otherwise the attempt to delete it immediately
+afterwards will fail. When copying an image to a volume, detach
+the volume after the copy operation.
+
+This only matters when Cinder is not used as a backing store for Glance
+images; otherwise, these functions are never invoked and volumes are
+cloned instead (modulo other bugs in these workflows).
+
+Change-Id: Id93d578763bcd444e093cac4bd91b6fe68ffd12f
+Closes-bug: #1978825
+---
+ cinder/volume/drivers/storpool.py | 34 +++++++++++++++----
+ ...ach-after-image-copy-6c4dff727583fe17.yaml | 7 ++++
+ 2 files changed, 34 insertions(+), 7 deletions(-)
+ create mode 100644 releasenotes/notes/bug-1978825-storpool-detach-after-image-copy-6c4dff727583fe17.yaml
+
+diff --git a/cinder/volume/drivers/storpool.py b/cinder/volume/drivers/storpool.py
+index 4d79a82f8..56b4070bc 100644
+--- a/cinder/volume/drivers/storpool.py
++++ b/cinder/volume/drivers/storpool.py
+@@ -93,6 +93,8 @@ class StorPoolDriver(driver.VolumeDriver):
+ 1.2.3 - Advertise some more driver capabilities.
+ 2.0.0 - Drop _attach_volume() and _detach_volume(), our os-brick
+ connector will handle this.
++ - Detach temporary snapshots and volumes after copying data
++ to or from from Glance images.
+ """
+
+ VERSION = '2.0.0'
+@@ -351,20 +353,28 @@ class StorPoolDriver(driver.VolumeDriver):
+ name = self._attach.volsnapName(volume['id'], req_id)
+ try:
+ self._attach.api().snapshotCreate(volname, {'name': name})
++ self._attach.add(req_id, {
++ 'volume': name,
++ 'type': 'copy-from',
++ 'id': req_id,
++ 'rights': 1,
++ 'volsnap': True
++ })
++ self._attach.sync(req_id, None)
+ except spapi.ApiError as e:
+ raise self._backendException(e)
+- self._attach.add(req_id, {
+- 'volume': name,
+- 'type': 'copy-from',
+- 'id': req_id,
+- 'rights': 1,
+- 'volsnap': True
+- })
+ try:
+ return super(StorPoolDriver, self).copy_volume_to_image(
+ context, volume, image_service, image_meta)
+ finally:
+ self._attach.remove(req_id)
++ try:
++ self._attach.sync(req_id, name)
++ except spapi.ApiError as e:
++ LOG.error(
++ 'Could not detach the temp snapshot %(name)s for '
++ '%(vol)s: %(err)s',
++ {'name': name, 'vol': volname, 'err': e})
+ try:
+ self._attach.api().snapshotDelete(name)
+ except spapi.ApiError as e:
+@@ -382,11 +392,21 @@ class StorPoolDriver(driver.VolumeDriver):
+ 'id': req_id,
+ 'rights': 2
+ })
++ try:
++ self._attach.sync(req_id, None)
++ except spapi.ApiError as e:
++ raise self._backendException(e)
+ try:
+ return super(StorPoolDriver, self).copy_image_to_volume(
+ context, volume, image_service, image_id)
+ finally:
+ self._attach.remove(req_id)
++ try:
++ self._attach.sync(req_id, name)
++ except spapi.ApiError as e:
++ LOG.error(
++ 'Could not detach the %(name)s volume: %(err)s',
++ {'name': name, 'err': e})
+
+ def extend_volume(self, volume, new_size):
+ size = int(new_size) * units.Gi
+diff --git a/releasenotes/notes/bug-1978825-storpool-detach-after-image-copy-6c4dff727583fe17.yaml b/releasenotes/notes/bug-1978825-storpool-detach-after-image-copy-6c4dff727583fe17.yaml
+new file mode 100644
+index 000000000..bfc6ef3dc
+--- /dev/null
++++ b/releasenotes/notes/bug-1978825-storpool-detach-after-image-copy-6c4dff727583fe17.yaml
+@@ -0,0 +1,7 @@
++---
++fixes:
++ - |
++ StorPool driver `bug #1978825
++ <https://bugs.launchpad.net/cinder/+bug/1978825>`_: Fixed
++ stale StorPool volume and snapshot attachments persisting after
++ copying a volume to/from a Glance image.
+--
+2.35.1
+