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
This commit is contained in:
Adam Harwell 2020-09-21 16:13:37 -07:00
parent e45ecc2111
commit 7839ffd50d
2 changed files with 10 additions and 1 deletions

View File

@ -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()

View File

@ -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.'