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
This commit is contained in:
Hong Hui Xiao 2016-09-29 14:36:12 +08:00
parent cf7369d5ce
commit b06a885b76
1 changed files with 6 additions and 0 deletions

View File

@ -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.