]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
ipam: Prevent none from being passed to delete
authorAaron Rosen <aaronorosen@gmail.com>
Wed, 16 Sep 2015 22:50:21 +0000 (15:50 -0700)
committerAaron Rosen <aaronorosen@gmail.com>
Wed, 16 Sep 2015 22:50:21 +0000 (15:50 -0700)
Previously, it was possible for None to be passed to context.session.delete()
if a port was not found (usually a result of a concurrent delete). This
resulted in an UnmappedInstanceError. This is avoided now by calling
query.delete() directly which does not raise any exceptions.

Change-Id: I3b9f513308d90874ac8e8a7f6345697978d4920f
Closes-bug: #1496554

neutron/db/ipam_backend_mixin.py

index d6adf01fb251daf6b037c76d0582e17aee4b9585..3806cb040b79f4c2243c63ac8675225a9e252f7f 100644 (file)
@@ -414,7 +414,7 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon):
                  enable_eagerloads(False).filter_by(id=port_id))
         if not context.is_admin:
             query = query.filter_by(tenant_id=context.tenant_id)
-        context.session.delete(query.first())
+        query.delete(synchronize_session=False)
 
     def _save_subnet(self, context,
                      network,