Skip to content

Commit aedb872

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. Conflicts: neutron/tests/unit/agent/dhcp/test_agent.py Related-Bug: #2052787 Change-Id: Ic58640d89952fa03bd1059608ee6c9072fbaabf5 (cherry picked from commit 2f7f7c2) (cherry picked from commit 0dfe8de)
1 parent 85debdd commit aedb872

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
@@ -295,7 +295,7 @@ def spawn_monitored_metadata_proxy(cls, monitor, ns_name, port, conf,
295295
ns_name=ns_name,
296296
callback=callback)
297297
try:
298-
pm.enable()
298+
pm.enable(ensure_active=True)
299299
except exceptions.ProcessExecutionError as exec_err:
300300
LOG.error("Encountered process execution error %(err)s while "
301301
"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
@@ -206,7 +206,7 @@ def spawn_monitored_metadata_proxy(cls, monitor, ns_name, port, conf,
206206
ns_name=ns_name,
207207
callback=callback)
208208
try:
209-
pm.enable()
209+
pm.enable(ensure_active=True)
210210
except exceptions.ProcessExecutionError as exec_err:
211211
LOG.error("Encountered process execution error %(err)s while "
212212
"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
@@ -637,6 +637,7 @@ def test_dhcp_ready_ports_updates_after_enable_dhcp(self, *args):
637637
'IpAddrCommand.wait_until_address_ready') as mock_wait:
638638
mock_wait.return_value = True
639639
dhcp = dhcp_agent.DhcpAgent(HOSTNAME)
640+
dhcp.update_isolated_metadata_proxy = mock.Mock()
640641
self.assertEqual(set(), dhcp.dhcp_ready_ports)
641642
dhcp.configure_dhcp_for_network(fake_network)
642643
self.assertEqual({fake_port1.id}, dhcp.dhcp_ready_ports)
@@ -834,7 +835,7 @@ def _enable_dhcp_helper(self, network, enable_isolated_metadata=False,
834835
process_instance.assert_has_calls([
835836
mock.call.disable(sig=str(int(signal.SIGTERM))),
836837
mock.call.get_pid_file_name(),
837-
mock.call.enable()])
838+
mock.call.enable(ensure_active=True)])
838839
else:
839840
process_instance.assert_has_calls([
840841
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
@@ -168,7 +168,12 @@ def _test_spawn_metadata_proxy(self, dad_failed=False):
168168
'IpAddrCommand.wait_until_address_ready') as mock_wait,\
169169
mock.patch(
170170
'neutron.agent.linux.ip_lib.'
171-
'delete_ip_address') as mock_del:
171+
'delete_ip_address') as mock_del,\
172+
mock.patch(
173+
'neutron.agent.linux.external_process.'
174+
'ProcessManager.active',
175+
new_callable=mock.PropertyMock,
176+
side_effect=[False, True]):
172177
agent = l3_agent.L3NATAgent('localhost')
173178
agent.process_monitor = mock.Mock()
174179
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
@@ -68,7 +68,12 @@ def test_spawn_metadata_proxy(self):
6868
return_value=test_utils.FakeUser(self.EUNAME)),\
6969
mock.patch('grp.getgrnam',
7070
return_value=test_utils.FakeGroup(self.EGNAME)),\
71-
mock.patch('os.makedirs'):
71+
mock.patch('os.makedirs'),\
72+
mock.patch(
73+
'neutron.agent.linux.external_process.'
74+
'ProcessManager.active',
75+
new_callable=mock.PropertyMock,
76+
side_effect=[False, True]):
7277
cfg_file = os.path.join(
7378
metadata_driver.HaproxyConfigurator.get_config_path(
7479
cfg.CONF.state_path),

0 commit comments

Comments
 (0)