NSX|V: ensure that router updates are atomic

Make sure that router updates are atomic. This could prevent edge
cases for example of updating a router and then updating a router
type.

The lock with be of the format router-<UUID of router>

Change-Id: I95e78d420d57b514837cf2bfd300f0a6f235c2f6
(cherry picked from commit c4298cd368)
This commit is contained in:
Gary Kotton 2017-07-15 21:25:09 +03:00 committed by garyk
parent 908121c825
commit 682e0de44b
1 changed files with 4 additions and 0 deletions

View File

@ -2849,6 +2849,10 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
raise n_exc.InvalidInput(error_message=err_msg)
def update_router(self, context, router_id, router):
with locking.LockManager.get_lock('router-%s' % router_id):
return self._safe_update_router(context, router_id, router)
def _safe_update_router(self, context, router_id, router):
# Validate that the gateway information is relevant
self._extract_external_gw(context, router, is_extract=False)
# Toggling the distributed flag is not supported