Skip to content

Commit 0dfe8de

Browse files
committed
Ensure that haproxy spawned by the metadata agents is active
In both neutron-metadata and neutron-ovn-metadata agents we should ensure that haproxy service spawned for network/router is actually active before moving on. This patch adds that check and this is similar to what was already implemented some time ago for the dnsmasq process spawned by the dhcp agent. Related-Bug: #2052787 Change-Id: Ic58640d89952fa03bd1059608ee6c9072fbaabf5 (cherry picked from commit 2f7f7c2)
1 parent 93cf601 commit 0dfe8de

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

neutron/agent/metadata/driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def spawn_monitored_metadata_proxy(cls, monitor, ns_name, port, conf,
270270
ns_name=ns_name,
271271
callback=callback)
272272
try:
273-
pm.enable()
273+
pm.enable(ensure_active=True)
274274
except exceptions.ProcessExecutionError as exec_err:
275275
LOG.error("Encountered process execution error %(err)s while "
276276
"starting process in namespace %(ns)s",

neutron/agent/ovn/metadata/driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def spawn_monitored_metadata_proxy(cls, monitor, ns_name, port, conf,
181181
ns_name=ns_name,
182182
callback=callback)
183183
try:
184-
pm.enable()
184+
pm.enable(ensure_active=True)
185185
except exceptions.ProcessExecutionError as exec_err:
186186
LOG.error("Encountered process execution error %(err)s while "
187187
"starting process in namespace %(ns)s",

neutron/tests/unit/agent/dhcp/test_agent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ def test_dhcp_ready_ports_updates_after_enable_dhcp(self, *args):
658658
'IpAddrCommand.wait_until_address_ready') as mock_wait:
659659
mock_wait.return_value = True
660660
dhcp = dhcp_agent.DhcpAgent(HOSTNAME)
661+
dhcp.update_isolated_metadata_proxy = mock.Mock()
661662
self.assertEqual(set(), dhcp.dhcp_ready_ports)
662663
dhcp.configure_dhcp_for_network(fake_network)
663664
self.assertEqual({fake_port1.id}, dhcp.dhcp_ready_ports)
@@ -854,7 +855,7 @@ def _enable_dhcp_helper(self, network, enable_isolated_metadata=False,
854855
is_ovn_network):
855856
process_instance.assert_has_calls([
856857
mock.call.disable(sig=str(int(signal.SIGTERM))),
857-
mock.call.enable()])
858+
mock.call.enable(ensure_active=True)])
858859
else:
859860
process_instance.assert_has_calls([
860861
mock.call.disable(sig=str(int(signal.SIGTERM)))])

neutron/tests/unit/agent/metadata/test_driver.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,12 @@ def _test_spawn_metadata_proxy(self, dad_failed=False):
171171
'IpAddrCommand.wait_until_address_ready') as mock_wait,\
172172
mock.patch(
173173
'neutron.agent.linux.ip_lib.'
174-
'delete_ip_address') as mock_del:
174+
'delete_ip_address') as mock_del,\
175+
mock.patch(
176+
'neutron.agent.linux.external_process.'
177+
'ProcessManager.active',
178+
new_callable=mock.PropertyMock,
179+
side_effect=[False, True]):
175180
agent = l3_agent.L3NATAgent('localhost')
176181
agent.process_monitor = mock.Mock()
177182
cfg_file = os.path.join(

neutron/tests/unit/agent/ovn/metadata/test_driver.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ def test_spawn_metadata_proxy(self):
7474
return_value=test_utils.FakeUser(self.EUNAME)),\
7575
mock.patch('grp.getgrnam',
7676
return_value=test_utils.FakeGroup(self.EGNAME)),\
77-
mock.patch('os.makedirs'):
77+
mock.patch('os.makedirs'),\
78+
mock.patch(
79+
'neutron.agent.linux.external_process.'
80+
'ProcessManager.active',
81+
new_callable=mock.PropertyMock,
82+
side_effect=[False, True]):
7883
cfg_file = os.path.join(
7984
metadata_driver.HaproxyConfigurator.get_config_path(
8085
cfg.CONF.state_path),

0 commit comments

Comments
 (0)