From e4766fb2b61624f4d5e08a774e4cc9f80b15523e Mon Sep 17 00:00:00 2001 From: Hong Hui Xiao Date: Wed, 4 Feb 2015 17:57:32 +0800 Subject: [PATCH] Allow customize l3 agent HA parameters Parameterize l3_ha, max_l3_agents_per_router, ha_vrrp_advert_int setting, so that user can deploy a topology with neutron l3 agent HA enabled. Change-Id: Iab159efcc30349e6481c944a5afb16293fbb0826 Closes-Bug: #1417913 --- CHANGELOG.md | 1 + README.md | 5 ++++- attributes/default.rb | 9 +++++++++ spec/default_spec.rb | 7 +++++++ spec/l3_agent_spec.rb | 5 +++++ templates/default/l3_agent.ini.erb | 13 +++++++++++++ templates/default/neutron.conf.erb | 17 +++++++++++++++++ 7 files changed, 56 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 534de44d..e6f35bec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This file is used to list changes made in each version of cookbook-openstack-net * Add radvd to neutron_l3_packages to support ipv6 * Use common specific_endpoint routines (bug 1412919) * Parameterize dhcp_agents_per_network +* Parameterize neutron l3 agent HA parameters ## 10.1.0 * Add support for Neutron VPN Service diff --git a/README.md b/README.md index d04dd21d..c6431d7d 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,10 @@ DHCP Agent Configuration L3 Agent Configuration ---------------------- -* `openstack['openstack']['network']['l3']['router_delete_namespaces'] - (StrOpt) If True, namespaces will be deleted when a router is destroyed. +* `openstack['openstack']['network']['l3']['router_delete_namespaces']` - (StrOpt) If True, namespaces will be deleted when a router is destroyed. +* `openstack['openstack']['network']['l3']['ha']['l3_ha']` - (BoolOpt) If True, virtual router will be created as ha by default. (default False) +* `openstack['openstack']['network']['l3']['ha']['max_l3_agents_per_router']` - (IntOpt) The maximum number of l3 agents for each ha router. (default 3) +* `openstack['openstack']['network']['l3']['ha']['ha_vrrp_advert_int']` - (IntOpt) The advertisement interval in seconds. (default 2) VPN Agent Configuration ---------------------- diff --git a/attributes/default.rb b/attributes/default.rb index afbc8f51..f1a42cbd 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -375,6 +375,15 @@ default['openstack']['network']['l3']['periodic_fuzzy_delay'] = 5 # If True, namespaces will be deleted when a router is destroyed default['openstack']['network']['l3']['router_delete_namespaces'] = 'False' +# Set the default value of ha parameter for virtual router. +default['openstack']['network']['l3']['ha']['l3_ha'] = 'False' + +# Set the default maximum number of l3 agents for each ha router. +default['openstack']['network']['l3']['ha']['max_l3_agents_per_router'] = 3 + +# Set the default advertisement interval in seconds +default['openstack']['network']['l3']['ha']['ha_vrrp_advert_int'] = 2 + # ============================= VPN Agent Configuration ==================== # VPN device drivers which vpn agent will use diff --git a/spec/default_spec.rb b/spec/default_spec.rb index 7a41da51..d8b82849 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -555,6 +555,13 @@ describe 'openstack-network' do expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^dhcp_agents_per_network = dhcp_agents_per_network_value$/) end + %w(l3_ha max_l3_agents_per_router).each do |attr| + it "sets the #{attr} attribute" do + node.set['openstack']['network']['l3']['ha'][attr] = "#{attr}_value" + expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr} = #{attr}_value$/) + end + end + %w(notify_nova_on_port_status_changes notify_nova_on_port_data_changes send_events_interval).each do |attr| it "sets the #{attr} nova attribute" do node.set['openstack']['network']['nova'][attr] = "#{attr}_value" diff --git a/spec/l3_agent_spec.rb b/spec/l3_agent_spec.rb index 479f316e..e6a33e14 100644 --- a/spec/l3_agent_spec.rb +++ b/spec/l3_agent_spec.rb @@ -83,6 +83,11 @@ describe 'openstack-network::l3_agent' do end end + it 'sets the ha_vrrp_advert_int attribute' do + node.set['openstack']['network']['l3']['ha']['ha_vrrp_advert_int'] = 'ha_vrrp_advert_int_value' + expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^ha_vrrp_advert_int = ha_vrrp_advert_int_value$/) + end + %w[router_id gateway_external_network_id].each do |conditional_attr| it "displays the #{conditional_attr} attribute when present" do node.set['openstack']['network']['l3'][conditional_attr] = "network_l3_#{conditional_attr}_value" diff --git a/templates/default/l3_agent.ini.erb b/templates/default/l3_agent.ini.erb index 265e9ce5..4d2f4d12 100644 --- a/templates/default/l3_agent.ini.erb +++ b/templates/default/l3_agent.ini.erb @@ -91,3 +91,16 @@ router_delete_namespaces = <%= node['openstack']['network']['l3']['router_delete # DVR. This mode must be used for an L3 agent running on a centralized # node (or in single-host deployments, e.g. devstack). # agent_mode = legacy + +# Location to store keepalived and all HA configurations +# ha_confs_path = $state_path/ha_confs + +# VRRP authentication type AH/PASS +# ha_vrrp_auth_type = PASS + +# VRRP authentication password +# ha_vrrp_auth_password = + +# The advertisement interval in seconds +ha_vrrp_advert_int = <%= node['openstack']['network']['l3']['ha']['ha_vrrp_advert_int'] %> + diff --git a/templates/default/neutron.conf.erb b/templates/default/neutron.conf.erb index 48a2db79..dc9bbcb7 100644 --- a/templates/default/neutron.conf.erb +++ b/templates/default/neutron.conf.erb @@ -283,6 +283,23 @@ dhcp_agents_per_network = <%= node['openstack']['network']['dhcp']['dhcp_agents_ # =========== end of items for agent scheduler extension ===== +# =========== items for l3 extension ============== +# Enable high availability for virtual routers. +l3_ha = <%= node['openstack']['network']['l3']['ha']['l3_ha'] %> + +# Maximum number of l3 agents which a HA router will be scheduled on. If it +# is set to 0 the router will be scheduled on every agent. +max_l3_agents_per_router = <%= node['openstack']['network']['l3']['ha']['max_l3_agents_per_router'] %> + +# Minimum number of l3 agents which a HA router will be scheduled on. The +# default value is 2. +# min_l3_agents_per_router = 2 + +# CIDR of the administrative network if HA mode is enabled +# l3_ha_net_cidr = 169.254.192.0/18 + +# =========== end of items for l3 extension ======= + # =========== WSGI parameters related to the API server ============== # Number of separate worker processes to spawn. The default, 0, runs the # worker thread in the current process. Greater than 0 launches that number of