Merge "psec profile distributed locking"
This commit is contained in:
@@ -59,6 +59,7 @@ from oslo_utils import importutils
|
||||
from oslo_utils import uuidutils
|
||||
from vmware_nsx.common import config # noqa
|
||||
from vmware_nsx.common import exceptions as nsx_exc
|
||||
from vmware_nsx.common import locking
|
||||
from vmware_nsx.common import nsx_constants
|
||||
from vmware_nsx.common import utils
|
||||
from vmware_nsx.db import db as nsx_db
|
||||
@@ -194,9 +195,12 @@ class NsxV3Plugin(addr_pair_db.AllowedAddressPairsMixin,
|
||||
|
||||
@utils.retry_upon_exception_nsxv3(Exception)
|
||||
def _init_port_security_profile(self):
|
||||
# NOTE(boden): potential race cond with distributed plugins
|
||||
# whereupon a different plugin could create the profile
|
||||
# after we don't find an existing one and create another
|
||||
profile = self._get_port_security_profile()
|
||||
if profile:
|
||||
return profile
|
||||
|
||||
with locking.LockManager.get_lock('nsxv3_psec_profile_init'):
|
||||
# NOTE(boden): double-checked locking pattern
|
||||
profile = self._get_port_security_profile()
|
||||
if profile:
|
||||
return profile
|
||||
|
||||
@@ -80,6 +80,11 @@ class NsxV3PluginTestCaseMixin(test_plugin.NeutronDbPluginV2TestCase,
|
||||
if getattr(self.plugin, '_port_client', None):
|
||||
self.plugin._port_client._client._session = self.mock_api
|
||||
|
||||
mocked_locking = mock.patch.object(
|
||||
nsx_plugin, 'locking', new=mock.Mock())
|
||||
mocked_locking.start()
|
||||
self._patchers.append(mocked_locking)
|
||||
|
||||
self.maxDiff = None
|
||||
|
||||
def tearDown(self):
|
||||
|
||||
Reference in New Issue
Block a user