NetApp ONTAP: Fix QoS lost after moving volume

When a Cinder volume is created with a volume-type associated to a QoS
entity, the driver creates a QoS policy group at the ONTAP back end, and
associates it to the entity representing the Cinder volume (either a LUN
or a file within an NFS share).

On NetApp NFS, when a migrate operation is issued and it completes, the
resulting volume ends up without a QoS.  That happens because the file
is being renamed while the QoS refers to the now non-existent file.

This patch makes it so that the file is not renamed when finishing a
migration and the driver code uses the ``name_id`` attribute instead of
the ``id`` one to refer to the right UUID.

Closes-Bug: #1906291
Change-Id: Icd7a929e7cbce0c74f6b340f4e09f74a8098d752
This commit is contained in:
Gorka Eguileor 2020-12-09 21:03:49 +01:00
parent 7c4b626c01
commit da100e1fca
6 changed files with 44 additions and 13 deletions

View File

@ -1161,3 +1161,9 @@ class NetAppNfsDriverTestCase(test.TestCase):
def test__is_flexgroup_clone_file_supported(self):
self.assertRaises(NotImplementedError,
self.driver._is_flexgroup_clone_file_supported)
def test_update_migrated_volume(self):
self.assertRaises(NotImplementedError,
self.driver.update_migrated_volume, self.ctxt,
fake.test_volume, mock.sentinel.new_volume,
mock.sentinel.original_status)

View File

@ -16,6 +16,7 @@
# under the License.
from cinder.tests.unit import fake_volume
from cinder.volume import configuration as conf
import cinder.volume.drivers.netapp.options as na_opts
@ -71,13 +72,12 @@ VOLUME_NAME = 'fake_volume_name'
VOLUME_ID = 'fake_volume_id'
VOLUME_TYPE_ID = 'fake_volume_type_id'
VOLUME = {
'name': VOLUME_NAME,
'size': 42,
'id': VOLUME_ID,
'host': 'fake_host@fake_backend#fake_pool',
'volume_type_id': VOLUME_TYPE_ID,
}
VOLUME = fake_volume.fake_volume_obj(None,
name=VOLUME_NAME,
size=42,
id=VOLUME_ID,
host='fake_host@fake_backend#fake_pool',
volume_type_id=VOLUME_TYPE_ID)
SNAPSHOT_NAME = 'fake_snapshot_name'
SNAPSHOT_ID = 'fake_snapshot_id'

View File

@ -557,13 +557,24 @@ class NetAppDriverUtilsTestCase(test.TestCase):
self.assertEqual(expected, result)
def test_get_qos_policy_group_name_no_id(self):
volume = copy.deepcopy(fake.VOLUME)
del(volume['id'])
result = na_utils.get_qos_policy_group_name(volume)
delattr(fake.VOLUME, '_obj_id')
try:
result = na_utils.get_qos_policy_group_name(fake.VOLUME)
finally:
fake.VOLUME._obj_id = fake.VOLUME_ID
self.assertIsNone(result)
def test_get_qos_policy_group_name_migrated_volume(self):
fake.VOLUME._name_id = 'asdf'
try:
expected = 'openstack-' + fake.VOLUME.name_id
result = na_utils.get_qos_policy_group_name(fake.VOLUME)
finally:
fake.VOLUME._name_id = None
self.assertEqual(expected, result)
def test_get_qos_policy_group_name_from_info(self):
expected = 'openstack-%s' % fake.VOLUME_ID
result = na_utils.get_qos_policy_group_name_from_info(

View File

@ -1223,3 +1223,10 @@ class NetAppNfsDriver(driver.ManageableVD,
def _is_flexgroup_clone_file_supported(self):
"""Check whether storage can perform clone file for FlexGroup"""
raise NotImplementedError()
def update_migrated_volume(self, ctxt, volume, new_volume,
original_volume_status):
# Implemented to prevent NFSDriver's implementation renaming the file
# and breaking volume's backend QoS.
msg = _("The method update_migrated_volume is not implemented.")
raise NotImplementedError(msg)

View File

@ -390,7 +390,7 @@ def map_dict_to_lower(input_dict):
def get_qos_policy_group_name(volume):
"""Return the name of backend QOS policy group based on its volume id."""
if 'id' in volume:
return OPENSTACK_PREFIX + volume['id']
return OPENSTACK_PREFIX + volume.name_id
return None
@ -437,7 +437,7 @@ def get_valid_qos_policy_group_info(volume, extra_specs=None):
info = dict(legacy=None, spec=None)
try:
volume_type = get_volume_type_from_volume(volume)
except KeyError:
except (KeyError, exception.NotFound):
LOG.exception('Cannot get QoS spec for volume %s.', volume['id'])
return info
if volume_type is None:

View File

@ -0,0 +1,7 @@
---
fixes:
- |
NetApp ONTAP `bug #1906291
<https://bugs.launchpad.net/cinder/+bug/1906291>`_: Fix volume losing its
QoS policy on the backend after moving it (migrate or retype with migrate)
to a NetApp NFS backend.