diff --git a/config.yaml b/config.yaml index 93ba0fd3..fdca8655 100755 --- a/config.yaml +++ b/config.yaml @@ -330,6 +330,29 @@ options: description: | Minimum number of l3 agents to host a router. Only used when enable-l3ha is True. + allow-automatic-l3agent-failover: + type: boolean + default: False + description: | + Automatically reschedule routers from offline L3 agents to online L3 + agents. Note that it is advised to set this to true even when + Distributed Virtual routing is enabled, since SNAT for nodes without + floating IPs is set up centrally on an L3 agent. For DVR the SNAT + namespace will be rescheduled only to L3 agents running in the 'dvr_snat' + mode, while l3 agents in the 'dvr' mode will only host qrouter and fip + namespaces. + allow-automatic-dhcp-failover: + type: boolean + default: True + description: | + Automatically remove networks from offline DHCP agents and reschedule + them to online DHCP agents. This option can be used in conjunction with + dhcp-agents-per-network as a single network can be maintained by multiple + dhcp agents. Practically, rescheduling involves creating a dhcp network + namespace and starting a DHCP agent like the default dnsmasq one in that + network namespace. If availability zone information is propagated to + neutron-openvswitch and neutron-gateway units from the underlying Juju + provider (e.g. MAAS), it may also affect rescheduling. dhcp-agents-per-network: type: int default: 1 diff --git a/hooks/neutron_api_context.py b/hooks/neutron_api_context.py index 536f88ed..84293d20 100644 --- a/hooks/neutron_api_context.py +++ b/hooks/neutron_api_context.py @@ -396,6 +396,10 @@ class NeutronCCContext(context.NeutronContext): ctxt['max_l3_agents_per_router'] = max_agents ctxt['min_l3_agents_per_router'] = min_agents + ctxt['allow_automatic_l3agent_failover'] = \ + config('allow-automatic-l3agent-failover') + ctxt['allow_automatic_dhcp_failover'] = \ + config('allow-automatic-dhcp-failover') ctxt['dhcp_agents_per_network'] = config('dhcp-agents-per-network') ctxt['tenant_network_types'] = self.neutron_tenant_network_types ctxt['overlay_network_type'] = self.neutron_overlay_network_type diff --git a/templates/juno/neutron.conf b/templates/juno/neutron.conf index b97f061b..9ffe4efa 100644 --- a/templates/juno/neutron.conf +++ b/templates/juno/neutron.conf @@ -1,3 +1,4 @@ +# juno ############################################################################### # [ WARNING ] # Configuration file maintained by Juju. Local changes may be overwritten. @@ -23,6 +24,8 @@ max_l3_agents_per_router = {{ max_l3_agents_per_router }} min_l3_agents_per_router = {{ min_l3_agents_per_router }} {% endif -%} +allow_automatic_l3agent_failover = {{ allow_automatic_l3agent_failover }} + {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} {% else -%} diff --git a/templates/kilo/neutron.conf b/templates/kilo/neutron.conf index f4b7404f..a209f6ae 100644 --- a/templates/kilo/neutron.conf +++ b/templates/kilo/neutron.conf @@ -23,6 +23,9 @@ max_l3_agents_per_router = {{ max_l3_agents_per_router }} min_l3_agents_per_router = {{ min_l3_agents_per_router }} {% endif -%} +allow_automatic_l3agent_failover = {{ allow_automatic_l3agent_failover }} +allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} + {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} {% else -%} diff --git a/templates/liberty/neutron.conf b/templates/liberty/neutron.conf index 8164b304..6c6afd56 100644 --- a/templates/liberty/neutron.conf +++ b/templates/liberty/neutron.conf @@ -24,6 +24,9 @@ max_l3_agents_per_router = {{ max_l3_agents_per_router }} min_l3_agents_per_router = {{ min_l3_agents_per_router }} {% endif -%} +allow_automatic_l3agent_failover = {{ allow_automatic_l3agent_failover }} +allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} + {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} {% else -%} diff --git a/templates/mitaka/neutron.conf b/templates/mitaka/neutron.conf index 4014741f..426157bc 100644 --- a/templates/mitaka/neutron.conf +++ b/templates/mitaka/neutron.conf @@ -26,6 +26,9 @@ max_l3_agents_per_router = {{ max_l3_agents_per_router }} min_l3_agents_per_router = {{ min_l3_agents_per_router }} {% endif -%} +allow_automatic_l3agent_failover = {{ allow_automatic_l3agent_failover }} +allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} + {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} {% else -%} diff --git a/templates/newton/neutron.conf b/templates/newton/neutron.conf index 3ae9ab3d..c5eed6da 100644 --- a/templates/newton/neutron.conf +++ b/templates/newton/neutron.conf @@ -26,6 +26,9 @@ max_l3_agents_per_router = {{ max_l3_agents_per_router }} min_l3_agents_per_router = {{ min_l3_agents_per_router }} {% endif -%} +allow_automatic_l3agent_failover = {{ allow_automatic_l3agent_failover }} +allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} + {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} {% else -%} diff --git a/templates/ocata/neutron.conf b/templates/ocata/neutron.conf index 1f77b914..0690132b 100644 --- a/templates/ocata/neutron.conf +++ b/templates/ocata/neutron.conf @@ -26,6 +26,9 @@ max_l3_agents_per_router = {{ max_l3_agents_per_router }} min_l3_agents_per_router = {{ min_l3_agents_per_router }} {% endif -%} +allow_automatic_l3agent_failover = {{ allow_automatic_l3agent_failover }} +allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} + {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} {% else -%} diff --git a/templates/pike/neutron.conf b/templates/pike/neutron.conf index 975a292b..0b39633e 100644 --- a/templates/pike/neutron.conf +++ b/templates/pike/neutron.conf @@ -26,6 +26,9 @@ max_l3_agents_per_router = {{ max_l3_agents_per_router }} min_l3_agents_per_router = {{ min_l3_agents_per_router }} {% endif -%} +allow_automatic_l3agent_failover = {{ allow_automatic_l3agent_failover }} +allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} + {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} {% else -%} diff --git a/templates/queens/neutron.conf b/templates/queens/neutron.conf index 7387386d..1e2df990 100644 --- a/templates/queens/neutron.conf +++ b/templates/queens/neutron.conf @@ -26,6 +26,9 @@ max_l3_agents_per_router = {{ max_l3_agents_per_router }} min_l3_agents_per_router = {{ min_l3_agents_per_router }} {% endif -%} +allow_automatic_l3agent_failover = {{ allow_automatic_l3agent_failover }} +allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} + {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} {% else -%} diff --git a/unit_tests/test_neutron_api_context.py b/unit_tests/test_neutron_api_context.py index 836bd79c..98977477 100644 --- a/unit_tests/test_neutron_api_context.py +++ b/unit_tests/test_neutron_api_context.py @@ -416,6 +416,8 @@ class NeutronCCContextTest(CharmTestCase): 'debug': True, 'enable_dvr': False, 'l3_ha': False, + 'allow_automatic_dhcp_failover': True, + 'allow_automatic_l3agent_failover': False, 'mechanism_drivers': 'openvswitch,l2population', 'dhcp_agents_per_network': 3, 'enable_sriov': False, @@ -462,6 +464,8 @@ class NeutronCCContextTest(CharmTestCase): 'debug': True, 'enable_dvr': False, 'l3_ha': False, + 'allow_automatic_dhcp_failover': True, + 'allow_automatic_l3agent_failover': False, 'mechanism_drivers': 'openvswitch,hyperv,l2population', 'dhcp_agents_per_network': 3, 'enable_sriov': False, @@ -555,6 +559,8 @@ class NeutronCCContextTest(CharmTestCase): 'debug': True, 'enable_dvr': False, 'l3_ha': False, + 'allow_automatic_dhcp_failover': True, + 'allow_automatic_l3agent_failover': False, 'mechanism_drivers': 'openvswitch,l2population', 'dhcp_agents_per_network': 3, 'enable_sriov': False, @@ -618,6 +624,8 @@ class NeutronCCContextTest(CharmTestCase): 'tenant_network_types': 'gre,vlan,flat,local', 'max_l3_agents_per_router': 2, 'min_l3_agents_per_router': 2, + 'allow_automatic_dhcp_failover': True, + 'allow_automatic_l3agent_failover': False, 'dhcp_agents_per_network': 3, 'enable_sriov': False, 'quota_floatingip': 50, @@ -672,6 +680,8 @@ class NeutronCCContextTest(CharmTestCase): 'debug': True, 'enable_dvr': False, 'l3_ha': False, + 'allow_automatic_dhcp_failover': True, + 'allow_automatic_l3agent_failover': False, 'mechanism_drivers': 'openvswitch,hyperv,l2population' ',sriovnicswitch', 'dhcp_agents_per_network': 3,