From 58e831ef093422ea0510e0198dd8f75d33523f26 Mon Sep 17 00:00:00 2001 From: Mike Dorman Date: Mon, 22 Jun 2015 13:38:34 -0600 Subject: [PATCH] Add support for RabbitMQ connection heartbeat Kilo oslo.messaging added heartbeating support for RabbitMQ connections. This patch adds support for this in Puppet modules by managing the oslo_messaging_rabbit/heartbeat_timeout_threshold and oslo_messaging_rabbit/heartbeat_rate settings. Closes-bug: 1467667 Change-Id: I9c237bea74572222be19495342931a67a374e7bc --- manifests/init.pp | 139 +++++++++++++++++++-------------- spec/classes/nova_init_spec.rb | 48 +++++++----- 2 files changed, 106 insertions(+), 81 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 8b91bb7b2..5750051a6 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -72,6 +72,21 @@ # (optional) Use HA queues in RabbitMQ. # Defaults to undef # +# [*rabbit_heartbeat_timeout_threshold*] +# (optional) Number of seconds after which the RabbitMQ broker is considered +# down if the heartbeat keepalive fails. Any value >0 enables heartbeats. +# Heartbeating helps to ensure the TCP connection to RabbitMQ isn't silently +# closed, resulting in missed or lost messages from the queue. +# (Requires kombu >= 3.0.7 and amqp >= 1.4.0) +# Defaults to 0 +# +# [*rabbit_heartbeat_rate*] +# (optional) How often during the rabbit_heartbeat_timeout_threshold period to +# check the heartbeat on RabbitMQ connection. (i.e. rabbit_heartbeat_rate=2 +# when rabbit_heartbeat_timeout_threshold=60, the heartbeat will be checked +# every 30 seconds. +# Defaults to 2 +# # [*kombu_ssl_ca_certs*] # (optional) SSL certification authority file (valid only if SSL enabled). # Defaults to undef @@ -246,64 +261,66 @@ # Defaults to undef # class nova( - $ensure_package = 'present', - $database_connection = false, - $slave_connection = false, - $database_idle_timeout = 3600, - $rpc_backend = 'rabbit', - $image_service = 'nova.image.glance.GlanceImageService', + $ensure_package = 'present', + $database_connection = false, + $slave_connection = false, + $database_idle_timeout = 3600, + $rpc_backend = 'rabbit', + $image_service = 'nova.image.glance.GlanceImageService', # these glance params should be optional # this should probably just be configured as a glance client - $glance_api_servers = 'localhost:9292', - $memcached_servers = false, - $rabbit_host = 'localhost', - $rabbit_hosts = false, - $rabbit_password = 'guest', - $rabbit_port = '5672', - $rabbit_userid = 'guest', - $rabbit_virtual_host = '/', - $rabbit_use_ssl = false, - $rabbit_ha_queues = undef, - $kombu_ssl_ca_certs = undef, - $kombu_ssl_certfile = undef, - $kombu_ssl_keyfile = undef, - $kombu_ssl_version = 'TLSv1', - $amqp_durable_queues = false, - $qpid_hostname = 'localhost', - $qpid_port = '5672', - $qpid_username = 'guest', - $qpid_password = 'guest', - $qpid_sasl_mechanisms = false, - $qpid_heartbeat = 60, - $qpid_protocol = 'tcp', - $qpid_tcp_nodelay = true, - $auth_strategy = 'keystone', - $service_down_time = 60, - $log_dir = '/var/log/nova', - $state_path = '/var/lib/nova', - $lock_path = $::nova::params::lock_path, - $verbose = false, - $debug = false, - $periodic_interval = '60', - $report_interval = '10', - $rootwrap_config = '/etc/nova/rootwrap.conf', - $use_ssl = false, - $enabled_ssl_apis = ['ec2', 'metadata', 'osapi_compute'], - $ca_file = false, - $cert_file = false, - $key_file = false, - $nova_public_key = undef, - $nova_private_key = undef, - $use_syslog = false, - $log_facility = 'LOG_USER', - $install_utilities = true, - $notification_driver = [], - $notification_topics = 'notifications', - $notify_api_faults = false, - $notify_on_state_change = undef, + $glance_api_servers = 'localhost:9292', + $memcached_servers = false, + $rabbit_host = 'localhost', + $rabbit_hosts = false, + $rabbit_password = 'guest', + $rabbit_port = '5672', + $rabbit_userid = 'guest', + $rabbit_virtual_host = '/', + $rabbit_use_ssl = false, + $rabbit_heartbeat_timeout_threshold = 0, + $rabbit_heartbeat_rate = 2, + $rabbit_ha_queues = undef, + $kombu_ssl_ca_certs = undef, + $kombu_ssl_certfile = undef, + $kombu_ssl_keyfile = undef, + $kombu_ssl_version = 'TLSv1', + $amqp_durable_queues = false, + $qpid_hostname = 'localhost', + $qpid_port = '5672', + $qpid_username = 'guest', + $qpid_password = 'guest', + $qpid_sasl_mechanisms = false, + $qpid_heartbeat = 60, + $qpid_protocol = 'tcp', + $qpid_tcp_nodelay = true, + $auth_strategy = 'keystone', + $service_down_time = 60, + $log_dir = '/var/log/nova', + $state_path = '/var/lib/nova', + $lock_path = $::nova::params::lock_path, + $verbose = false, + $debug = false, + $periodic_interval = '60', + $report_interval = '10', + $rootwrap_config = '/etc/nova/rootwrap.conf', + $use_ssl = false, + $enabled_ssl_apis = ['ec2', 'metadata', 'osapi_compute'], + $ca_file = false, + $cert_file = false, + $key_file = false, + $nova_public_key = undef, + $nova_private_key = undef, + $use_syslog = false, + $log_facility = 'LOG_USER', + $install_utilities = true, + $notification_driver = [], + $notification_topics = 'notifications', + $notify_api_faults = false, + $notify_on_state_change = undef, # DEPRECATED PARAMETERS - $mysql_module = undef, - $os_region_name = undef, + $mysql_module = undef, + $os_region_name = undef, ) inherits nova::params { # maintain backward compatibility @@ -459,11 +476,13 @@ class nova( if $rpc_backend == 'nova.openstack.common.rpc.impl_kombu' or $rpc_backend == 'rabbit' { # I may want to support exporting and collecting these nova_config { - 'oslo_messaging_rabbit/rabbit_password': value => $rabbit_password, secret => true; - 'oslo_messaging_rabbit/rabbit_userid': value => $rabbit_userid; - 'oslo_messaging_rabbit/rabbit_virtual_host': value => $rabbit_virtual_host; - 'oslo_messaging_rabbit/rabbit_use_ssl': value => $rabbit_use_ssl; - 'DEFAULT/amqp_durable_queues': value => $amqp_durable_queues; + 'oslo_messaging_rabbit/rabbit_password': value => $rabbit_password, secret => true; + 'oslo_messaging_rabbit/rabbit_userid': value => $rabbit_userid; + 'oslo_messaging_rabbit/rabbit_virtual_host': value => $rabbit_virtual_host; + 'oslo_messaging_rabbit/rabbit_use_ssl': value => $rabbit_use_ssl; + 'oslo_messaging_rabbit/heartbeat_timeout_threshold': value => $rabbit_heartbeat_timeout_threshold; + 'oslo_messaging_rabbit/heartbeat_rate': value => $rabbit_heartbeat_rate; + 'DEFAULT/amqp_durable_queues': value => $amqp_durable_queues; } if $rabbit_use_ssl { diff --git a/spec/classes/nova_init_spec.rb b/spec/classes/nova_init_spec.rb index 368cb6a12..d73e5c3ca 100644 --- a/spec/classes/nova_init_spec.rb +++ b/spec/classes/nova_init_spec.rb @@ -62,6 +62,8 @@ describe 'nova' do is_expected.to contain_nova_config('oslo_messaging_rabbit/rabbit_port').with_value('5672') is_expected.to contain_nova_config('oslo_messaging_rabbit/rabbit_userid').with_value('guest') is_expected.to contain_nova_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value('/') + is_expected.to contain_nova_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('0') + is_expected.to contain_nova_config('oslo_messaging_rabbit/heartbeat_rate').with_value('2') end it 'configures various things' do @@ -88,27 +90,29 @@ describe 'nova' do context 'with overridden parameters' do let :params do - { :verbose => true, - :debug => true, - :log_dir => '/var/log/nova2', - :image_service => 'nova.image.local.LocalImageService', - :rabbit_host => 'rabbit', - :rabbit_userid => 'rabbit_user', - :rabbit_port => '5673', - :rabbit_password => 'password', - :rabbit_ha_queues => 'undef', - :lock_path => '/var/locky/path', - :state_path => '/var/lib/nova2', - :service_down_time => '120', - :auth_strategy => 'foo', - :ensure_package => '2012.1.1-15.el6', - :memcached_servers => ['memcached01:11211', 'memcached02:11211'], - :install_utilities => false, - :notification_driver => 'ceilometer.compute.nova_notifier', - :notification_topics => 'openstack', - :notify_api_faults => true, - :report_interval => '60', - :os_region_name => 'MyRegion' } + { :verbose => true, + :debug => true, + :log_dir => '/var/log/nova2', + :image_service => 'nova.image.local.LocalImageService', + :rabbit_host => 'rabbit', + :rabbit_userid => 'rabbit_user', + :rabbit_port => '5673', + :rabbit_password => 'password', + :rabbit_ha_queues => 'undef', + :rabbit_heartbeat_timeout_threshold => '60', + :rabbit_heartbeat_rate => '10', + :lock_path => '/var/locky/path', + :state_path => '/var/lib/nova2', + :service_down_time => '120', + :auth_strategy => 'foo', + :ensure_package => '2012.1.1-15.el6', + :memcached_servers => ['memcached01:11211', 'memcached02:11211'], + :install_utilities => false, + :notification_driver => 'ceilometer.compute.nova_notifier', + :notification_topics => 'openstack', + :notify_api_faults => true, + :report_interval => '60', + :os_region_name => 'MyRegion' } end it 'installs packages' do @@ -133,6 +137,8 @@ describe 'nova' do is_expected.to contain_nova_config('oslo_messaging_rabbit/rabbit_port').with_value('5673') is_expected.to contain_nova_config('oslo_messaging_rabbit/rabbit_userid').with_value('rabbit_user') is_expected.to contain_nova_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value('/') + is_expected.to contain_nova_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('60') + is_expected.to contain_nova_config('oslo_messaging_rabbit/heartbeat_rate').with_value('10') end it 'configures memcached_servers' do