diff --git a/cinder/tests/unit/volume/drivers/nec/test_volume.py b/cinder/tests/unit/volume/drivers/nec/test_volume.py index b4640cb21f6..363445df672 100644 --- a/cinder/tests/unit/volume/drivers/nec/test_volume.py +++ b/cinder/tests/unit/volume/drivers/nec/test_volume.py @@ -1350,8 +1350,12 @@ class NonDisruptiveBackup_test(volume_helper.MStorageDSVDriver, attachment = volume_attachment.VolumeAttachmentList( objects=[attach_object]) snap.volume_attachment = attachment - ret = self.fc_terminate_connection_snapshot(snap, connector) + mocker = self.mock_object(self, '_is_multi_attachment', + mock.Mock(wraps=self._is_multi_attachment)) + ret = self.fc_terminate_connection_snapshot(snap, connector, + is_snapshot=True) self.assertEqual('fibre_channel', ret['driver_volume_type']) + mocker.assert_not_called() def test_remove_export_snapshot(self): snap = DummySnapshot('46045673-41e7-44a7-9333-02f07feab04b') diff --git a/cinder/volume/drivers/nec/volume_helper.py b/cinder/volume/drivers/nec/volume_helper.py index 440c6be9bfe..6b8a2b5738b 100644 --- a/cinder/volume/drivers/nec/volume_helper.py +++ b/cinder/volume/drivers/nec/volume_helper.py @@ -24,6 +24,7 @@ from oslo_utils import units from cinder import coordination from cinder import exception from cinder.i18n import _ +from cinder import utils from cinder.volume.drivers.nec import cli from cinder.volume.drivers.nec import volume_common from cinder.volume import volume_utils @@ -1324,14 +1325,12 @@ class MStorageDriver(volume_common.MStorageVolumeCommon): '(%(msgparm)s) (%(exception)s)', {'msgparm': msgparm, 'exception': e}) - def _fc_terminate_connection(self, volume, connector): + @utils.trace + def _fc_terminate_connection(self, vol_or_snap, connector, + is_snapshot=False): """Disallow connection from connector.""" - LOG.debug('_fc_terminate_connection' - '(Volume ID = %(id)s, connector = %(connector)s) Start.', - {'id': volume.id, 'connector': connector}) - - if connector is not None and ( - self._is_multi_attachment(volume, connector)): + if not is_snapshot and connector is not None and ( + self._is_multi_attachment(vol_or_snap, connector)): return xml = self._cli.view_all(self._properties['ismview_path']) @@ -1353,10 +1352,15 @@ class MStorageDriver(volume_common.MStorageVolumeCommon): info['data'] = {'target_wwn': target_wwns, 'initiator_target_map': init_targ_map} + if is_snapshot: + # Detaching the snapshot is performed in the + # remove_export_snapshot. + return info + if connector is not None and self._properties['ldset_name'] == '': # delete LD from LD set. ldname = self.get_ldname( - volume.id, self._properties['ld_name_format']) + vol_or_snap.id, self._properties['ld_name_format']) if ldname not in lds: LOG.debug('Logical Disk `%s` has unbound already.', ldname) return info @@ -1373,19 +1377,14 @@ class MStorageDriver(volume_common.MStorageVolumeCommon): 'Logical Disk Set (%s)') % errnum) raise exception.VolumeBackendAPIException(data=msg) - LOG.debug('_fc_terminate_connection' - '(Volume ID = %(id)s, connector = %(connector)s, ' - 'info = %(info)s) End.', - {'id': volume.id, - 'connector': connector, - 'info': info}) return info def fc_terminate_connection_snapshot(self, snapshot, connector, **kwargs): msgparm = ('Volume ID = %(id)s, Connector = %(connector)s' % {'id': snapshot.id, 'connector': connector}) try: - ret = self._fc_terminate_connection(snapshot, connector) + ret = self._fc_terminate_connection(snapshot, connector, + is_snapshot=True) LOG.info('Terminated FC Connection snapshot(%s)', msgparm) self.remove_export_snapshot(None, snapshot) return ret diff --git a/doc/source/reference/support-matrix.ini b/doc/source/reference/support-matrix.ini index 985c041550f..b9cad7c7d73 100644 --- a/doc/source/reference/support-matrix.ini +++ b/doc/source/reference/support-matrix.ini @@ -374,7 +374,7 @@ driver.lenovo=missing driver.linbit_linstor=missing driver.lvm=missing driver.macrosan=missing -driver.nec=missing +driver.nec=complete driver.netapp_ontap=missing driver.netapp_solidfire=missing driver.nexenta=missing diff --git a/releasenotes/notes/bug-1887885-nec-fix-snapshot-detach-error-fff3012e0e9a2d2b.yaml b/releasenotes/notes/bug-1887885-nec-fix-snapshot-detach-error-fff3012e0e9a2d2b.yaml new file mode 100644 index 00000000000..51a8ee51db5 --- /dev/null +++ b/releasenotes/notes/bug-1887885-nec-fix-snapshot-detach-error-fff3012e0e9a2d2b.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + `Bug #1887885 `_: + In NEC driver, fix a snapshot detach error. +