From 2f5ca655d694ec4d0d7337b379b4d0ff2c31cd3e Mon Sep 17 00:00:00 2001 From: yatinkarel Date: Fri, 24 Nov 2023 17:54:49 +0530 Subject: [PATCH] [DHCP agent] Fetch OVN Metadata port from plugin OVN metadata port from NetworkCache is being used and fixed_ips for it were not available at the time network was added into the cache. So let's re fetch it if it is available in the cache. Related-Bug: #1982569 Related-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=2213862 Change-Id: Ie0ec43566fa2b3e13b4917493336ce1519c9b6bb (cherry picked from commit 0afa24d9af9425036b452ca3ffac685f2a30d47d) --- neutron/agent/linux/dhcp.py | 3 ++- neutron/tests/unit/agent/linux/test_dhcp.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/neutron/agent/linux/dhcp.py b/neutron/agent/linux/dhcp.py index 0504fae8d04..3ae74f60592 100644 --- a/neutron/agent/linux/dhcp.py +++ b/neutron/agent/linux/dhcp.py @@ -1136,7 +1136,8 @@ class Dnsmasq(DhcpLocalProcess): m_ports = [port for port in self.network.ports if self._is_ovn_metadata_port(port, self.network.id)] if m_ports: - for fixed_ip in m_ports[0].fixed_ips: + port = self.device_manager.plugin.get_dhcp_port(m_ports[0].id) + for fixed_ip in port.fixed_ips: if fixed_ip.subnet_id == subnet.id: return fixed_ip.ip_address diff --git a/neutron/tests/unit/agent/linux/test_dhcp.py b/neutron/tests/unit/agent/linux/test_dhcp.py index 14814e62f8b..862de8c3775 100644 --- a/neutron/tests/unit/agent/linux/test_dhcp.py +++ b/neutron/tests/unit/agent/linux/test_dhcp.py @@ -3125,6 +3125,8 @@ class TestDnsmasq(TestBase): def test__generate_opts_per_subnet_with_metadata_port(self): config = {'enable_isolated_metadata': False, 'force_metadata': False} + self.mock_mgr.return_value.plugin.get_dhcp_port.return_value = \ + FakeOvnMetadataPort() self._test__generate_opts_per_subnet_helper(config, True, network_class=FakeNetworkDhcpandOvnMetadataPort)