NetApp ONTAP: Fix export path used as volume name

On ONTAP NFS driver, the export path was being used as the volume
name. If the export path is different than the volume name, the
API call to delete files would fail and the driver would invoke
a fallback method that deletes the files manually. This patch fixes
that by finding the correct volume name.

Change-Id: Ice78889573a36ff5e8873a0d316ddcf180d0263f
Closes-bug: #1690954
This commit is contained in:
tpsilva 2018-04-04 13:24:33 -03:00 committed by Tiago Pasqualini da Silva
parent fb257890eb
commit 4d75cbf3c3
3 changed files with 20 additions and 3 deletions

View File

@ -597,12 +597,21 @@ class NetAppCmodeNfsDriverTestCase(test.TestCase):
def test_delete_file(self):
mock_get_vs_ip = self.mock_object(self.driver, '_get_export_ip_path')
mock_get_vs_ip.return_value = (fake.VSERVER_NAME, '/%s' % fake.FLEXVOL)
mock_get_vs_ip.return_value = (fake.SHARE_IP, fake.EXPORT_PATH)
mock_get_vserver = self.mock_object(self.driver, '_get_vserver_for_ip')
mock_get_vserver.return_value = fake.VSERVER_NAME
mock_zapi_get_vol = self.driver.zapi_client.get_vol_by_junc_vserver
mock_zapi_get_vol.return_value = fake.FLEXVOL
mock_zapi_delete = self.driver.zapi_client.delete_file
self.driver._delete_file(
fake.test_snapshot['volume_id'], fake.test_snapshot['name'])
mock_get_vs_ip.assert_called_once_with(
volume_id=fake.test_snapshot['volume_id'])
mock_get_vserver.assert_called_once_with(fake.SHARE_IP)
mock_zapi_get_vol.assert_called_once_with(
fake.VSERVER_NAME, fake.EXPORT_PATH)
mock_zapi_delete.assert_called_once_with(
'/vol/%s/%s' % (fake.FLEXVOL, fake.test_snapshot['name']))

View File

@ -434,8 +434,11 @@ class NetAppCmodeNfsDriver(nfs_base.NetAppNfsDriver,
'%s was unsuccessful.', volume['id'])
def _delete_file(self, file_id, file_name):
(_vserver, flexvol) = self._get_export_ip_path(volume_id=file_id)
path_on_backend = '/vol' + flexvol + '/' + file_name
(host_ip, junction_path) = self._get_export_ip_path(volume_id=file_id)
vserver = self._get_vserver_for_ip(host_ip)
flexvol = self.zapi_client.get_vol_by_junc_vserver(
vserver, junction_path)
path_on_backend = '/vol/' + flexvol + '/' + file_name
LOG.debug('Attempting to delete file %(path)s for ID %(file_id)s on '
'backend.', {'path': path_on_backend, 'file_id': file_id})
self.zapi_client.delete_file(path_on_backend)

View File

@ -0,0 +1,5 @@
---
fixes:
- |
NetApp ONTAP NFS (bug 1690954): Fix wrong usage of export path
as volume name when deleting volumes and snapshots.