Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/puppet/provider/mysql_database/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def self.instances(managed_databases = nil)
attributes[k] = v
end
rescue Puppet::ExecutionFailure => e
raise unless e.message.include?('Unknown database')
# MySQL/MariaDB error 1049 is ER_BAD_DB_ERROR ("Unknown database"). Match on the numeric error code to handle localized error text.
raise unless e.message.include?('ERROR 1049 ')

next
end
Expand Down
10 changes: 10 additions & 0 deletions spec/unit/puppet/provider/mysql_database/mysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@
expect(databases).to eq(['managed_existing'])
end

it 'skips managed databases that no longer exist under a non-English locale' do
allow(provider.class).to receive(:mysql_caller).with(["show variables like '%_database'", 'managed_existing'], 'regular').and_return("character_set_database latin1\ncollation_database latin1_swedish_ci\nskip_show_database OFF") # rubocop:disable Layout/LineLength
allow(provider.class).to receive(:mysql_caller)
.with(["show variables like '%_database'", 'managed_missing'], 'regular')
.and_raise(Puppet::ExecutionFailure, "Execution of '/usr/bin/mariadb -NBe show variables like '%_database' managed_missing' returned 1: ERROR 1049 (42000): Unbekannte Datenbank 'managed_missing'") # rubocop:disable Layout/LineLength

databases = provider.class.instances(['managed_existing', 'managed_missing']).map(&:name)
expect(databases).to eq(['managed_existing'])
end

it 're-raises unexpected database lookup failures' do
allow(provider.class).to receive(:mysql_caller).with(["show variables like '%_database'", 'managed_broken'], 'regular').and_raise(Puppet::ExecutionFailure, 'ERROR 1044 (42000): Access denied')

Expand Down
Loading