[NetApp] Fix race condition issues on vserver deletion

This patch updates the NetApp driver handling with an issue that
happens when the driver tries to delete the vserver, during a
rollback operation inside the vserver creation method.

Change-Id: I0c8468c72e15c1d27f5cdfa50cfc379a9207c5f1
Closes-bug: #1831092
This commit is contained in:
arthurnsantos 2019-05-14 17:08:23 -03:00 committed by Douglas Viroel
parent 2609950d1e
commit 4fbf1a2d9d
3 changed files with 21 additions and 5 deletions

View File

@ -212,8 +212,11 @@ class NetAppCmodeMultiSVMFileStorageLibrary(
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.error("Failed to configure Vserver.") LOG.error("Failed to configure Vserver.")
# NOTE(dviroel): At this point, the lock was already acquired
# by the caller of _create_vserver.
self._delete_vserver(vserver_name, self._delete_vserver(vserver_name,
security_services=security_services) security_services=security_services,
needs_lock=False)
def _get_valid_ipspace_name(self, network_id): def _get_valid_ipspace_name(self, network_id):
"""Get IPspace name according to network id.""" """Get IPspace name according to network id."""
@ -357,7 +360,8 @@ class NetAppCmodeMultiSVMFileStorageLibrary(
self._delete_vserver(vserver, security_services=security_services) self._delete_vserver(vserver, security_services=security_services)
@na_utils.trace @na_utils.trace
def _delete_vserver(self, vserver, security_services=None): def _delete_vserver(self, vserver, security_services=None,
needs_lock=True):
"""Delete a Vserver plus IPspace and security services as needed.""" """Delete a Vserver plus IPspace and security services as needed."""
ipspace_name = self._client.get_vserver_ipspace(vserver) ipspace_name = self._client.get_vserver_ipspace(vserver)
@ -378,8 +382,7 @@ class NetAppCmodeMultiSVMFileStorageLibrary(
else: else:
vlan_id = None vlan_id = None
@utils.synchronized('netapp-VLAN-%s' % vlan_id, external=True) def _delete_vserver_without_lock():
def _delete_vserver_with_lock():
self._client.delete_vserver(vserver, self._client.delete_vserver(vserver,
vserver_client, vserver_client,
security_services=security_services) security_services=security_services)
@ -390,7 +393,14 @@ class NetAppCmodeMultiSVMFileStorageLibrary(
self._delete_vserver_vlans(interfaces_on_vlans) self._delete_vserver_vlans(interfaces_on_vlans)
return _delete_vserver_with_lock() @utils.synchronized('netapp-VLAN-%s' % vlan_id, external=True)
def _delete_vserver_with_lock():
_delete_vserver_without_lock()
if needs_lock:
return _delete_vserver_with_lock()
else:
return _delete_vserver_without_lock()
@na_utils.trace @na_utils.trace
def _delete_vserver_vlans(self, network_interfaces_on_vlans): def _delete_vserver_vlans(self, network_interfaces_on_vlans):

View File

@ -522,6 +522,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
fake.IPSPACE) fake.IPSPACE)
self.library._delete_vserver.assert_called_once_with( self.library._delete_vserver.assert_called_once_with(
vserver_name, vserver_name,
needs_lock=False,
security_services=None) security_services=None)
self.assertFalse(vserver_client.enable_nfs.called) self.assertFalse(vserver_client.enable_nfs.called)
self.assertEqual(1, lib_multi_svm.LOG.error.call_count) self.assertEqual(1, lib_multi_svm.LOG.error.call_count)

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixed an issue with the NetApp driver failing during a rollback operation
in the share server creation.