From 520a7ee6e87e5262e419e6a451c93e789d232358 Mon Sep 17 00:00:00 2001 From: Artem Panchenko Date: Fri, 4 Sep 2015 11:18:30 +0300 Subject: [PATCH] Use 'mgmt/database' network for Galera cluster Configure Galera to use network with 'mgmt/database' role for database replication. Also it should listen for connections only on IP from that network. Change-Id: I375e94b5da82276207a49ac28b5ce306904e1293 Closes-bug: #1492158 --- deployment/puppet/galera/templates/wsrep.cnf.erb | 1 + .../osnailyfacter/modular/database/database.pp | 2 +- tests/noop/spec/hosts/database/database_spec.rb | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/deployment/puppet/galera/templates/wsrep.cnf.erb b/deployment/puppet/galera/templates/wsrep.cnf.erb index a4ff1063a7..a892b15eeb 100644 --- a/deployment/puppet/galera/templates/wsrep.cnf.erb +++ b/deployment/puppet/galera/templates/wsrep.cnf.erb @@ -61,6 +61,7 @@ wsrep_sst_auth=<%= @mysql_user %>:<%= @mysql_password %> <% end -%> wsrep_node_address=<%= @node_address %> wsrep_provider_options="gcache.size = <%= [256, @gcache_factor.to_i*64, 2048].sort[1] %>M" +wsrep_provider_options="gmcast.listen_addr = tcp://<%= @node_address %>:<%= @gcomm_port.to_s %>" <% if @wsrep_sst_method =~ /xtrabackup/ -%> [xtrabackup] diff --git a/deployment/puppet/osnailyfacter/modular/database/database.pp b/deployment/puppet/osnailyfacter/modular/database/database.pp index 6ff95ad1e1..0420849ea3 100644 --- a/deployment/puppet/osnailyfacter/modular/database/database.pp +++ b/deployment/puppet/osnailyfacter/modular/database/database.pp @@ -19,7 +19,7 @@ $mysql_database_password = $mysql_hash['root_password'] $enabled = pick($mysql_hash['enabled'], true) $galera_node_address = get_network_role_property('mgmt/database', 'ipaddr') -$galera_nodes = keys(get_node_to_ipaddr_map_by_network_role(hiera_hash('database_nodes'), 'mgmt/database')) +$galera_nodes = values(get_node_to_ipaddr_map_by_network_role(hiera_hash('database_nodes'), 'mgmt/database')) $galera_primary_controller = hiera('primary_database', $primary_controller) $mysql_bind_address = '0.0.0.0' $galera_cluster_name = 'openstack' diff --git a/tests/noop/spec/hosts/database/database_spec.rb b/tests/noop/spec/hosts/database/database_spec.rb index f9543d5b0b..088f7821e5 100644 --- a/tests/noop/spec/hosts/database/database_spec.rb +++ b/tests/noop/spec/hosts/database/database_spec.rb @@ -16,6 +16,14 @@ describe manifest do access_networks = ['localhost', '127.0.0.1', '240.0.0.0/255.255.0.0'] + other_networks.split(' ') end + let(:database_nodes) do + Noop.hiera('database_nodes') + end + + let(:galera_nodes) do + (Noop.puppet_function 'get_node_to_ipaddr_map_by_network_role', database_nodes, 'mgmt/database').values + end + it "should delcare osnailyfacter::mysql_user with correct other_networks" do expect(subject).to contain_class('osnailyfacter::mysql_user').with( 'user' => 'root', @@ -23,7 +31,12 @@ describe manifest do ).that_comes_before('Exec[initial_access_config]') end - it { should contain_class('mysql::server').that_comes_before('Osnailyfacter::Mysql_user') } + it "should configure Galera to use mgmt/database network for replication" do + expect(subject).to contain_class('mysql::server').with( + 'galera_nodes' => galera_nodes, + ).that_comes_before('Osnailyfacter::Mysql_user') + end + it { should contain_class('osnailyfacter::mysql_access') } it { should contain_class('openstack::galera::status').that_comes_before('Haproxy_backend_status[mysql]') } it { should contain_haproxy_backend_status('mysql').that_comes_before('Class[osnailyfacter::mysql_access]') }