Merge "Support shared_targets tristate value"
This commit is contained in:
@@ -36,8 +36,17 @@ ISCSI_SUPPORTS_MANUAL_SCAN = check_manual_scan()
|
|||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def guard_connection(device):
|
def guard_connection(device):
|
||||||
"""Context Manager handling locks for attach/detach operations."""
|
"""Context Manager handling locks for attach/detach operations.
|
||||||
if ISCSI_SUPPORTS_MANUAL_SCAN or not device.get('shared_targets'):
|
|
||||||
|
In Cinder microversion 3.69 the shared_targets field for volumes are
|
||||||
|
tristate:
|
||||||
|
|
||||||
|
- True ==> Lock if iSCSI initiator doesn't support manual scans
|
||||||
|
- False ==> Never lock.
|
||||||
|
- None ==> Always lock.
|
||||||
|
"""
|
||||||
|
shared = device.get('shared_targets', False)
|
||||||
|
if (shared is not None and ISCSI_SUPPORTS_MANUAL_SCAN) or shared is False:
|
||||||
yield
|
yield
|
||||||
else:
|
else:
|
||||||
# Cinder passes an OVO, but Nova passes a dictionary, so we use dict
|
# Cinder passes an OVO, but Nova passes a dictionary, so we use dict
|
||||||
|
|||||||
@@ -47,6 +47,16 @@ class InitiatorUtilsTestCase(base.TestCase):
|
|||||||
with utils.guard_connection({'shared_targets': True}):
|
with utils.guard_connection({'shared_targets': True}):
|
||||||
mock_lock.assert_not_called()
|
mock_lock.assert_not_called()
|
||||||
|
|
||||||
|
@mock.patch('oslo_concurrency.lockutils.lock')
|
||||||
|
def test_guard_connection_manual_scan_support_forced(self, mock_lock):
|
||||||
|
"""Guard locks when cinder forces locking."""
|
||||||
|
utils.ISCSI_SUPPORTS_MANUAL_SCAN = True
|
||||||
|
# We confirm that shared_targets is ignored
|
||||||
|
with utils.guard_connection({'service_uuid': mock.sentinel.uuid,
|
||||||
|
'shared_targets': None}):
|
||||||
|
mock_lock.assert_called_once_with(mock.sentinel.uuid, 'os-brick-',
|
||||||
|
external=True)
|
||||||
|
|
||||||
@mock.patch('oslo_concurrency.lockutils.lock')
|
@mock.patch('oslo_concurrency.lockutils.lock')
|
||||||
def test_guard_connection_manual_scan_unsupported_not_shared(self,
|
def test_guard_connection_manual_scan_unsupported_not_shared(self,
|
||||||
mock_lock):
|
mock_lock):
|
||||||
@@ -55,7 +65,7 @@ class InitiatorUtilsTestCase(base.TestCase):
|
|||||||
mock_lock.assert_not_called()
|
mock_lock.assert_not_called()
|
||||||
|
|
||||||
@mock.patch('oslo_concurrency.lockutils.lock')
|
@mock.patch('oslo_concurrency.lockutils.lock')
|
||||||
def test_guard_connection_manual_scan_unsupported_hared(self, mock_lock):
|
def test_guard_connection_manual_scan_unsupported_shared(self, mock_lock):
|
||||||
utils.ISCSI_SUPPORTS_MANUAL_SCAN = False
|
utils.ISCSI_SUPPORTS_MANUAL_SCAN = False
|
||||||
with utils.guard_connection({'service_uuid': mock.sentinel.uuid,
|
with utils.guard_connection({'service_uuid': mock.sentinel.uuid,
|
||||||
'shared_targets': True}):
|
'shared_targets': True}):
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
NVMe-oF connector `bug #1961102
|
||||||
|
<https://bugs.launchpad.net/os-brick/+bug/1961102>`_: Fixed leaving
|
||||||
|
controller devices (i.e., /dev/nvme0) behind on hosts. Now NVMe-oF
|
||||||
|
subsytems are disconnected when disconnecting volumes if the subsytem
|
||||||
|
doesn't have additional volumes present in the host.
|
||||||
Reference in New Issue
Block a user