summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Rosmaita <rosmaita.fossdev@gmail.com>2023-04-18 11:22:27 -0400
committerGorka Eguileor <geguileo@redhat.com>2023-05-10 16:52:31 +0200
commit1f447bc184500e070cbfcada76b0ea51104919b1 (patch)
tree513c1193792eaf57135697843908d27a2d18bc49
parentece3fbe0619d21580c30f8a86a243ad336718103 (diff)
downloadglance_store-stable/xena.tar.gz
Add force to os-brick disconnectstable/xena
In order to be sure that devices are being removed from the host, we should be using the 'force' parameter with os-brick's disconnect_volume() method. Closes-bug: #2004555 Change-Id: I63d09ad9ef465bc154c85a9ea125449c039d1b90 (cherry picked from commit 1d8033e54e009bbc4408f6e16aec4f6c01687c91 (cherry picked from commit a7eed0263e436f841a3c277e051bdc6d6e07447d Conflicts: glance_store/_drivers/cinder/base.py glance_store/tests/unit/cinder/test_base.py (cherry picked from commit e9d2509926445fd95c9bba9e1cacacb85a5e58af) Conflicts: glance_store/tests/unit/test_cinder_base.py (cherry picked from commit 28301829777d4b1d2d7bca59fda108158d2ad6ca)
-rw-r--r--glance_store/_drivers/cinder.py5
-rw-r--r--glance_store/common/attachment_state_manager.py3
-rw-r--r--glance_store/tests/unit/common/test_attachment_state_manager.py4
-rw-r--r--glance_store/tests/unit/test_cinder_store.py2
-rw-r--r--glance_store/tests/unit/test_multistore_cinder.py2
-rw-r--r--releasenotes/notes/bug-2004555-4fd67fce86c07461.yaml11
6 files changed, 21 insertions, 6 deletions
diff --git a/glance_store/_drivers/cinder.py b/glance_store/_drivers/cinder.py
index 5296dc2..0b4d0a8 100644
--- a/glance_store/_drivers/cinder.py
+++ b/glance_store/_drivers/cinder.py
@@ -816,7 +816,10 @@ class Store(glance_store.driver.Store):
client, attachment.id, volume_id, host, conn,
connection_info, device)
else:
- conn.disconnect_volume(connection_info, device)
+ # Bug #2004555: use force so there aren't any
+ # leftovers
+ conn.disconnect_volume(connection_info, device,
+ force=True)
except Exception:
LOG.exception(_LE('Failed to disconnect volume '
'%(volume_id)s.'),
diff --git a/glance_store/common/attachment_state_manager.py b/glance_store/common/attachment_state_manager.py
index 187a24c..641234a 100644
--- a/glance_store/common/attachment_state_manager.py
+++ b/glance_store/common/attachment_state_manager.py
@@ -230,7 +230,8 @@ class _AttachmentState(object):
{'volume_id': volume_id, 'host': host})
if not vol_attachment.in_use():
- conn.disconnect_volume(connection_info, device)
+ # Bug #2004555: use force so there aren't any leftovers
+ conn.disconnect_volume(connection_info, device, force=True)
del self.volumes[volume_id]
self.volume_api.attachment_delete(client, attachment_id)
diff --git a/glance_store/tests/unit/common/test_attachment_state_manager.py b/glance_store/tests/unit/common/test_attachment_state_manager.py
index f019c9b..7d85b1a 100644
--- a/glance_store/tests/unit/common/test_attachment_state_manager.py
+++ b/glance_store/tests/unit/common/test_attachment_state_manager.py
@@ -90,7 +90,7 @@ class AttachmentStateTestCase(base.BaseTestCase):
mock_attach_delete.side_effect = ex()
self.assertRaises(ex, self._sentinel_detach, conn)
conn.disconnect_volume.assert_called_once_with(
- *self.disconnect_vol_call)
+ *self.disconnect_vol_call, force=True)
@mock.patch.object(cinder_utils.API, 'attachment_create')
@mock.patch.object(cinder_utils.API, 'attachment_delete')
@@ -103,6 +103,6 @@ class AttachmentStateTestCase(base.BaseTestCase):
*self.attach_call_1, **self.attach_call_2)
self.assertEqual(mock.sentinel.attachment_id, attachment['id'])
conn.disconnect_volume.assert_called_once_with(
- *self.disconnect_vol_call)
+ *self.disconnect_vol_call, force=True)
mock_attach_delete.assert_called_once_with(
*self.detach_call)
diff --git a/glance_store/tests/unit/test_cinder_store.py b/glance_store/tests/unit/test_cinder_store.py
index eca8a9f..1a74149 100644
--- a/glance_store/tests/unit/test_cinder_store.py
+++ b/glance_store/tests/unit/test_cinder_store.py
@@ -265,7 +265,7 @@ class TestCinderStore(base.StoreBaseTest,
fake_connector.connect_volume.assert_called_once_with(
mock.ANY)
fake_connector.disconnect_volume.assert_called_once_with(
- mock.ANY, fake_devinfo)
+ mock.ANY, fake_devinfo, force=True)
fake_conn_obj.assert_called_once_with(
mock.ANY, root_helper, conn=mock.ANY,
use_multipath=multipath_supported)
diff --git a/glance_store/tests/unit/test_multistore_cinder.py b/glance_store/tests/unit/test_multistore_cinder.py
index 4046dcd..216acd8 100644
--- a/glance_store/tests/unit/test_multistore_cinder.py
+++ b/glance_store/tests/unit/test_multistore_cinder.py
@@ -298,7 +298,7 @@ class TestMultiCinderStore(base.MultiStoreBaseTest,
fake_connector.connect_volume.assert_called_once_with(
mock.ANY)
fake_connector.disconnect_volume.assert_called_once_with(
- mock.ANY, fake_devinfo)
+ mock.ANY, fake_devinfo, force=True)
fake_conn_obj.assert_called_once_with(
mock.ANY, root_helper, conn=mock.ANY,
use_multipath=multipath_supported)
diff --git a/releasenotes/notes/bug-2004555-4fd67fce86c07461.yaml b/releasenotes/notes/bug-2004555-4fd67fce86c07461.yaml
new file mode 100644
index 0000000..8d982c6
--- /dev/null
+++ b/releasenotes/notes/bug-2004555-4fd67fce86c07461.yaml
@@ -0,0 +1,11 @@
+security:
+ - |
+ Cinder glance_store driver: in order to avoid a situation where a
+ leftover device could be mapped to a different volume than the one
+ intended, the cinder glance_store driver now instructs the os-brick
+ library to force detach volumes, which ensures that devices are
+ removed from the host.
+
+ See `Bug #2004555
+ <https://bugs.launchpad.net/glance-store/+bug/2004555>`_ for more
+ information about this issue.