From 0499e0c5d66575d194854cde8ba70ff75c728165 Mon Sep 17 00:00:00 2001 From: Adam Harwell Date: Mon, 21 Sep 2020 16:13:37 -0700 Subject: [PATCH] Followup Remove haproxy_check_script for UDP-only The original patch: Ib2a80afb9223da2c0af6f6add250ffaaa20a316f First attempt at fixing this issue assumed that the update function would actually be called again after the initial LB creation, which it is not. We should ensure that this is called when we do any UDP listener creation, so the file can be removed if necessary. Change-Id: Iec1ec7df420e3746b47004c8c0374d2d8274f45b (cherry picked from commit 7839ffd50d730c33d81be754ce6fd5747f546a74) (cherry picked from commit 5580fd01ecba0f57f0dbb94f31ae1adf7fc547b7) --- .../backends/agent/api_server/keepalivedlvs.py | 1 + .../backend/agent/api_server/test_keepalivedlvs.py | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/octavia/amphorae/backends/agent/api_server/keepalivedlvs.py b/octavia/amphorae/backends/agent/api_server/keepalivedlvs.py index 0ec0855ce1..4fe6e9e650 100644 --- a/octavia/amphorae/backends/agent/api_server/keepalivedlvs.py +++ b/octavia/amphorae/backends/agent/api_server/keepalivedlvs.py @@ -169,6 +169,7 @@ class KeepalivedLvs(udp_listener_base.UdpListenerApiServerBase): keepalived_lvs_pid_dir=util.keepalived_lvs_dir() ) script_file.write(text) + util.vrrp_check_script_update(None, consts.AMP_ACTION_START) res = webob.Response(json={'message': 'OK'}, status=200) res.headers['ETag'] = stream.get_md5() diff --git a/octavia/tests/functional/amphorae/backend/agent/api_server/test_keepalivedlvs.py b/octavia/tests/functional/amphorae/backend/agent/api_server/test_keepalivedlvs.py index 569c2333fe..ee6dc5b024 100644 --- a/octavia/tests/functional/amphorae/backend/agent/api_server/test_keepalivedlvs.py +++ b/octavia/tests/functional/amphorae/backend/agent/api_server/test_keepalivedlvs.py @@ -171,6 +171,10 @@ class KeepalivedLvsTestCase(base.TestCase): m_fdopen.assert_any_call('TEST-WRITE-SYSINIT', 'w') self.assertEqual(200, res.status_code) + @mock.patch('octavia.amphorae.backends.agent.api_server.util.' + 'get_udp_listeners') + @mock.patch('octavia.amphorae.backends.agent.api_server.util.' + 'get_loadbalancers') @mock.patch('octavia.amphorae.backends.agent.api_server.util.' 'run_systemctl_command') @mock.patch('octavia.amphorae.backends.agent.api_server.util.' @@ -187,8 +191,10 @@ class KeepalivedLvsTestCase(base.TestCase): def test_upload_udp_listener_config_with_vrrp_check_dir( self, m_check_output, m_os_rm, m_os_mkdir, m_exists, m_os_chmod, m_os_sysinit, m_copy2, mock_netns, mock_install_netns, - mock_systemctl): + mock_systemctl, mock_get_lbs, mock_get_udp_listeners): m_exists.side_effect = [False, False, True, True, False, False, False] + mock_get_lbs.return_value = [] + mock_get_udp_listeners.return_value = [self.FAKE_ID] cfg_path = util.keepalived_lvs_cfg_path(self.FAKE_ID) m = self.useFixture(test_utils.OpenFixture(cfg_path)).mock_open @@ -237,6 +243,8 @@ class KeepalivedLvsTestCase(base.TestCase): m_fdopen.assert_any_call('TEST-WRITE-CFG', 'wb') m_fdopen.assert_any_call('TEST-WRITE-SYSINIT', 'w') m_fdopen.assert_any_call('TEST-WRITE-UDP-VRRP-CHECK', 'w') + + m_os_rm.assert_called_once_with(util.haproxy_check_script_path()) self.assertEqual(200, res.status_code) @mock.patch('octavia.amphorae.backends.agent.api_server.util.'