Introduce node name prefix for mgmt/messaging IPs

RabbitMQ will resolve <prefix>-<fqdn> hostnames to valid mgmt/messaging IP

Change-Id: Ifc2af16b08663655d365587ea6f45c87bfc68698
Depends-On: I9813fa8c20d47e0ef1e251fe5ac8d01d08fe7703
Closes-bug: #1528707
DocImpact: https://bugs.launchpad.net/fuel/+bug/1535383
(cherry picked from commit ca65b718de)
This commit is contained in:
Kyrylo Galanov 2015-12-29 12:41:26 +02:00
parent 59621be94d
commit 5724477c83
9 changed files with 68 additions and 6 deletions

View File

@ -289,6 +289,8 @@ if hiera('amqp_hosts', false) {
$amqp_hosts = amqp_hosts($amqp_nodes, $amqp_port, get_network_role_property('mgmt/messaging', 'ipaddr'))
}
$node_name_prefix_for_messaging = hiera('node_name_prefix_for_messaging', 'messaging-')
# MySQL and SQLAlchemy backend configuration
$custom_mysql_setup_class = hiera('custom_mysql_setup_class', 'galera')
$max_pool_size = hiera('max_pool_size', min($::processorcount * 5 + 0, 30 + 0))

View File

@ -1,12 +1,14 @@
notice('MODULAR: hosts.pp')
$hosts_file = '/etc/hosts'
$host_resources = network_metadata_to_hosts(hiera_hash('network_metadata'))
$network_metadata = hiera_hash('network_metadata')
$host_resources = network_metadata_to_hosts($network_metadata)
$messaging_host_resources = network_metadata_to_hosts($network_metadata, 'mgmt/messaging', hiera('node_name_prefix_for_messaging'))
Host {
ensure => present,
target => $hosts_file
}
create_resources(host, $host_resources)
create_resources(host, merge($host_resources, $messaging_host_resources))

View File

@ -49,6 +49,7 @@ if $queue_provider == 'rabbitmq' {
$management_bind_ip_address = hiera('management_bind_ip_address', '127.0.0.1')
$enable_rpc_ha = hiera('enable_rpc_ha', 'true')
$enable_notifications_ha = hiera('enable_notifications_ha', 'true')
$fqdn_prefix = hiera('node_name_prefix_for_messaging', 'messaging-')
# NOTE(mattymo) UNSET is a puppet ref, but would break real configs
if $rabbitmq_bind_ip_address == 'UNSET' {
@ -103,13 +104,14 @@ if $queue_provider == 'rabbitmq' {
} else {
$rabbit_pid_file = '/var/run/rabbitmq/pid'
}
$environment_variables = hiera('rabbit_environment_variables',
$environment_variables_init = hiera('rabbit_environment_variables',
{
'SERVER_ERL_ARGS' => "\"+K true +A${thread_pool_calc} +P 1048576\"",
'ERL_EPMD_ADDRESS' => $epmd_bind_ip_address,
'PID_FILE' => $rabbit_pid_file,
}
)
$environment_variables = merge($environment_variables_init,{'NODENAME' => "rabbit@${fqdn_prefix}${hostname}"})
if ($enabled) {
class { '::rabbitmq':
@ -165,6 +167,7 @@ if $queue_provider == 'rabbitmq' {
before => Class['nova::rabbitmq'],
enable_rpc_ha => $enable_rpc_ha,
enable_notifications_ha => $enable_notifications_ha,
fqdn_prefix => $fqdn_prefix,
}
}

View File

@ -118,5 +118,6 @@ if @vips.select{|key, hash| hash['namespace'] == 'haproxy' }.length == 0
else
globals.store "external_lb", false
end -%>
<% globals.store "node_name_prefix_for_messaging", @node_name_prefix_for_messaging -%>
<%= YAML.dump globals %>

View File

@ -58,6 +58,11 @@
# Boolean. Set ha-mode=all policy for Ceilometer queues. Note
# that RPC queues are not affected by this flag.
#
# [*fqdn_prefix*]
# String. Optional FQDN prefix for node names.
# Defaults to empty string
#
class pacemaker_wrappers::rabbitmq (
$primitive_type = 'rabbitmq-server',
$service_name = $::rabbitmq::service_name,
@ -71,6 +76,7 @@ class pacemaker_wrappers::rabbitmq (
$admin_pass = undef,
$enable_rpc_ha = true,
$enable_notifications_ha = true,
$fqdn_prefix = '',
) inherits ::rabbitmq::service {
if $host_ip == 'UNSET' or $host_ip == '0.0.0.0' {
@ -89,6 +95,7 @@ class pacemaker_wrappers::rabbitmq (
'admin_password' => $admin_pass,
'enable_rpc_ha' => $enable_rpc_ha,
'enable_notifications_ha' => $enable_notifications_ha,
'fqdn_prefix' => $fqdn_prefix,
}
$metadata = {

View File

@ -44,6 +44,7 @@ OCF_RESKEY_node_port_default=5672
OCF_RESKEY_erlang_cookie_default=false
OCF_RESKEY_erlang_cookie_file_default="/var/lib/rabbitmq/.erlang.cookie"
OCF_RESKEY_use_fqdn_default=false
OCF_RESKEY_fqdn_prefix_default=""
OCF_RESKEY_max_rabbitmqctl_timeouts_default=1
: ${HA_LOGTAG="lrmd"}
@ -63,6 +64,7 @@ OCF_RESKEY_max_rabbitmqctl_timeouts_default=1
: ${OCF_RESKEY_erlang_cookie=${OCF_RESKEY_erlang_cookie_default}}
: ${OCF_RESKEY_erlang_cookie_file=${OCF_RESKEY_erlang_cookie_file_default}}
: ${OCF_RESKEY_use_fqdn=${OCF_RESKEY_use_fqdn_default}}
: ${OCF_RESKEY_fqdn_prefix=${OCF_RESKEY_fqdn_prefix_default}}
: ${OCF_RESKEY_max_rabbitmqctl_timeouts=${OCF_RESKEY_max_rabbitmqctl_timeouts_default}}
#######################################################################
@ -266,6 +268,16 @@ Either to use FQDN or a shortname for the rabbitmq node
<content type="boolean" default="${OCF_RESKEY_use_fqdn_default}" />
</parameter>
<parameter name="fqdn_prefix" unique="0" required="0">
<longdesc lang="en">
Optional FQDN prefix for RabbitMQ nodes in cluster.
FQDN prefix can be specified to host multiple RabbitMQ instances on a node or
in case of RabbitMQ running in dedicated network/interface.
</longdesc>
<shortdesc lang="en">FQDN prefix</shortdesc>
<content type="string" default="${OCF_RESKEY_fqdn_prefix_default}" />
</parameter>
<parameter name="max_rabbitmqctl_timeouts" unique="0" required="0">
<longdesc lang="en">
If during monitor call rabbitmqctl times out, the timeout is ignored
@ -515,9 +527,9 @@ get_hostname() {
# Strip the FQDN to the shortname, if OCF_RESKEY_use_fqdn was set
process_fqdn() {
if [ "${OCF_RESKEY_use_fqdn}" = 'false' ] ; then
echo "$1" | awk -F. '{print $1}'
echo "${OCF_RESKEY_fqdn_prefix}$1" | awk -F. '{print $1}'
else
echo "$1"
echo "${OCF_RESKEY_fqdn_prefix}$1"
fi
}
@ -530,7 +542,7 @@ my_host() {
local rc=10
local LH="${LL} my_host():"
hostname=$(get_hostname)
hostname=$(process_fqdn $(get_hostname))
ocf_log info "${LH} hostlist is: $hostlist"
for host in $hostlist ; do
hn=$(process_fqdn "${host}")

View File

@ -914,3 +914,4 @@ workloads_collector:
password: MhdNr1K7
tenant: services
username: workloads_collector
node_name_prefix_for_messaging: rabbitmq

View File

@ -3,6 +3,32 @@ require 'shared-examples'
manifest = 'hosts/hosts.pp'
describe manifest do
shared_examples 'catalog' do
network_metadata = Noop.hiera_structure('network_metadata/nodes')
messaging_fqdn_prefix = Noop.hiera('node_name_prefix_for_messaging', 'messaging-')
it 'should create basic host entries' do
network_metadata.each do |node, params|
should contain_host(params['fqdn']).with({
:ip => params['network_roles']['mgmt/vip'],
:host_aliases => ["#{node}"],
:target => '/etc/hosts'
})
end
end
it 'should create host entries for messaging network with correct prefix' do
network_metadata.each do |node, params|
should contain_host("#{messaging_fqdn_prefix}#{params['fqdn']}").with({
:ip => params['network_roles']['mgmt/messaging'],
:host_aliases => ["#{messaging_fqdn_prefix}#{node}"],
:target => '/etc/hosts'
})
end
end
end
test_ubuntu_and_centos manifest
end

View File

@ -16,6 +16,13 @@ describe manifest do
expect(environment_variables['ERL_EPMD_ADDRESS']).to eq node_ip_address
end
it "should contain nodename" do
fqdn_prefix = Noop.hiera('node_name_prefix_for_messaging', 'messaging-')
node_name = "rabbit@#{fqdn_prefix}#{facts[:hostname]}"
environment_variables = Noop.resource_parameter_value self, 'class', 'rabbitmq', 'environment_variables'
expect(environment_variables['NODENAME']).to eq node_name
end
# LP#1477595
it "should contain rabbitmq correct log levels" do
debug = Noop.hiera('debug', false)
@ -54,6 +61,7 @@ describe manifest do
it "should override service on package install" do
should contain_tweaks__ubuntu_service_override('rabbitmq-server')
end
end
test_ubuntu_and_centos manifest
end