Make MySQL ignore lost+found directory in its datadir

This commit introduces optional ignore_db_dirs parameter that can be passed to
mysql::server. It is expected to be an array and is empty by default.

Change-Id: Ic8815b89fea41182692f9f8fafd07bbe6ca15af6
Closes-Bug: 1484552
This commit is contained in:
Bartłomiej Piotrowski 2015-09-25 13:30:14 +02:00
parent 2a92075c2a
commit fb100ee828
6 changed files with 37 additions and 5 deletions

View File

@ -11,10 +11,11 @@
# [*config_file*] - my.cnf configuration file path.
# [*socket*] - mysql socket.
# [*datadir*] - path to datadir.
# [*ssl] - enable ssl
# [*ssl_ca] - path to ssl-ca
# [*ssl_cert] - path to ssl-cert
# [*ssl_key] - path to ssl-key
# [*ssl*] - enable ssl
# [*ssl_ca*] - path to ssl-ca
# [*ssl_cert*] - path to ssl-cert
# [*ssl_key*] - path to ssl-key
# [*ignore_db_dirs*] - array of directories to ignore in datadir.
#
# Actions:
#
@ -49,6 +50,7 @@ class mysql::config(
$server_id = $mysql::params::server_id,
$debug = $mysql::params::debug,
$wait_timeout = $mysql::params::wait_timeout,
$ignore_db_dirs = $mysql::params::ignore_db_dirs,
) inherits mysql::params {
$mysql_buffer_pool_size = $::mysql::params::mysql_buffer_pool_size
@ -59,6 +61,10 @@ class mysql::config(
$myisam_sort_buffer_size = $::mysql::params::myisam_sort_buffer_size
$open_files_limit = $::mysql::params::open_files_limit
if ! is_array($ignore_db_dirs) {
fail('The ignore_db_dirs parameter is expected to be an array')
}
if $custom_setup_class != "pacemaker_mysql" {
File {
owner => 'root',

View File

@ -32,6 +32,7 @@ class mysql::params {
$open_files_limit = '102400'
$max_connections = '3000'
$debug = false
$ignore_db_dirs = []
case $::osfamily {
'RedHat': {

View File

@ -41,6 +41,7 @@ class mysql::server (
$bind_address = '0.0.0.0',
$use_syslog = true,
$wait_timeout = $mysql::params::wait_timeout,
$ignore_db_dirs = $mysql::params::ignore_db_dirs,
) inherits mysql::params {
if ($config_hash['config_file']) {

View File

@ -22,6 +22,11 @@ port = <%= @port %>
basedir = <%= @basedir %>
datadir = <%= @datadir %>
tmpdir = /tmp
<% if @ignore_db_dirs and (@ignore_db_dirs.length > 0) %>
<% @ignore_db_dirs.each do |directory| %>
ignore-db-dir = <%= directory %>
<% end %>
<% end %>
skip-external-locking
bind-address = <%= @bind_address %>
max_allowed_packet = 256M

View File

@ -53,6 +53,12 @@ if $enabled {
$config_hash_real = { }
}
if '/var/lib/mysql' in split($::mounts, ',') {
$ignore_db_dirs = ['lost+found']
} else {
$ignore_db_dirs = []
}
class { 'mysql::server':
bind_address => '0.0.0.0',
etc_root_password => true,
@ -68,6 +74,7 @@ if $enabled {
mysql_skip_name_resolve => $mysql_skip_name_resolve,
use_syslog => $use_syslog,
config_hash => $config_hash_real,
ignore_db_dirs => $ignore_db_dirs,
}
class { 'osnailyfacter::mysql_user':

View File

@ -4,6 +4,12 @@ manifest = 'database/database.pp'
describe manifest do
shared_examples 'catalog' do
let(:facts) {
Noop.ubuntu_facts.merge({
:mounts => '/,/boot,/var/log,/var/lib/glance,/var/lib/mysql'
})
}
let(:endpoints) do
Noop.hiera('network_scheme', {}).fetch('endpoints', {})
end
@ -24,7 +30,7 @@ describe manifest 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
it "should declare osnailyfacter::mysql_user with correct other_networks" do
expect(subject).to contain_class('osnailyfacter::mysql_user').with(
'user' => 'root',
'access_networks' => access_networks,
@ -37,6 +43,12 @@ describe manifest do
).that_comes_before('Osnailyfacter::Mysql_user')
end
it "should configure mysql to ignore lost+found directory" do
expect(subject).to contain_class('mysql::server').with(
'ignore_db_dirs' => ['lost+found']
).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]') }