[SVF]:Fix in change_vdisk_iogrp during retype

[Spectrum Virtualize Family] Fixed issues in change_vdisk_iogrp.
During retyping a volume between I/O groups, if addvdiskaccess fails
an exception is raised and if movevdisk fails rmvdiskaccess should be
done for new I/O group before failing the retype operation.

Closes bug: #1896214

Change-Id: Ic1f770a7c7850c9897f42999968820eac4d6ed47
This commit is contained in:
sharathkacham 2020-09-30 09:01:52 +00:00
parent a9bc7dd6c5
commit 1145569343
3 changed files with 105 additions and 1 deletions

View File

@ -8201,6 +8201,92 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
delete_vdisk.assert_has_calls(calls, any_order=True)
def test_storwize_svc_retype_between_iogrps(self):
self.driver.do_setup(None)
ctxt = context.get_admin_context()
key_specs_old = {'iogrp': 0}
key_specs_new = {'iogrp': 1}
old_type_ref = volume_types.create(ctxt, 'old', key_specs_old)
new_type_ref = volume_types.create(ctxt, 'new', key_specs_new)
diff, _equal = volume_types.volume_types_diff(ctxt, old_type_ref['id'],
new_type_ref['id'])
old_type = objects.VolumeType.get_by_id(ctxt,
old_type_ref['id'])
volume = self._generate_vol_info(old_type)
new_type = objects.VolumeType.get_by_id(ctxt,
new_type_ref['id'])
self.driver.create_volume(volume)
conn = {'initiator': u'iqn.1993-08.org.debian:01:eac5ccc1aaa',
'ip': '10.10.10.12',
'host': u'openstack@svc#openstack'}
self.driver.initialize_connection(volume, conn)
loc = ('StorwizeSVCDriver:' + self.driver._state['system_id'] +
':openstack2')
cap = {'location_info': loc, 'extent_size': '128'}
host_name = self.driver._helpers.get_host_from_connector(
conn, iscsi=True)
self.assertIsNotNone(host_name)
host = {'host': host_name, 'capabilities': cap}
volume['host'] = host['host']
self.driver.retype(ctxt, volume, new_type, diff, host)
attrs = self.driver._helpers.get_vdisk_attributes(volume['name'])
self.assertEqual('1', attrs['IO_group_id'], 'Volume retype '
'failed')
@mock.patch.object(storwize_svc_common.StorwizeSSH, 'addvdiskaccess')
@mock.patch.object(storwize_svc_common.StorwizeSSH, 'rmvdiskaccess')
@mock.patch.object(storwize_svc_common.StorwizeSSH, 'movevdisk')
def test_storwize_svc_retype_between_iogrps_invalid(
self, movevdisk, rmvdiskaccess, addvdiskaccess):
self.driver.do_setup(None)
ctxt = context.get_admin_context()
key_specs_old = {'iogrp': 0}
key_specs_new = {'iogrp': 1}
old_type_ref = volume_types.create(ctxt, 'old', key_specs_old)
new_type_ref = volume_types.create(ctxt, 'new', key_specs_new)
diff, _equal = volume_types.volume_types_diff(ctxt, old_type_ref['id'],
new_type_ref['id'])
old_type = objects.VolumeType.get_by_id(ctxt,
old_type_ref['id'])
volume = self._generate_vol_info(old_type)
new_type = objects.VolumeType.get_by_id(ctxt,
new_type_ref['id'])
self.driver.create_volume(volume)
conn = {'initiator': u'iqn.1993-08.org.debian:01:eac5ccc1aaa',
'ip': '10.10.10.12',
'host': u'openstack@svc#openstack'}
self.driver.initialize_connection(volume, conn)
loc = ('StorwizeSVCDriver:' + self.driver._state['system_id'] +
':openstack2')
cap = {'location_info': loc, 'extent_size': '128'}
host_name = self.driver._helpers.get_host_from_connector(
conn, iscsi=True)
self.assertIsNotNone(host_name)
host = {'host': host_name, 'capabilities': cap}
volume['host'] = host['host']
ex = exception.VolumeBackendAPIException(data='CMMVC5879E')
movevdisk.side_effect = ex
self.assertRaises(exception.VolumeBackendAPIException,
self.driver.retype, ctxt,
volume, new_type, diff, host)
attrs = self.driver._helpers.get_vdisk_attributes(volume['name'])
self.assertEqual(int(key_specs_old['iogrp']),
int(attrs['IO_group_id']), 'Volume retype failed')
addvdiskaccess.assert_called()
movevdisk.assert_called()
rmvdiskaccess.assert_called_with(
volume['name'], str(key_specs_new['iogrp']))
class CLIResponseTestCase(test.TestCase):
def test_empty(self):

View File

@ -2480,8 +2480,17 @@ class StorwizeHelpers(object):
'%(code_level)s, below the required 6.4.0.0.',
{'code_level': state['code_level']})
else:
self.ssh.movevdisk(vdisk, str(iogrp[0]))
self.ssh.addvdiskaccess(vdisk, str(iogrp[0]))
try:
self.ssh.movevdisk(vdisk, str(iogrp[0]))
except exception.VolumeBackendAPIException as e:
self.ssh.rmvdiskaccess(vdisk, str(iogrp[0]))
msg = (_('movevdisk command failed for %(vdisk),'
'performing rmdiskaccess for %(iogrp)s.'
'Exception: %(err)s.'),
{'vdisk': vdisk, 'iogrp': iogrp[0], 'err': e})
LOG.exception(msg)
raise exception.VolumeBackendAPIException(data=msg)
self.ssh.rmvdiskaccess(vdisk, str(iogrp[1]))
def vdisk_by_uid(self, vdisk_uid):

View File

@ -0,0 +1,9 @@
---
fixes:
- |
IBM Spectrum Virtualize Family `Bug #1896214
<https://bugs.launchpad.net/cinder/+bug/1896214>`_:
Fixed issues in change_vdisk_iogrp.
During retyping a volume between I/O groups, if addvdiskaccess fails
an exception is raised and if movevdisk fails rmvdiskaccess should be
done for new I/O group before failing the retype operation.