Browse Source

NEC driver: fix a snapshot detach error

In NEC driver, _fc_terminate_connection() refers to
Volume.volume_attachment of an argument.
However, the argument is a snapshot object when a snapshot is being
detached.
The snapshot object does not have the "volume_attachment" attribute.

This patch avoids referring to the "volume_attachment" attribute when
the argument is a snapshot.

Change-Id: Ibc5fa0901ae9c0766f98d623357bade266598bff
Closes-Bug: #1887885
(cherry picked from commit 6e8dd2f0c0)
(cherry picked from commit 7e98b66a17)
tags/15.4.1
Naoki Saito 6 months ago
parent
commit
39905d5df3
4 changed files with 26 additions and 17 deletions
  1. +5
    -1
      cinder/tests/unit/volume/drivers/nec/test_volume.py
  2. +14
    -15
      cinder/volume/drivers/nec/volume_helper.py
  3. +1
    -1
      doc/source/reference/support-matrix.ini
  4. +6
    -0
      releasenotes/notes/bug-1887885-nec-fix-snapshot-detach-error-fff3012e0e9a2d2b.yaml

+ 5
- 1
cinder/tests/unit/volume/drivers/nec/test_volume.py View File

@@ -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')


+ 14
- 15
cinder/volume/drivers/nec/volume_helper.py View File

@@ -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


+ 1
- 1
doc/source/reference/support-matrix.ini View File

@@ -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


+ 6
- 0
releasenotes/notes/bug-1887885-nec-fix-snapshot-detach-error-fff3012e0e9a2d2b.yaml View File

@@ -0,0 +1,6 @@
---
fixes:
- |
`Bug #1887885 <https://bugs.launchpad.net/cinder/+bug/1887885>`_:
In NEC driver, fix a snapshot detach error.


Loading…
Cancel
Save