blob: fea0d2ae394dd23f39a98e0c5e04dca58c5f7362 [file] [log] [blame]
Peter Pentchev6ef0f072022-09-26 16:20:30 +03001From 6c24a83a1b7c1c31a43088165492604f440e00c5 Mon Sep 17 00:00:00 2001
2From: Peter Penchev <openstack-dev@storpool.com>
3Date: Tue, 20 Apr 2021 17:46:41 +0300
4Subject: [PATCH 4/7] StorPool: drop _attach_volume() and _detach_volume()
5
6Our os-brick connector already handles the "keep track of which volume
7is attached for what reason" calls to storpool.spopenstack. However,
8we need to explicitly specify the access mode in initialize_connection()
9now, since our os-brick connector does not know how to divine it yet.
10(this will come later with the "attach snapshot" functionality)
11
12Incidentally, this fixes the "create an encrypted volume" flow, since
13our _attach_volume() implementation never actually returned a connector
14in the attachment info...
15
16Change-Id: I5da7ae04b87b4fd52a682a6545060e852174f6c8
17Closes-Bug: #1939241
18---
19 .../unit/volume/drivers/test_storpool.py | 4 +-
20 cinder/volume/drivers/storpool.py | 40 +------------------
21 ...ch-encrypted-volumes-783c723683b8f9a9.yaml | 7 ++++
22 3 files changed, 11 insertions(+), 40 deletions(-)
23 create mode 100644 releasenotes/notes/bug-1939241-storpool-attach-encrypted-volumes-783c723683b8f9a9.yaml
24
25diff --git a/cinder/tests/unit/volume/drivers/test_storpool.py b/cinder/tests/unit/volume/drivers/test_storpool.py
26index a5f763b96..2e6f56526 100644
27--- a/cinder/tests/unit/volume/drivers/test_storpool.py
28+++ b/cinder/tests/unit/volume/drivers/test_storpool.py
29@@ -225,7 +225,9 @@ class StorPoolTestCase(test.TestCase):
30 def test_initialize_connection_good(self, cid, hid, name):
31 c = self.driver.initialize_connection({'id': hid}, {'host': name})
32 self.assertEqual('storpool', c['driver_volume_type'])
33- self.assertDictEqual({'client_id': cid, 'volume': hid}, c['data'])
34+ self.assertDictEqual({'client_id': cid, 'volume': hid,
35+ 'access_mode': 'rw'},
36+ c['data'])
37
38 def test_noop_functions(self):
39 self.driver.terminate_connection(None, None)
40diff --git a/cinder/volume/drivers/storpool.py b/cinder/volume/drivers/storpool.py
41index 328f76c00..353329085 100644
42--- a/cinder/volume/drivers/storpool.py
43+++ b/cinder/volume/drivers/storpool.py
44@@ -168,6 +168,7 @@ class StorPoolDriver(driver.VolumeDriver):
45 'data': {
46 'client_id': self._storpool_client_id(connector),
47 'volume': volume['id'],
48+ 'access_mode': 'rw',
49 }}
50
51 def terminate_connection(self, volume, connector, **kwargs):
52@@ -314,45 +315,6 @@ class StorPoolDriver(driver.VolumeDriver):
53 'pools': pools
54 }
55
56- def _attach_volume(self, context, volume, properties, remote=False):
57- if remote:
58- return super(StorPoolDriver, self)._attach_volume(
59- context, volume, properties, remote=remote)
60- req_id = context.request_id
61- req = self._attach.get().get(req_id, None)
62- if req is None:
63- req = {
64- 'volume': self._attach.volumeName(volume['id']),
65- 'type': 'cinder-attach',
66- 'id': context.request_id,
67- 'rights': 2,
68- 'volsnap': False,
69- 'remove_on_detach': True
70- }
71- self._attach.add(req_id, req)
72- name = req['volume']
73- self._attach.sync(req_id, None)
74- return {'device': {'path': '/dev/storpool/' + name,
75- 'storpool_attach_req': req_id}}, volume
76-
77- def _detach_volume(self, context, attach_info, volume, properties,
78- force=False, remote=False, ignore_errors=False):
79- if remote:
80- return super(StorPoolDriver, self)._detach_volume(
81- context, attach_info, volume, properties,
82- force=force, remote=remote, ignore_errors=ignore_errors)
83- try:
84- req_id = attach_info.get('device', {}).get(
85- 'storpool_attach_req', context.request_id)
86- req = self._attach.get()[req_id]
87- name = req['volume']
88- self._attach.sync(req_id, name)
89- if req.get('remove_on_detach', False):
90- self._attach.remove(req_id)
91- except BaseException:
92- if not ignore_errors:
93- raise
94-
95 def backup_volume(self, context, backup, backup_service):
96 volume = self.db.volume_get(context, backup['volume_id'])
97 req_id = context.request_id
98diff --git a/releasenotes/notes/bug-1939241-storpool-attach-encrypted-volumes-783c723683b8f9a9.yaml b/releasenotes/notes/bug-1939241-storpool-attach-encrypted-volumes-783c723683b8f9a9.yaml
99new file mode 100644
100index 000000000..b19904041
101--- /dev/null
102+++ b/releasenotes/notes/bug-1939241-storpool-attach-encrypted-volumes-783c723683b8f9a9.yaml
103@@ -0,0 +1,7 @@
104+---
105+fixes:
106+ - |
107+ StorPool driver `bug #1939241
108+ <https://bugs.launchpad.net/cinder/+bug/1939241>`_: Fixed the creation of
109+ encrypted StorPool volumes by dropping the needlessly and incompletely
110+ overridden `_attach_volume()` and `_detach_volume()` methods.
111--
1122.35.1
113