Merge pull request #623 from sileht/sileht/galera-tweak
Allow to use nova database slave_connection
This commit is contained in:
commit
95dcabdec0
@ -23,6 +23,11 @@
|
|||||||
# (optional) Hostname or IP address to connect to nova database
|
# (optional) Hostname or IP address to connect to nova database
|
||||||
# Defaults to '127.0.0.1'
|
# Defaults to '127.0.0.1'
|
||||||
#
|
#
|
||||||
|
# [*nova_db_use_slave*]
|
||||||
|
# (optional) Enable slave connection for nova, this assume
|
||||||
|
# the haproxy is used and mysql loadbalanced port for read operation is 3307
|
||||||
|
# Defaults to false
|
||||||
|
#
|
||||||
# [*nova_db_user*]
|
# [*nova_db_user*]
|
||||||
# (optional) Username to connect to nova database
|
# (optional) Username to connect to nova database
|
||||||
# Defaults to 'nova'
|
# Defaults to 'nova'
|
||||||
@ -70,6 +75,7 @@
|
|||||||
|
|
||||||
class cloud::compute(
|
class cloud::compute(
|
||||||
$nova_db_host = '127.0.0.1',
|
$nova_db_host = '127.0.0.1',
|
||||||
|
$nova_db_use_slave = false,
|
||||||
$nova_db_user = 'nova',
|
$nova_db_user = 'nova',
|
||||||
$nova_db_password = 'novapassword',
|
$nova_db_password = 'novapassword',
|
||||||
$rabbit_hosts = ['127.0.0.1:5672'],
|
$rabbit_hosts = ['127.0.0.1:5672'],
|
||||||
@ -128,6 +134,12 @@ class cloud::compute(
|
|||||||
nova_shell => '/bin/bash',
|
nova_shell => '/bin/bash',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if $nova_db_use_slave {
|
||||||
|
nova_config {'database/slave_connection': value => "mysql://${encoded_user}:${encoded_password}@${nova_db_host}:3307/nova?charset=utf8" }
|
||||||
|
} else {
|
||||||
|
nova_config {'database/slave_connection': ensure => absent }
|
||||||
|
}
|
||||||
|
|
||||||
class { 'nova::network::neutron':
|
class { 'nova::network::neutron':
|
||||||
neutron_admin_password => $neutron_password,
|
neutron_admin_password => $neutron_password,
|
||||||
neutron_admin_auth_url => "${neutron_protocol}://${neutron_endpoint}:35357/v2.0",
|
neutron_admin_auth_url => "${neutron_protocol}://${neutron_endpoint}:35357/v2.0",
|
||||||
|
@ -342,4 +342,12 @@ class cloud::database::sql (
|
|||||||
inline_template('check inter 2000 rise 2 fall 5 port 9200 <% if @hostname != @galera_master_name -%>backup<% end %>')
|
inline_template('check inter 2000 rise 2 fall 5 port 9200 <% if @hostname != @galera_master_name -%>backup<% end %>')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@haproxy::balancermember{"${::fqdn}-readonly":
|
||||||
|
listening_service => 'galera_readonly_cluster',
|
||||||
|
server_names => $::hostname,
|
||||||
|
ipaddresses => $api_eth,
|
||||||
|
ports => '3306',
|
||||||
|
options =>
|
||||||
|
inline_template('check inter 2000 rise 2 fall 5 port 9200 <% if @hostname == @galera_master_name -%>backup<% end %>')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,6 +233,7 @@ class cloud::loadbalancer(
|
|||||||
$vip_public_ip = ['127.0.0.1'],
|
$vip_public_ip = ['127.0.0.1'],
|
||||||
$vip_internal_ip = false,
|
$vip_internal_ip = false,
|
||||||
$galera_ip = ['127.0.0.1'],
|
$galera_ip = ['127.0.0.1'],
|
||||||
|
$galera_slave = false,
|
||||||
# Deprecated parameters
|
# Deprecated parameters
|
||||||
$keepalived_interface = false,
|
$keepalived_interface = false,
|
||||||
$keepalived_ipvs = false,
|
$keepalived_ipvs = false,
|
||||||
@ -500,6 +501,21 @@ class cloud::loadbalancer(
|
|||||||
},
|
},
|
||||||
bind_options => $galera_bind_options,
|
bind_options => $galera_bind_options,
|
||||||
}
|
}
|
||||||
|
if $galera_slave {
|
||||||
|
haproxy::listen { 'galera_readonly_cluster':
|
||||||
|
ipaddress => $galera_ip,
|
||||||
|
ports => 3307,
|
||||||
|
options => {
|
||||||
|
'maxconn' => '1000',
|
||||||
|
'mode' => 'tcp',
|
||||||
|
'balance' => 'roundrobin',
|
||||||
|
'option' => ['tcpka', 'tcplog', 'httpchk'], #httpchk mandatory expect 200 on port 9000
|
||||||
|
'timeout client' => '400s',
|
||||||
|
'timeout server' => '400s',
|
||||||
|
},
|
||||||
|
bind_options => $galera_bind_options,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Allow HAProxy to bind to a non-local IP address
|
# Allow HAProxy to bind to a non-local IP address
|
||||||
$haproxy_sysctl_settings = {
|
$haproxy_sysctl_settings = {
|
||||||
|
@ -26,6 +26,7 @@ describe 'cloud::compute::api' do
|
|||||||
"class { 'cloud::compute':
|
"class { 'cloud::compute':
|
||||||
availability_zone => 'MyZone',
|
availability_zone => 'MyZone',
|
||||||
nova_db_host => '10.0.0.1',
|
nova_db_host => '10.0.0.1',
|
||||||
|
nova_db_use_slave => false,
|
||||||
nova_db_user => 'nova',
|
nova_db_user => 'nova',
|
||||||
nova_db_password => 'secrete',
|
nova_db_password => 'secrete',
|
||||||
rabbit_hosts => ['10.0.0.1'],
|
rabbit_hosts => ['10.0.0.1'],
|
||||||
@ -75,6 +76,24 @@ describe 'cloud::compute::api' do
|
|||||||
should contain_nova_config('DEFAULT/glance_num_retries').with_value('10')
|
should contain_nova_config('DEFAULT/glance_num_retries').with_value('10')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not configure nova db slave' do
|
||||||
|
should contain_nova_config('database/slave_connection').with('ensure' => 'absent')
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when enabling nova db slave" do
|
||||||
|
let :pre_condition do
|
||||||
|
"class { 'cloud::compute':
|
||||||
|
nova_db_host => '10.0.0.1',
|
||||||
|
nova_db_use_slave => true,
|
||||||
|
nova_db_user => 'nova',
|
||||||
|
nova_db_password => 'secrete' }"
|
||||||
|
end
|
||||||
|
it 'configure nova db slave' do
|
||||||
|
should contain_nova_config('database/slave_connection').with(
|
||||||
|
'value' => 'mysql://nova:secrete@10.0.0.1:3307/nova?charset=utf8')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it 'configure neutron on compute node' do
|
it 'configure neutron on compute node' do
|
||||||
should contain_class('nova::network::neutron').with(
|
should contain_class('nova::network::neutron').with(
|
||||||
:neutron_admin_password => 'secrete',
|
:neutron_admin_password => 'secrete',
|
||||||
|
@ -66,6 +66,7 @@ describe 'cloud::loadbalancer' do
|
|||||||
:spice_port => '6082',
|
:spice_port => '6082',
|
||||||
:vip_public_ip => '10.0.0.1',
|
:vip_public_ip => '10.0.0.1',
|
||||||
:galera_ip => '10.0.0.2',
|
:galera_ip => '10.0.0.2',
|
||||||
|
:galera_slave => false,
|
||||||
:horizon_ssl => false,
|
:horizon_ssl => false,
|
||||||
:horizon_ssl_port => false,
|
:horizon_ssl_port => false,
|
||||||
:ks_ceilometer_public_port => '8777',
|
:ks_ceilometer_public_port => '8777',
|
||||||
@ -201,7 +202,7 @@ describe 'cloud::loadbalancer' do
|
|||||||
)}
|
)}
|
||||||
end # configure monitor haproxy listen
|
end # configure monitor haproxy listen
|
||||||
|
|
||||||
context 'configure monitor haproxy listen' do
|
context 'configure galera haproxy listen' do
|
||||||
it { should contain_haproxy__listen('galera_cluster').with(
|
it { should contain_haproxy__listen('galera_cluster').with(
|
||||||
:ipaddress => params[:galera_ip],
|
:ipaddress => params[:galera_ip],
|
||||||
:ports => '3306',
|
:ports => '3306',
|
||||||
@ -216,6 +217,28 @@ describe 'cloud::loadbalancer' do
|
|||||||
)}
|
)}
|
||||||
end # configure monitor haproxy listen
|
end # configure monitor haproxy listen
|
||||||
|
|
||||||
|
context 'not configure galera slave haproxy listen' do
|
||||||
|
it { should_not contain_haproxy__listen('galera_readonly_cluster') }
|
||||||
|
end # configure monitor haproxy listen
|
||||||
|
|
||||||
|
context 'configure galera slave haproxy listen' do
|
||||||
|
before do
|
||||||
|
params.merge!( :galera_slave => true )
|
||||||
|
end
|
||||||
|
it { should contain_haproxy__listen('galera_readonly_cluster').with(
|
||||||
|
:ipaddress => params[:galera_ip],
|
||||||
|
:ports => '3307',
|
||||||
|
:options => {
|
||||||
|
'maxconn' => '1000',
|
||||||
|
'mode' => 'tcp',
|
||||||
|
'balance' => 'roundrobin',
|
||||||
|
'option' => ['tcpka','tcplog','httpchk'],
|
||||||
|
'timeout client' => '400s',
|
||||||
|
'timeout server' => '400s'
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
end # configure monitor haproxy listen
|
||||||
|
|
||||||
# test backward compatibility
|
# test backward compatibility
|
||||||
context 'configure OpenStack binding on public network only' do
|
context 'configure OpenStack binding on public network only' do
|
||||||
it { should contain_haproxy__listen('spice_cluster').with(
|
it { should contain_haproxy__listen('spice_cluster').with(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user