From 94c1d241533397bb938682abeaa51ae74d069cb7 Mon Sep 17 00:00:00 2001 From: Naoki Saito Date: Fri, 17 Jul 2020 17:30:17 +0900 Subject: [PATCH] NEC driver: fix live-migration failure with FC The initialize_connection() in the driver sometimes returns wrong LUN and causes a live-migration failure. The function searches the LUN from LD sets (attached hosts) and returns the first hit. The function must return an LUN of the destination host, but the first hit may be an LUN of the source host. This patch fixes initialize_connection() to return correct LUN by searching with WWPN of the desitination host. Change-Id: I102ae84204e0d88814a7d2e028f7cec118ad6b60 Closes-Bug: #1887908 --- .../unit/volume/drivers/nec/test_volume.py | 69 ++++++++++++++++++- cinder/volume/drivers/nec/volume_helper.py | 8 +-- ...ation-failure-withfc-3128fff7c48e739f.yaml | 6 ++ 3 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 releasenotes/notes/bug-1887908-nec-live-migration-failure-withfc-3128fff7c48e739f.yaml diff --git a/cinder/tests/unit/volume/drivers/nec/test_volume.py b/cinder/tests/unit/volume/drivers/nec/test_volume.py index 1a93ece3e96..b069c68a448 100644 --- a/cinder/tests/unit/volume/drivers/nec/test_volume.py +++ b/cinder/tests/unit/volume/drivers/nec/test_volume.py @@ -211,6 +211,17 @@ xml_out = ''' IV + +
+ 0011 + LX + 6EWPOChJkdSysJmpMAB9YR + 6442450944 + 0001 + --- + IV +
+
0fff @@ -331,6 +342,26 @@ xml_out = ''' 0001 0006
+
+ 0002 + 0011 +
+
+ +
+ LX + OpenStack3 +
+
+ 1000-0090-FAA0-786D +
+
+ 1000-0090-FAA0-786C +
+
+ 0001 + 0011 +
@@ -1033,6 +1064,37 @@ class ExportTest(volume_helper.MStorageDSVDriver, test.TestCase): self._fc_terminate_connection(vol, connector) delldsetld_mock.assert_not_called() + vol = fake_volume_obj(ctx, id='ccd662e5-2efe-4899-b12f-114b5cad81c3') + connector = {'wwpns': ["10000090FAA0786A", "10000090FAA0786B"], + 'host': 'HostA'} + atchmnt = { + 'id': constants.ATTACHMENT_ID, + 'volume_id': vol.id, + 'connector': connector + } + attach_object = volume_attachment.VolumeAttachment(**atchmnt) + attachment = volume_attachment.VolumeAttachmentList( + objects=[attach_object]) + vol.volume_attachment = attachment + + info = self._fc_initialize_connection(vol, connector) + self.assertEqual(2, info['data']['target_lun']) + + connector = {'wwpns': ["10000090FAA0786C", "10000090FAA0786D"], + 'host': 'HostB'} + atchmnt = { + 'id': constants.ATTACHMENT_ID, + 'volume_id': vol.id, + 'connector': connector + } + attach_object = volume_attachment.VolumeAttachment(**atchmnt) + attachment = volume_attachment.VolumeAttachmentList( + objects=[attach_object]) + vol.volume_attachment = attachment + + info = self._fc_initialize_connection(vol, connector) + self.assertEqual(1, info['data']['target_lun']) + def test_fc_terminate_connection(self): ctx = context.RequestContext('admin', 'fake', True) vol = fake_volume_obj(ctx, id='46045673-41e7-44a7-9333-02f07feab04b') @@ -1244,7 +1306,12 @@ class NonDisruptiveBackup_test(volume_helper.MStorageDSVDriver, 'protocol': 'FC', 'wwpn': ['1000-0090-FAA0-786A', '1000-0090-FAA0-786B'], 'port': []} - return_ldset = [ldset_lds0, ldset_lds1] + ldset_lds2 = {'ldsetname': 'LX:OpenStack1', + 'lds': {6: {'ldn': 6, 'lun': 1}}, + 'protocol': 'FC', + 'wwpn': ['1000-0090-FAA0-786A', '1000-0090-FAA0-786B'], + 'port': []} + return_ldset = [ldset_lds0, ldset_lds1, ldset_lds2] self.mock_object(self, '_validate_fcldset_exist', side_effect=return_ldset) mocker = self.mock_object(self._cli, 'addldsetld', diff --git a/cinder/volume/drivers/nec/volume_helper.py b/cinder/volume/drivers/nec/volume_helper.py index 05a374a59f7..dd60f7bf89c 100644 --- a/cinder/volume/drivers/nec/volume_helper.py +++ b/cinder/volume/drivers/nec/volume_helper.py @@ -1275,15 +1275,11 @@ class MStorageDriver(volume_common.MStorageVolumeCommon): else: ldn = lds[ldname]['ldn'] - lun = None - for ldset in ldsets.values(): - if ldn in ldset['lds']: - lun = ldset['lds'][ldn]['lun'] - break + ldset = self._validate_fcldset_exist(ldsets, connector) info = { 'driver_volume_type': 'fibre_channel', - 'data': {'target_lun': lun, + 'data': {'target_lun': ldset['lds'][ldn]['lun'], 'target_wwn': target_wwns, 'initiator_target_map': init_targ_map}} diff --git a/releasenotes/notes/bug-1887908-nec-live-migration-failure-withfc-3128fff7c48e739f.yaml b/releasenotes/notes/bug-1887908-nec-live-migration-failure-withfc-3128fff7c48e739f.yaml new file mode 100644 index 00000000000..34fce49ff5e --- /dev/null +++ b/releasenotes/notes/bug-1887908-nec-live-migration-failure-withfc-3128fff7c48e739f.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + `Bug #1887908 `_: + In NEC driver, fix live-migration failure with FC. +