ovn: Don't use dict.remove() for filtering dhcp ports in db-sync

The db-sync script removes ovnmeta ports because sometimes removing
reserved_dhcp_port in the loop doesn't work.

Change-Id: I78673b6a85f1c872e70026da82124d1ba2326562
Signed-off-by: Jakub Libosvar <libosvar@redhat.com>
This commit is contained in:
Jakub Libosvar 2021-05-02 13:40:38 +02:00
parent d6d6855234
commit 0aab51c9f8
1 changed files with 10 additions and 10 deletions

View File

@ -890,16 +890,16 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
# TODO(mjozefcz): Remove constants.DEVICE_OWNER_DHCP
# from get_ports in W-release.
for net in self.core_plugin.get_networks(ctx):
dhcp_ports = self.core_plugin.get_ports(ctx, filters=dict(
network_id=[net['id']],
device_owner=[
constants.DEVICE_OWNER_DISTRIBUTED,
constants.DEVICE_OWNER_DHCP]))
for port in dhcp_ports:
# Do not touch the Neutron DHCP agents ports
if utils.is_neutron_dhcp_agent_port(port):
dhcp_ports.remove(port)
# Get only DHCP ports that don't belong to agent, it should return
# only OVN metadata ports
dhcp_ports = [
p for p in self.core_plugin.get_ports(
ctx, filters=dict(
network_id=[net['id']],
device_owner=[
constants.DEVICE_OWNER_DISTRIBUTED,
constants.DEVICE_OWNER_DHCP]))
if not utils.is_neutron_dhcp_agent_port(p)]
if not dhcp_ports:
LOG.warning('Missing metadata port found in Neutron for '