Skip to content

Commit f3af12f

Browse files
authored
Merge pull request #1472 from puppetlabs/IAC-1595-MySQL-maintenance
(IAC-1595) MySQL maintenance
2 parents 2134953 + 895ad50 commit f3af12f

File tree

11 files changed

+49
-27
lines changed

11 files changed

+49
-27
lines changed

.github/workflows/nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
if: ${{ github.repository_owner == 'puppetlabs' }}
6060
run: |
6161
if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then
62-
buildevents cmd $TRACE_ID $STEP_ID matrix_from_metadata -- bundle exec matrix_from_metadata_v2 --exclude-platforms '["Debian-9", "Debian-10", "Debian-11"]'
62+
echo "::set-output name=matrix::{'platforms':[{'label':'AlmaLinux-8','provider':'provision::docker','image':'litmusimage/almalinux:8'},{'label':'CentOS-7','provider':'provision::docker','image':'litmusimage/centos:7'},{'label':'CentOS-8','provider':'provision::docker','image':'litmusimage/centos:stream8'},{'label':'Debian-10','provider':'provision::provision_service','image':'debian-10'},{'label':'Debian-11','provider':'provision::provision_service','image':'debian-11'},{'label':'Debian-9','provider':'provision::provision_service','image':'debian-9'},{'label':'OracleLinux-6','provider':'provision::docker','image':'litmusimage/oraclelinux:6'},{'label':'OracleLinux-7','provider':'provision::docker','image':'litmusimage/oraclelinux:7'},{'label':'RedHat-7','provider':'provision::provision_service','image':'rhel-7'},{'label':'RedHat-8','provider':'provision::provision_service','image':'rhel-8'},{'label':'Rocky-8','provider':'provision::docker','image':'litmusimage/rockylinux:8'},{'label':'SLES-12','provider':'provision::provision_service','image':'sles-12'},{'label':'SLES-15','provider':'provision::provision_service','image':'sles-15'},{'label':'Scientific-6','provider':'provision::docker','image':'litmusimage/scientificlinux:6'},{'label':'Scientific-7','provider':'provision::docker','image':'litmusimage/scientificlinux:7'},{'label':'Ubuntu-18.04','provider':'provision::docker','image':'litmusimage/ubuntu:18.04'},{'label':'Ubuntu-20.04','provider':'provision::provision_service','image':'ubuntu-2004-lts'}],'collection':['puppet6-nightly','puppet7-nightly']}"
6363
else
6464
echo "::set-output name=matrix::{}"
6565
fi

.github/workflows/pr_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
id: get-matrix
6262
run: |
6363
if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then
64-
buildevents cmd $TRACE_ID $STEP_ID matrix_from_metadata -- bundle exec matrix_from_metadata_v2 --exclude-platforms '["Debian-9", "Debian-10", "Debian-11"]'
64+
echo "::set-output name=matrix::{'platforms':[{'label':'AlmaLinux-8','provider':'provision::docker','image':'litmusimage/almalinux:8'},{'label':'CentOS-7','provider':'provision::docker','image':'litmusimage/centos:7'},{'label':'CentOS-8','provider':'provision::docker','image':'litmusimage/centos:stream8'},{'label':'Debian-10','provider':'provision::provision_service','image':'debian-10'},{'label':'Debian-11','provider':'provision::provision_service','image':'debian-11'},{'label':'Debian-9','provider':'provision::provision_service','image':'debian-9'},{'label':'OracleLinux-6','provider':'provision::docker','image':'litmusimage/oraclelinux:6'},{'label':'OracleLinux-7','provider':'provision::docker','image':'litmusimage/oraclelinux:7'},{'label':'RedHat-7','provider':'provision::provision_service','image':'rhel-7'},{'label':'RedHat-8','provider':'provision::provision_service','image':'rhel-8'},{'label':'Rocky-8','provider':'provision::docker','image':'litmusimage/rockylinux:8'},{'label':'SLES-12','provider':'provision::provision_service','image':'sles-12'},{'label':'SLES-15','provider':'provision::provision_service','image':'sles-15'},{'label':'Scientific-6','provider':'provision::docker','image':'litmusimage/scientificlinux:6'},{'label':'Scientific-7','provider':'provision::docker','image':'litmusimage/scientificlinux:7'},{'label':'Ubuntu-18.04','provider':'provision::docker','image':'litmusimage/ubuntu:18.04'},{'label':'Ubuntu-20.04','provider':'provision::provision_service','image':'ubuntu-2004-lts'}],'collection':['puppet6','puppet7']}"
6565
else
6666
echo "::set-output name=matrix::{}"
6767
fi

lib/puppet/provider/mysql_grant/mysql.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,21 @@ def self.instances
6868
'UPDATE']
6969
sorted_privileges = ['ALL']
7070

71-
# Currently there is an issue with the behaviour of the module which was highlighted by the 'complex test' test case in 'mysql_grant_spec'. The module, upon retrieving all privileges from an
72-
# user, does not take into account that the latest version of mysql now includes dynamic privileges which are returned alongside the original static privileges and are set by 'ALL PRIVILEGES'
73-
# (shortened to 'ALL'). This is a workaround to remove the unnecesary privileges from the sorted_privileges list which is used to check for idempotency in test cases.
71+
# The following two elsif blocks of code are a workaround for issue #1474.
7472
elsif sorted_privileges == ['ALL', 'APPLICATION_PASSWORD_ADMIN', 'AUDIT_ABORT_EXEMPT', 'AUDIT_ADMIN', 'AUTHENTICATION_POLICY_ADMIN', 'BACKUP_ADMIN', 'BINLOG_ADMIN', 'BINLOG_ENCRYPTION_ADMIN',
7573
'CLONE_ADMIN', 'CONNECTION_ADMIN', 'ENCRYPTION_KEY_ADMIN', 'FLUSH_OPTIMIZER_COSTS', 'FLUSH_STATUS', 'FLUSH_TABLES', 'FLUSH_USER_RESOURCES',
7674
'GROUP_REPLICATION_ADMIN', 'GROUP_REPLICATION_STREAM', 'INNODB_REDO_LOG_ARCHIVE', 'INNODB_REDO_LOG_ENABLE', 'PASSWORDLESS_USER_ADMIN', 'PERSIST_RO_VARIABLES_ADMIN',
7775
'REPLICATION_APPLIER', 'REPLICATION_SLAVE_ADMIN', 'RESOURCE_GROUP_ADMIN', 'RESOURCE_GROUP_USER', 'ROLE_ADMIN', 'SERVICE_CONNECTION_ADMIN',
7876
'SESSION_VARIABLES_ADMIN', 'SET_USER_ID', 'SHOW_ROUTINE', 'SYSTEM_USER', 'SYSTEM_VARIABLES_ADMIN', 'TABLE_ENCRYPTION_ADMIN', 'XA_RECOVER_ADMIN']
7977
sorted_privileges = ['ALL']
78+
79+
elsif sorted_privileges == ['ALL', 'APPLICATION_PASSWORD_ADMIN', 'AUDIT_ABORT_EXEMPT', 'AUDIT_ADMIN', 'AUTHENTICATION_POLICY_ADMIN', 'BACKUP_ADMIN', 'BINLOG_ADMIN', 'BINLOG_ENCRYPTION_ADMIN',
80+
'CLONE_ADMIN', 'CONNECTION_ADMIN', 'ENCRYPTION_KEY_ADMIN', 'FLUSH_OPTIMIZER_COSTS', 'FLUSH_STATUS', 'FLUSH_TABLES', 'FLUSH_USER_RESOURCES',
81+
'GROUP_REPLICATION_ADMIN', 'GROUP_REPLICATION_STREAM', 'INNODB_REDO_LOG_ARCHIVE', 'INNODB_REDO_LOG_ENABLE', 'PASSWORDLESS_USER_ADMIN', 'PERSIST_RO_VARIABLES_ADMIN',
82+
'REPLICATION_APPLIER', 'REPLICATION_SLAVE_ADMIN', 'RESOURCE_GROUP_ADMIN', 'RESOURCE_GROUP_USER', 'ROLE_ADMIN', 'SENSITIVE_VARIABLES_OBSERVER',
83+
'SERVICE_CONNECTION_ADMIN', 'SESSION_VARIABLES_ADMIN', 'SET_USER_ID', 'SHOW_ROUTINE', 'SYSTEM_USER', 'SYSTEM_VARIABLES_ADMIN', 'TABLE_ENCRYPTION_ADMIN',
84+
'XA_RECOVER_ADMIN']
85+
sorted_privileges = ['ALL']
8086
end
8187

8288
instance_configs[name] = {

manifests/backup/xtrabackup.pp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,23 @@
4949
require => Class['mysql::server::root_password'],
5050
}
5151

52-
mysql_grant { "${backupuser}@localhost/*.*":
53-
ensure => $ensure,
54-
user => "${backupuser}@localhost",
55-
table => '*.*',
56-
privileges => ['RELOAD', 'PROCESS', 'LOCK TABLES', 'REPLICATION CLIENT'],
57-
require => Mysql_user["${backupuser}@localhost"],
52+
if $::osfamily == 'debian' and $::operatingsystemmajrelease == '11' {
53+
mysql_grant { "${backupuser}@localhost/*.*":
54+
ensure => $ensure,
55+
user => "${backupuser}@localhost",
56+
table => '*.*',
57+
privileges => ['BINLOG MONITOR', 'RELOAD', 'PROCESS', 'LOCK TABLES'],
58+
require => Mysql_user["${backupuser}@localhost"],
59+
}
60+
}
61+
else {
62+
mysql_grant { "${backupuser}@localhost/*.*":
63+
ensure => $ensure,
64+
user => "${backupuser}@localhost",
65+
table => '*.*',
66+
privileges => ['RELOAD', 'PROCESS', 'LOCK TABLES', 'REPLICATION CLIENT'],
67+
require => Mysql_user["${backupuser}@localhost"],
68+
}
5869
}
5970
}
6071

manifests/params.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@
236236
$ruby_package_name = $facts['os']['release']['major'] ? {
237237
'9' => 'ruby-mysql2', # stretch
238238
'10' => 'ruby-mysql2', # buster
239+
'11' => 'ruby-mysql2', # bullseye
239240
'16.04' => 'ruby-mysql', # xenial
240241
'18.04' => 'ruby-mysql2', # bionic
241242
'20.04' => 'ruby-mysql2', # focal

manifests/server.pp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@
167167
~> Class['mysql::server::service']
168168
}
169169

170-
171170
if $_options['mysqld']['ssl-disable'] {
172171
notify { 'ssl-disable':
173172
message => 'Disabling SSL is evil! You should never ever do this except

spec/acceptance/00_mysql_server_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ class { '::mysql::server':
6464

6565
it 'can be set' do
6666
apply_manifest(pp, catch_failures: true) do |r|
67-
expect(r.stderr).to be_empty
67+
if (os[:family] == 'debian' && os[:release].to_i > 9) && Gem::Version.new(run_shell('puppet --version').stdout) < Gem::Version.new('7.0.0')
68+
expect(r.stderr).to match(%r{locale environment variables were bad; continuing with LANG=C LC_ALL=C})
69+
else
70+
expect(r.stderr).to be_empty
71+
end
6872
end
6973
end
7074
end

spec/acceptance/04_mysql_backup_spec.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class { 'mysql::server::backup':
129129
end
130130

131131
context 'with xtrabackup enabled' do
132-
context 'should work with no errors', if: ((os[:family] == 'debian') || (os[:family] == 'ubuntu' && os[:release] =~ %r{^16\.04|^18\.04}) || (os[:family] == 'redhat' && os[:release].to_i > 7)) do
132+
context 'should work with no errors', if: ((os[:family] == 'debian') || (os[:family] == 'ubuntu') || (os[:family] == 'redhat' && os[:release].to_i > 7)) do
133133
pp = <<-MANIFEST
134134
class { 'mysql::server': root_password => 'password' }
135135
mysql::db { [
@@ -142,11 +142,7 @@ class { 'mysql::server': root_password => 'password' }
142142
}
143143
case $facts['os']['family'] {
144144
/Debian/: {
145-
if versioncmp($::operatingsystemmajrelease, '8') >= 0 {
146-
$source_url = "http://repo.percona.com/apt/percona-release_1.0-22.generic_all.deb"
147-
} else {
148-
$source_url = "http://repo.percona.com/apt/percona-release_latest.${facts['os']['distro']['codename']}_all.deb"
149-
}
145+
$source_url = "http://repo.percona.com/apt/percona-release_latest.${facts['os']['distro']['codename']}_all.deb"
150146
151147
file { '/tmp/percona-release_latest.deb':
152148
ensure => present,
@@ -209,7 +205,7 @@ class { 'mysql::server::backup':
209205
end
210206
end
211207

212-
describe 'xtrabackup.sh', if: Gem::Version.new(mysql_version) < Gem::Version.new('5.7.0') && ((os[:family] == 'debian' && os[:release].to_i >= 9) || (os[:family] == 'ubuntu' && os[:release] =~ %r{^16\.04|^18\.04}) || (os[:family] == 'redhat' && os[:release].to_i > 7)) do # rubocop:disable Layout/LineLength
208+
describe 'xtrabackup.sh', if: Gem::Version.new(mysql_version) < Gem::Version.new('5.7.0') && ((os[:family] == 'debian' && os[:release].to_i >= 9) || (os[:family] == 'ubuntu') || (os[:family] == 'redhat' && os[:release].to_i > 7)) do # rubocop:disable Layout/LineLength
213209
it 'runs xtrabackup.sh full backup with no errors' do
214210
run_shell('/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/xtrabackups/$(date +%F)_full --backup 2>&1 | tee /tmp/xtrabackup_full.log') do |r|
215211
expect(r.exit_code).to be_zero
@@ -254,7 +250,7 @@ class { 'mysql::server::backup':
254250
end
255251

256252
context 'with xtrabackup enabled and incremental backups disabled' do
257-
context 'should work with no errors', if: ((os[:family] == 'debian' && os[:release].to_i >= 9) || (os[:family] == 'ubuntu' && os[:release] =~ %r{^16\.04|^18\.04}) || (os[:family] == 'redhat' && os[:release].to_i > 7)) do # rubocop:disable Layout/LineLength
253+
context 'should work with no errors', if: ((os[:family] == 'debian') || (os[:family] == 'ubuntu') || (os[:family] == 'redhat' && os[:release].to_i > 7)) do
258254
pp = <<-MANIFEST
259255
class { 'mysql::server': root_password => 'password' }
260256
mysql::db { [
@@ -323,7 +319,7 @@ class { 'mysql::server::backup':
323319
end
324320
end
325321

326-
describe 'xtrabackup.sh', if: Gem::Version.new(mysql_version) < Gem::Version.new('5.7.0') && ((os[:family] == 'debian' && os[:release].to_i >= 9) || (os[:family] == 'ubuntu' && os[:release] =~ %r{^16\.04|^18\.04}) || (os[:family] == 'redhat' && os[:release].to_i > 7)) do # rubocop:disable Layout/LineLength
322+
describe 'xtrabackup.sh', if: Gem::Version.new(mysql_version) < Gem::Version.new('5.7.0') && ((os[:family] == 'debian' && os[:release].to_i >= 9) || (os[:family] == 'ubuntu') || (os[:family] == 'redhat' && os[:release].to_i > 7)) do # rubocop:disable Layout/LineLength
327323
it 'runs xtrabackup.sh with no errors' do
328324
run_shell('/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/xtrabackups/$(date +%F_%H-%M-%S) --backup 2>&1 | tee /tmp/xtrabackup.log') do |r|
329325
expect(r.exit_code).to be_zero

spec/acceptance/types/mysql_login_path_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
support_bin_dir = '/root/mysql_login_path'
77
if os[:family] == 'redhat' && os[:release].to_i == 8
88
mysql_version = '8.0'
9-
elsif os[:family] == 'debian' && os[:release] =~ %r{9|10}
9+
elsif os[:family] == 'debian' && os[:release] =~ %r{9|10|11}
1010
mysql_version = '8.0'
11-
elsif os[:family] == 'ubuntu' && os[:release] =~ %r{16\.04|18\.04}
11+
elsif os[:family] == 'ubuntu' && os[:release] =~ %r{18\.04|20\.04}
1212
mysql_version = '5.7'
1313
end
1414

spec/classes/mysql_backup_xtrabackup_spec.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,12 @@ class { 'mysql::server': }
105105
ensure: 'present',
106106
user: 'backupuser@localhost',
107107
table: '*.*',
108-
privileges: ['RELOAD', 'PROCESS', 'LOCK TABLES', 'REPLICATION CLIENT'],
108+
privileges:
109+
if facts[:osfamily] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '11') == 0
110+
['BINLOG MONITOR', 'RELOAD', 'PROCESS', 'LOCK TABLES']
111+
else
112+
['RELOAD', 'PROCESS', 'LOCK TABLES', 'REPLICATION CLIENT']
113+
end,
109114
)
110115
.that_requires('Mysql_user[backupuser@localhost]')
111116
end

spec/spec_helper_acceptance_local.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def export_locales
2727
LitmusHelper.instance.run_shell('echo export LANGUAGE=en_US.UTF-8 >> /etc/profile.d/my-custom.lang.sh')
2828
LitmusHelper.instance.run_shell('echo export LC_COLLATE=C >> /etc/profile.d/my-custom.lang.sh')
2929
LitmusHelper.instance.run_shell('echo export LC_CTYPE=en_US.UTF-8 >> /etc/profile.d/my-custom.lang.sh')
30-
LitmusHelper.instance.run_shell('source /etc/profile.d/my-custom.lang.sh')
30+
LitmusHelper.instance.run_shell('. /etc/profile.d/my-custom.lang.sh')
3131
LitmusHelper.instance.run_shell('echo export LC_ALL="C" >> ~/.bashrc')
32-
LitmusHelper.instance.run_shell('source ~/.bashrc')
32+
LitmusHelper.instance.run_shell('. ~/.bashrc')
3333
end
3434

3535
def fetch_charset

0 commit comments

Comments
 (0)