NSX|V: ensures updates on subnet are atomic

Serialize subnet updates by locking the specific subnet for
updates

Change-Id: I07efd70e934fd999c5374582a84c0656062257d1
This commit is contained in:
Gary Kotton 2017-08-01 14:06:56 +03:00
parent 3d89d25667
commit f34a7b3264
1 changed files with 6 additions and 0 deletions

View File

@ -2503,6 +2503,12 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
router_driver._update_nexthop(context, router_id, new_gateway)
def update_subnet(self, context, id, subnet):
# Lock the subnet so that no other conflicting action can occur on
# the same subnet
with locking.LockManager.get_lock('subnet-%s' % id):
return self._safe_update_subnet(context, id, subnet)
def _safe_update_subnet(self, context, id, subnet):
s = subnet['subnet']
orig = self._get_subnet(context, id)
gateway_ip = orig['gateway_ip']