Add the copy to volume and retyping fixes
Change-Id: I71c0561c5fab179156a3a357e64298819cb53885
diff --git a/patches/openstack/cinder/sep-sp-drop-copy-img-vol.patch b/patches/openstack/cinder/sep-sp-drop-copy-img-vol.patch
new file mode 100644
index 0000000..5010855
--- /dev/null
+++ b/patches/openstack/cinder/sep-sp-drop-copy-img-vol.patch
@@ -0,0 +1,89 @@
+From 51a9b386555228e1ba09f0ceebbe18f4b1783ef7 Mon Sep 17 00:00:00 2001
+From: Peter Penchev <openstack-dev@storpool.com>
+Date: Wed, 14 Dec 2022 17:55:18 +0200
+Subject: [PATCH 1/2] StorPool: drop copy_image_to_volume and
+ copy_volume_to_image
+
+These two methods do not do anything useful any more, and they actually
+get in the way of some new Cinder flows.
+
+Change-Id: I2a7efc87c1bb87e8af66dc9b0cf8fa6289f55f97
+---
+ cinder/volume/drivers/storpool.py | 61 -------------------------------
+ 1 file changed, 61 deletions(-)
+
+diff --git a/cinder/volume/drivers/storpool.py b/cinder/volume/drivers/storpool.py
+index 64e92fe7e..b586c3216 100644
+--- a/cinder/volume/drivers/storpool.py
++++ b/cinder/volume/drivers/storpool.py
+@@ -434,67 +434,6 @@ class StorPoolDriver(driver.VolumeDriver):
+ 'pools': pools
+ }
+
+- def copy_volume_to_image(self, context, volume, image_service, image_meta):
+- req_id = context.request_id
+- volname = self._attach.volumeName(volume['id'])
+- 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)
+- 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:
+- LOG.error(
+- 'Could not remove the temp snapshot %(name)s for '
+- '%(vol)s: %(err)s',
+- {'name': name, 'vol': volname, 'err': e})
+-
+- def copy_image_to_volume(self, context, volume, image_service, image_id):
+- req_id = context.request_id
+- name = self._attach.volumeName(volume['id'])
+- self._attach.add(req_id, {
+- 'volume': name,
+- 'type': 'copy-to',
+- '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
+ name = self._attach.volumeName(volume['id'])
+--
+2.35.1
+
diff --git a/patches/openstack/cinder/sep-sp-retype-vol.patch b/patches/openstack/cinder/sep-sp-retype-vol.patch
new file mode 100644
index 0000000..3b5fada
--- /dev/null
+++ b/patches/openstack/cinder/sep-sp-retype-vol.patch
@@ -0,0 +1,91 @@
+From 15773fc48d174bd6931eac65cae1b000ab72b1fb Mon Sep 17 00:00:00 2001
+From: Peter Penchev <openstack-dev@storpool.com>
+Date: Wed, 14 Dec 2022 17:55:56 +0200
+Subject: [PATCH 2/2] StorPool: fix the retype volume flow
+
+Change-Id: I786733aae17dea47e3e6f2a393a947bfb46e70a3
+---
+ cinder/volume/drivers/storpool.py | 47 ++++++++++++++++++++++++-------
+ 1 file changed, 37 insertions(+), 10 deletions(-)
+
+diff --git a/cinder/volume/drivers/storpool.py b/cinder/volume/drivers/storpool.py
+index b586c3216..51f95f14f 100644
+--- a/cinder/volume/drivers/storpool.py
++++ b/cinder/volume/drivers/storpool.py
+@@ -472,10 +472,12 @@ class StorPoolDriver(driver.VolumeDriver):
+ update['template'] = templ
+ else:
+ update['replication'] = repl
+- elif v[0] != v[1]:
+- LOG.error('Retype of extra_specs "%s" not '
+- 'supported yet.', k)
+- return False
++ else:
++ # We ignore any extra specs that we do not know about.
++ # Let's leave it to Cinder's scheduler to not even
++ # get this far if there is any serious mismatch between
++ # the volume types.
++ pass
+
+ if update:
+ name = self._attach.volumeName(volume['id'])
+@@ -500,25 +502,50 @@ class StorPoolDriver(driver.VolumeDriver):
+ 'created as part of the migration from '
+ '"%(oid)s".', {'tid': temp_id, 'oid': orig_id})
+ return {'_name_id': new_volume['_name_id'] or new_volume['id']}
+- elif orig_name in vols:
+- LOG.error('StorPool update_migrated_volume(): both '
++
++ if orig_name in vols:
++ LOG.debug('StorPool update_migrated_volume(): both '
+ 'the original volume "%(oid)s" and the migrated '
+ 'StorPool volume "%(tid)s" seem to exist on '
+ 'the StorPool cluster.',
+ {'oid': orig_id, 'tid': temp_id})
+- return {'_name_id': new_volume['_name_id'] or new_volume['id']}
+- else:
++ int_name = temp_name + '--temp--mig'
++ LOG.debug('Trying to swap the volume names, intermediate "%(int)s"',
++ {'int': int_name})
+ try:
++ LOG.debug('- rename "%(orig)s" to "%(int)s"',
++ {'orig': orig_name, 'int': int_name})
++ self._attach.api().volumeUpdate(orig_name,
++ {'rename': int_name})
++
++ LOG.debug('- rename "%(temp)s" to "%(orig)s"',
++ {'temp': temp_name, 'orig': orig_name})
+ self._attach.api().volumeUpdate(temp_name,
+ {'rename': orig_name})
++
++ LOG.debug('- rename "%(int)s" to "%(temp)s"',
++ {'int': int_name, 'temp': temp_name})
++ self._attach.api().volumeUpdate(int_name,
++ {'rename': temp_name})
+ return {'_name_id': None}
+ except spapi.ApiError as e:
+ LOG.error('StorPool update_migrated_volume(): '
+- 'could not rename %(tname)s to %(oname)s: '
++ 'could not rename a volume: '
+ '%(err)s',
+- {'tname': temp_name, 'oname': orig_name, 'err': e})
++ {'err': e})
+ return {'_name_id': new_volume['_name_id'] or new_volume['id']}
+
++ try:
++ self._attach.api().volumeUpdate(temp_name,
++ {'rename': orig_name})
++ return {'_name_id': None}
++ except spapi.ApiError as e:
++ LOG.error('StorPool update_migrated_volume(): '
++ 'could not rename %(tname)s to %(oname)s: '
++ '%(err)s',
++ {'tname': temp_name, 'oname': orig_name, 'err': e})
++ return {'_name_id': new_volume['_name_id'] or new_volume['id']}
++
+ def revert_to_snapshot(self, context, volume, snapshot):
+ volname = self._attach.volumeName(volume['id'])
+ snapname = self._attach.snapshotName('snap', snapshot['id'])
+--
+2.35.1
+
diff --git a/patches/series.experimental b/patches/series.experimental
index 62f87f2..45d7be5 100644
--- a/patches/series.experimental
+++ b/patches/series.experimental
@@ -5,5 +5,7 @@
openstack/cinder/sep-sp-rm-backup.patch
openstack/cinder/sep-sp-rm-copy-volimg.patch
openstack/cinder/sep-sp-clone-volume.patch
+openstack/cinder/sep-sp-drop-copy-img-vol.patch
+openstack/cinder/sep-sp-retype-vol.patch
openstack/cinderlib/storpool-test-20190910.patch
openstack/devstack/eatmydata.patch