Peter Pentchev | 38b9cec | 2022-06-23 14:05:52 +0300 | [diff] [blame] | 1 | From b0710f215a9bea69bfdb35d0485c38cd8a87204e Mon Sep 17 00:00:00 2001 |
Peter Pentchev | 5006ff6 | 2021-10-26 01:28:45 +0300 | [diff] [blame] | 2 | From: Peter Penchev <openstack-dev@storpool.com> |
| 3 | Date: Tue, 20 Apr 2021 17:46:41 +0300 |
Peter Pentchev | 38b9cec | 2022-06-23 14:05:52 +0300 | [diff] [blame] | 4 | Subject: [PATCH 3/8] StorPool: drop _attach_volume() and _detach_volume() |
Peter Pentchev | 5006ff6 | 2021-10-26 01:28:45 +0300 | [diff] [blame] | 5 | |
| 6 | Our os-brick connector already handles the "keep track of which volume |
| 7 | is attached for what reason" calls to storpool.spopenstack. However, |
| 8 | we need to explicitly specify the access mode in initialize_connection() |
| 9 | now, since our os-brick connector does not know how to divine it yet. |
| 10 | (this will come later with the "attach snapshot" functionality) |
| 11 | |
| 12 | Incidentally, this fixes the "create an encrypted volume" flow, since |
| 13 | our _attach_volume() implementation never actually returned a connector |
| 14 | in the attachment info... |
| 15 | |
| 16 | Change-Id: I5da7ae04b87b4fd52a682a6545060e852174f6c8 |
Peter Pentchev | 38b9cec | 2022-06-23 14:05:52 +0300 | [diff] [blame] | 17 | Closes-Bug: #1939241 |
Peter Pentchev | 5006ff6 | 2021-10-26 01:28:45 +0300 | [diff] [blame] | 18 | --- |
| 19 | .../unit/volume/drivers/test_storpool.py | 6 ++- |
Peter Pentchev | 38b9cec | 2022-06-23 14:05:52 +0300 | [diff] [blame] | 20 | cinder/volume/drivers/storpool.py | 46 ++----------------- |
| 21 | ...ch-encrypted-volumes-783c723683b8f9a9.yaml | 7 +++ |
| 22 | 3 files changed, 16 insertions(+), 43 deletions(-) |
| 23 | create mode 100644 releasenotes/notes/bug-1939241-storpool-attach-encrypted-volumes-783c723683b8f9a9.yaml |
Peter Pentchev | 5006ff6 | 2021-10-26 01:28:45 +0300 | [diff] [blame] | 24 | |
| 25 | diff --git a/cinder/tests/unit/volume/drivers/test_storpool.py b/cinder/tests/unit/volume/drivers/test_storpool.py |
| 26 | index a5f763b96..843283db4 100644 |
| 27 | --- a/cinder/tests/unit/volume/drivers/test_storpool.py |
| 28 | +++ b/cinder/tests/unit/volume/drivers/test_storpool.py |
| 29 | @@ -1,4 +1,4 @@ |
| 30 | -# Copyright 2014 - 2017, 2019 StorPool |
| 31 | +# Copyright 2014 - 2017, 2019 - 2021 StorPool |
| 32 | # All Rights Reserved. |
| 33 | # |
| 34 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 35 | @@ -225,7 +225,9 @@ class StorPoolTestCase(test.TestCase): |
| 36 | def test_initialize_connection_good(self, cid, hid, name): |
| 37 | c = self.driver.initialize_connection({'id': hid}, {'host': name}) |
| 38 | self.assertEqual('storpool', c['driver_volume_type']) |
| 39 | - self.assertDictEqual({'client_id': cid, 'volume': hid}, c['data']) |
| 40 | + self.assertDictEqual({'client_id': cid, 'volume': hid, |
| 41 | + 'access_mode': 'rw'}, |
| 42 | + c['data']) |
| 43 | |
| 44 | def test_noop_functions(self): |
| 45 | self.driver.terminate_connection(None, None) |
| 46 | diff --git a/cinder/volume/drivers/storpool.py b/cinder/volume/drivers/storpool.py |
Peter Pentchev | 38b9cec | 2022-06-23 14:05:52 +0300 | [diff] [blame] | 47 | index 47685cb3f..4d79a82f8 100644 |
Peter Pentchev | 5006ff6 | 2021-10-26 01:28:45 +0300 | [diff] [blame] | 48 | --- a/cinder/volume/drivers/storpool.py |
| 49 | +++ b/cinder/volume/drivers/storpool.py |
| 50 | @@ -1,4 +1,4 @@ |
| 51 | -# Copyright (c) 2014 - 2019 StorPool |
| 52 | +# Copyright (c) 2014 - 2021 StorPool |
| 53 | # All Rights Reserved. |
| 54 | # |
| 55 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
Peter Pentchev | 38b9cec | 2022-06-23 14:05:52 +0300 | [diff] [blame] | 56 | @@ -91,9 +91,11 @@ class StorPoolDriver(driver.VolumeDriver): |
Peter Pentchev | 5006ff6 | 2021-10-26 01:28:45 +0300 | [diff] [blame] | 57 | 1.2.2 - Reintroduce the driver into OpenStack Queens, |
| 58 | add ignore_errors to the internal _detach_volume() method |
| 59 | 1.2.3 - Advertise some more driver capabilities. |
| 60 | + 2.0.0 - Drop _attach_volume() and _detach_volume(), our os-brick |
| 61 | + connector will handle this. |
| 62 | """ |
| 63 | |
Peter Pentchev | 38b9cec | 2022-06-23 14:05:52 +0300 | [diff] [blame] | 64 | - VERSION = '1.2.3' |
| 65 | + VERSION = '2.0.0' |
| 66 | CI_WIKI_NAME = 'StorPool_distributed_storage_CI' |
| 67 | |
| 68 | def __init__(self, *args, **kwargs): |
| 69 | @@ -168,6 +170,7 @@ class StorPoolDriver(driver.VolumeDriver): |
Peter Pentchev | 5006ff6 | 2021-10-26 01:28:45 +0300 | [diff] [blame] | 70 | 'data': { |
| 71 | 'client_id': self._storpool_client_id(connector), |
| 72 | 'volume': volume['id'], |
| 73 | + 'access_mode': 'rw', |
| 74 | }} |
| 75 | |
| 76 | def terminate_connection(self, volume, connector, **kwargs): |
Peter Pentchev | 38b9cec | 2022-06-23 14:05:52 +0300 | [diff] [blame] | 77 | @@ -313,45 +316,6 @@ class StorPoolDriver(driver.VolumeDriver): |
Peter Pentchev | 5006ff6 | 2021-10-26 01:28:45 +0300 | [diff] [blame] | 78 | 'pools': pools |
| 79 | } |
| 80 | |
| 81 | - def _attach_volume(self, context, volume, properties, remote=False): |
| 82 | - if remote: |
| 83 | - return super(StorPoolDriver, self)._attach_volume( |
| 84 | - context, volume, properties, remote=remote) |
| 85 | - req_id = context.request_id |
| 86 | - req = self._attach.get().get(req_id, None) |
| 87 | - if req is None: |
| 88 | - req = { |
| 89 | - 'volume': self._attach.volumeName(volume['id']), |
| 90 | - 'type': 'cinder-attach', |
| 91 | - 'id': context.request_id, |
| 92 | - 'rights': 2, |
| 93 | - 'volsnap': False, |
| 94 | - 'remove_on_detach': True |
| 95 | - } |
| 96 | - self._attach.add(req_id, req) |
| 97 | - name = req['volume'] |
| 98 | - self._attach.sync(req_id, None) |
| 99 | - return {'device': {'path': '/dev/storpool/' + name, |
| 100 | - 'storpool_attach_req': req_id}}, volume |
| 101 | - |
| 102 | - def _detach_volume(self, context, attach_info, volume, properties, |
| 103 | - force=False, remote=False, ignore_errors=False): |
| 104 | - if remote: |
| 105 | - return super(StorPoolDriver, self)._detach_volume( |
| 106 | - context, attach_info, volume, properties, |
| 107 | - force=force, remote=remote, ignore_errors=ignore_errors) |
| 108 | - try: |
| 109 | - req_id = attach_info.get('device', {}).get( |
| 110 | - 'storpool_attach_req', context.request_id) |
| 111 | - req = self._attach.get()[req_id] |
| 112 | - name = req['volume'] |
| 113 | - self._attach.sync(req_id, name) |
| 114 | - if req.get('remove_on_detach', False): |
| 115 | - self._attach.remove(req_id) |
| 116 | - except BaseException: |
| 117 | - if not ignore_errors: |
| 118 | - raise |
| 119 | - |
| 120 | def backup_volume(self, context, backup, backup_service): |
| 121 | volume = self.db.volume_get(context, backup['volume_id']) |
| 122 | req_id = context.request_id |
Peter Pentchev | 38b9cec | 2022-06-23 14:05:52 +0300 | [diff] [blame] | 123 | diff --git a/releasenotes/notes/bug-1939241-storpool-attach-encrypted-volumes-783c723683b8f9a9.yaml b/releasenotes/notes/bug-1939241-storpool-attach-encrypted-volumes-783c723683b8f9a9.yaml |
| 124 | new file mode 100644 |
| 125 | index 000000000..b19904041 |
| 126 | --- /dev/null |
| 127 | +++ b/releasenotes/notes/bug-1939241-storpool-attach-encrypted-volumes-783c723683b8f9a9.yaml |
| 128 | @@ -0,0 +1,7 @@ |
| 129 | +--- |
| 130 | +fixes: |
| 131 | + - | |
| 132 | + StorPool driver `bug #1939241 |
| 133 | + <https://bugs.launchpad.net/cinder/+bug/1939241>`_: Fixed the creation of |
| 134 | + encrypted StorPool volumes by dropping the needlessly and incompletely |
| 135 | + overridden `_attach_volume()` and `_detach_volume()` methods. |
Peter Pentchev | 5006ff6 | 2021-10-26 01:28:45 +0300 | [diff] [blame] | 136 | -- |
Peter Pentchev | 38b9cec | 2022-06-23 14:05:52 +0300 | [diff] [blame] | 137 | 2.35.1 |
Peter Pentchev | 5006ff6 | 2021-10-26 01:28:45 +0300 | [diff] [blame] | 138 | |