summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2023-05-10 21:25:51 +0000
committerGerrit Code Review <review@openstack.org>2023-05-10 21:25:51 +0000
commit7101820b6422780cbb1824335e701243491777df (patch)
tree3b652b49ddb91e44b57d679777a094d91b7bf4a0
parent03283b672da6671153387f90452991307d1d765f (diff)
parent28301829777d4b1d2d7bca59fda108158d2ad6ca (diff)
downloadglance_store-7101820b6422780cbb1824335e701243491777df.tar.gz
Merge "Add force to os-brick disconnect" into stable/yoga3.0.1
-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 8a81543..4817ba9 100644
--- a/glance_store/_drivers/cinder.py
+++ b/glance_store/_drivers/cinder.py
@@ -819,7 +819,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 984fcb8..948ebd1 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 d8c5189..4d1c26a 100644
--- a/glance_store/tests/unit/common/test_attachment_state_manager.py
+++ b/glance_store/tests/unit/common/test_attachment_state_manager.py
@@ -91,7 +91,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')
@@ -104,7 +104,7 @@ 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 d59cf07..fe738ca 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 66770c7..c8ee25e 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.