Fix code that's trying to read from a stale DB object

Change-Id: Ib601235b56c553c29618a4dfdf0608a7b2784c6f
Closes-Bug: #1594376
Carl Baldwin 2016-06-23 15:39:47 -06:00
parent 7245b172b0
commit dfbe1fb7c5
1 changed files with 6 additions and 3 deletions

View File

@ -1053,13 +1053,16 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
for ip in a.port.fixed_ips
if ip.subnet_id != id]}}
self.update_port(context, a.port_id, data)
# NOTE Don't inline port_id; needed for PortNotFound.
port_id = a.port_id
self.update_port(context, port_id, data)
except exc.PortNotFound:
LOG.debug("Port %s deleted concurrently", a.port_id)
# NOTE Attempting to access a.port_id here is an error.
LOG.debug("Port %s deleted concurrently", port_id)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Exception deleting fixed_ip "
"from port %s"), a.port_id)
"from port %s"), port_id)