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 2f7f7c2fc2)
This commit is contained in:
Slawek Kaplonski 2024-02-22 10:06:58 +01:00
parent 93cf601354
commit 0dfe8dedd6
5 changed files with 16 additions and 5 deletions

View File

@ -270,7 +270,7 @@ class MetadataDriver(object):
ns_name=ns_name,
callback=callback)
try:
pm.enable()
pm.enable(ensure_active=True)
except exceptions.ProcessExecutionError as exec_err:
LOG.error("Encountered process execution error %(err)s while "
"starting process in namespace %(ns)s",

View File

@ -181,7 +181,7 @@ class MetadataDriver(object):
ns_name=ns_name,
callback=callback)
try:
pm.enable()
pm.enable(ensure_active=True)
except exceptions.ProcessExecutionError as exec_err:
LOG.error("Encountered process execution error %(err)s while "
"starting process in namespace %(ns)s",

View File

@ -658,6 +658,7 @@ class TestDhcpAgent(base.BaseTestCase):
'IpAddrCommand.wait_until_address_ready') as mock_wait:
mock_wait.return_value = True
dhcp = dhcp_agent.DhcpAgent(HOSTNAME)
dhcp.update_isolated_metadata_proxy = mock.Mock()
self.assertEqual(set(), dhcp.dhcp_ready_ports)
dhcp.configure_dhcp_for_network(fake_network)
self.assertEqual({fake_port1.id}, dhcp.dhcp_ready_ports)
@ -854,7 +855,7 @@ class TestDhcpAgentEventHandler(base.BaseTestCase):
is_ovn_network):
process_instance.assert_has_calls([
mock.call.disable(sig=str(int(signal.SIGTERM))),
mock.call.enable()])
mock.call.enable(ensure_active=True)])
else:
process_instance.assert_has_calls([
mock.call.disable(sig=str(int(signal.SIGTERM)))])

View File

@ -171,7 +171,12 @@ class TestMetadataDriverProcess(base.BaseTestCase):
'IpAddrCommand.wait_until_address_ready') as mock_wait,\
mock.patch(
'neutron.agent.linux.ip_lib.'
'delete_ip_address') as mock_del:
'delete_ip_address') as mock_del,\
mock.patch(
'neutron.agent.linux.external_process.'
'ProcessManager.active',
new_callable=mock.PropertyMock,
side_effect=[False, True]):
agent = l3_agent.L3NATAgent('localhost')
agent.process_monitor = mock.Mock()
cfg_file = os.path.join(

View File

@ -74,7 +74,12 @@ class TestMetadataDriverProcess(base.BaseTestCase):
return_value=test_utils.FakeUser(self.EUNAME)),\
mock.patch('grp.getgrnam',
return_value=test_utils.FakeGroup(self.EGNAME)),\
mock.patch('os.makedirs'):
mock.patch('os.makedirs'),\
mock.patch(
'neutron.agent.linux.external_process.'
'ProcessManager.active',
new_callable=mock.PropertyMock,
side_effect=[False, True]):
cfg_file = os.path.join(
metadata_driver.HaproxyConfigurator.get_config_path(
cfg.CONF.state_path),