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