From 5d83c2c702d9bd720286f8da4329aa36417228a8 Mon Sep 17 00:00:00 2001 From: Edward Hope-Morley Date: Sat, 8 Aug 2020 15:37:50 +0100 Subject: [PATCH] Add keepalived-healthcheck-interval config option Defaults to 30s (i.e. enabled) but also allows disabling healthchecks by setting to 0. Change-Id: I5bb7d362f0d957237e24f79f1f82583661bed470 Closes-Bug: #1890900 --- config.yaml | 9 +++++++++ hooks/neutron_ovs_context.py | 2 ++ templates/mitaka/l3_agent.ini | 4 ++-- templates/rocky/l3_agent.ini | 4 ++-- templates/stein/l3_agent.ini | 3 +++ unit_tests/test_neutron_ovs_context.py | 5 ++++- 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/config.yaml b/config.yaml index 79e44605..5bbd22b2 100644 --- a/config.yaml +++ b/config.yaml @@ -394,3 +394,12 @@ options: order to support kernels with limited namespace support. i.e. Trusty. Changing the value after neutron DHCP agents are created will break access. The charm will go into a blocked state if this is attempted. + keepalived-healthcheck-interval: + type: int + default: 30 + description: | + By default all HA routers will check their external network gateway + by sending a ping and if that fails they trigger a vrrp transition. This + option defines how frequently this check is performed. Setting this value + to 0 will disable the healthchecks. Note that this only applies when + using l3ha and dvr_snat. diff --git a/hooks/neutron_ovs_context.py b/hooks/neutron_ovs_context.py index 31ac1fbe..7c42cb53 100644 --- a/hooks/neutron_ovs_context.py +++ b/hooks/neutron_ovs_context.py @@ -201,6 +201,8 @@ class OVSPluginContext(context.NeutronContext): ovs_ctxt['debug'] = conf['debug'] ovs_ctxt['prevent_arp_spoofing'] = conf['prevent-arp-spoofing'] ovs_ctxt['enable_dpdk'] = conf['enable-dpdk'] + ovs_ctxt['keepalived_healthcheck_interval'] = \ + conf['keepalived-healthcheck-interval'] net_dev_mtu = neutron_api_settings.get('network_device_mtu') if net_dev_mtu: diff --git a/templates/mitaka/l3_agent.ini b/templates/mitaka/l3_agent.ini index 1e0a4d44..8c0b222d 100644 --- a/templates/mitaka/l3_agent.ini +++ b/templates/mitaka/l3_agent.ini @@ -11,6 +11,6 @@ agent_mode = {{ agent_mode }} gateway_external_network_id = external_network_bridge = {% endif %} -{% if use_l3ha and agent_mode == 'dvr_snat' -%} -ha_vrrp_health_check_interval = 30 +{% if use_l3ha and agent_mode == 'dvr_snat' and keepalived_healthcheck_interval -%} +ha_vrrp_health_check_interval = {{ keepalived_healthcheck_interval }} {% endif %} diff --git a/templates/rocky/l3_agent.ini b/templates/rocky/l3_agent.ini index 4eb2f1c1..7011f91e 100644 --- a/templates/rocky/l3_agent.ini +++ b/templates/rocky/l3_agent.ini @@ -11,8 +11,8 @@ agent_mode = {{ agent_mode }} gateway_external_network_id = external_network_bridge = {% endif %} -{% if use_l3ha and agent_mode == 'dvr_snat' -%} -ha_vrrp_health_check_interval = 30 +{% if use_l3ha and agent_mode == 'dvr_snat' and keepalived_healthcheck_interval -%} +ha_vrrp_health_check_interval = {{ keepalived_healthcheck_interval }} {% endif %} [AGENT] diff --git a/templates/stein/l3_agent.ini b/templates/stein/l3_agent.ini index 929b48b3..c58d31b3 100644 --- a/templates/stein/l3_agent.ini +++ b/templates/stein/l3_agent.ini @@ -12,6 +12,9 @@ agent_mode = {{ agent_mode }} gateway_external_network_id = external_network_bridge = {% endif %} +{% if use_l3ha and agent_mode == 'dvr_snat' and keepalived_healthcheck_interval -%} +ha_vrrp_health_check_interval = {{ keepalived_healthcheck_interval }} +{% endif %} [AGENT] extensions = {{ l3_extension_plugins }} diff --git a/unit_tests/test_neutron_ovs_context.py b/unit_tests/test_neutron_ovs_context.py index e8d3b5fa..8ef9b4f4 100644 --- a/unit_tests/test_neutron_ovs_context.py +++ b/unit_tests/test_neutron_ovs_context.py @@ -133,7 +133,8 @@ class OVSPluginContextTest(CharmTestCase): 'enable-dpdk': False, 'security-group-log-output-base': '/var/log/nsg.log', 'security-group-log-rate-limit': None, - 'security-group-log-burst-limit': 25} + 'security-group-log-burst-limit': 25, + 'keepalived-healthcheck-interval': 0} def mock_config(key=None): if key: @@ -191,6 +192,7 @@ class OVSPluginContextTest(CharmTestCase): 'nsg_log_output_base': '/var/log/nsg.log', 'nsg_log_rate_limit': None, 'nsg_log_burst_limit': 25, + 'keepalived_healthcheck_interval': 0, } self.assertEqual(expect, napi_ctxt()) @@ -271,6 +273,7 @@ class OVSPluginContextTest(CharmTestCase): 'nsg_log_output_base': None, 'nsg_log_rate_limit': None, 'nsg_log_burst_limit': 25, + 'keepalived_healthcheck_interval': 30, } self.maxDiff = None self.assertEqual(expect, napi_ctxt())