Currently delete_csnat_router_interface_ports provides an iterator as
filter to core_plugin.get_ports which is used in a SQL IN argument.
SQLAlchemy is able to avoid some db queries when the IN argument is
empty BUT not when the argument is an empty iterator and raises the
warning:
SAWarning: The IN-predicate on "ports.id" was invoked with an empty
sequence. This results in a contradiction, which nonetheless can be
expensive to evaluate. Consider alternative strategies for improved
performance.
This change replaces the iterator by a list in order to optimize db
queries when the filter is empty.
Closes-Bug: #
1503852
Change-Id: I4f53433d688dfa020927118a18020b1a6aa55517
# TODO(markmcclain): This is suboptimal but was left to reduce
# changeset size since it is late in cycle
- ports = (
+ ports = [
rp.port.id for rp in
router.attached_ports.filter_by(
port_type=l3_const.DEVICE_OWNER_ROUTER_SNAT)
if rp.port
- )
+ ]
c_snat_ports = self._core_plugin.get_ports(
context,