From 4d75cbf3c35a8aa917d3970beac99d612f13eed3 Mon Sep 17 00:00:00 2001 From: tpsilva Date: Wed, 4 Apr 2018 13:24:33 -0300 Subject: [PATCH] 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 --- .../volume/drivers/netapp/dataontap/test_nfs_cmode.py | 11 ++++++++++- cinder/volume/drivers/netapp/dataontap/nfs_cmode.py | 7 +++++-- releasenotes/notes/bug-1690954-40fc21683977e996.yaml | 5 +++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/bug-1690954-40fc21683977e996.yaml diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py index d14264a694a..9cadf9bce75 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py @@ -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'])) diff --git a/cinder/volume/drivers/netapp/dataontap/nfs_cmode.py b/cinder/volume/drivers/netapp/dataontap/nfs_cmode.py index fd1d1c6a61a..5b06ec54389 100644 --- a/cinder/volume/drivers/netapp/dataontap/nfs_cmode.py +++ b/cinder/volume/drivers/netapp/dataontap/nfs_cmode.py @@ -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) diff --git a/releasenotes/notes/bug-1690954-40fc21683977e996.yaml b/releasenotes/notes/bug-1690954-40fc21683977e996.yaml new file mode 100644 index 00000000000..14b556a87cf --- /dev/null +++ b/releasenotes/notes/bug-1690954-40fc21683977e996.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + NetApp ONTAP NFS (bug 1690954): Fix wrong usage of export path + as volume name when deleting volumes and snapshots.