From b06a885b7660e24b837595d5ff3ba14fcdba4ff3 Mon Sep 17 00:00:00 2001 From: Hong Hui Xiao Date: Thu, 29 Sep 2016 14:36:12 +0800 Subject: [PATCH] Check port existence before updating it in NB DB The logical port might already been deleted due to concurrent operation. DF mech_driver should check its existence before updating it. Change-Id: I110b4d3adcd5c169a65917422c1f2c8fc3bac993 Close-Bug: #1628408 --- dragonflow/neutron/ml2/mech_driver.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dragonflow/neutron/ml2/mech_driver.py b/dragonflow/neutron/ml2/mech_driver.py index 08831b0c4..b9178eb96 100644 --- a/dragonflow/neutron/ml2/mech_driver.py +++ b/dragonflow/neutron/ml2/mech_driver.py @@ -567,6 +567,12 @@ class DFMechDriver(driver_api.MechanismDriver): @lock_db.wrap_db_lock(lock_db.RESOURCE_ML2_CORE) def update_port_postcommit(self, context): updated_port = context.current + if not self.nb_api.get_logical_port(updated_port['id'], + updated_port['tenant_id']): + # REVISIT(xiaohhui): Should we unify the check before update nb db? + LOG.debug("The port %s has been deleted from dragonflow NB DB, " + "by concurrent operation.", updated_port['id']) + return # If a subnet enabled dhcp, the DFMechDriver will create a dhcp server # port. When delete this subnet, the port should be deleted.