Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop support for hybrid db setups and logical backups #948

Merged
merged 3 commits into from
Nov 8, 2024
Merged
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
13 changes: 4 additions & 9 deletions definitions/checks/restore/validate_backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,30 @@ def required_files(backup)
def required_katello_files(backup)
backup_files_message(
backup.katello_online_files.join(', '),
backup.katello_offline_files.join(', '),
[backup.katello_online_files + backup.katello_offline_files].join(', ')
backup.katello_offline_files.join(', ')
)
end

def required_fpc_files(backup)
backup_files_message(
backup.fpc_online_files.join(', '),
backup.fpc_offline_files.join(', '),
[backup.fpc_online_files + backup.fpc_offline_files].join(', ')
backup.fpc_offline_files.join(', ')
)
end

def required_foreman_files(backup)
backup_files_message(
backup.foreman_online_files.join(', '),
backup.foreman_offline_files.join(', '),
[backup.foreman_online_files + backup.foreman_offline_files].join(', ')
backup.foreman_offline_files.join(', ')
)
end

def backup_files_message(online_files, offline_files, logical_files)
def backup_files_message(online_files, offline_files)
message = ''
message += 'An online or remote database backup directory contains: '
message += "#{online_files}\n"
message += 'An offline backup directory contains: '
message += "#{offline_files}\n"
message += 'A logical backup directory contains: '
message += "#{logical_files}\n"
message
end
end
Expand Down
59 changes: 3 additions & 56 deletions lib/foreman_maintain/utils/backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,15 @@ def check_backup
end

def valid_fpc_backup?
fpc_online_backup? || fpc_standard_backup? || fpc_logical_backup? || \
fpc_hybrid_db_backup?
fpc_online_backup? || fpc_standard_backup?
end

def valid_katello_backup?
katello_online_backup? || katello_standard_backup? || katello_logical_backup? || \
# Katello can have setup where some of dbs are external but not all
katello_hybrid_db_backup?
katello_online_backup? || katello_standard_backup?
end

def valid_foreman_backup?
foreman_standard_backup? || foreman_online_backup? || foreman_logical_backup?
foreman_standard_backup? || foreman_online_backup?
end

def check_file_existence(existence_map)
Expand Down Expand Up @@ -111,19 +108,6 @@ def katello_online_backup?
:absent => absent)
end

def katello_logical_backup?
present = [:pgsql_data, :candlepin_dump, :foreman_dump, :pulpcore_dump]
absent = []
check_file_existence(:present => present,
:absent => absent)
end

def katello_hybrid_db_backup?
all_dbs = { :pgsql_data => %w[candlepin foreman pulpcore] }
present, absent = dumps_for_hybrid_db_setup(all_dbs)
check_file_existence(:present => present, :absent => absent)
end

def fpc_standard_backup?
present = [:pgsql_data]
absent = [:candlepin_dump, :foreman_dump, :pulpcore_dump]
Expand All @@ -137,19 +121,6 @@ def fpc_online_backup?
check_file_existence(:present => present, :absent => absent)
end

def fpc_logical_backup?
present = [:pulpcore_dump, :pgsql_data]
absent = [:candlepin_dump, :foreman_dump]
check_file_existence(:present => present, :absent => absent)
end

def fpc_hybrid_db_backup?
all_dbs = { :pgsql_data => ['pulpcore'] }
present, absent = dumps_for_hybrid_db_setup(all_dbs)
absent.concat [:candlepin_dump, :foreman_dump]
check_file_existence(:present => present, :absent => absent)
end

def foreman_standard_backup?
check_file_existence(:present => [:pgsql_data],
:absent => [:candlepin_dump, :foreman_dump, :pulpcore_dump])
Expand All @@ -160,30 +131,6 @@ def foreman_online_backup?
:absent => [:candlepin_dump, :pgsql_data, :pulpcore_dump])
end

def foreman_logical_backup?
check_file_existence(:present => [:pgsql_data, :foreman_dump],
:absent => [:candlepin_dump, :pulpcore_dump])
end

def dumps_for_hybrid_db_setup(dbs_hash)
present = []
absent = []
dbs_hash.each do |data_file, dbs|
dbs.each do |db|
feature_label = "#{db}_database"
dump_file = "#{db}_dump"
if feature(feature_label.to_sym).local?
present |= [data_file]
absent << dump_file.to_sym
else
present << dump_file.to_sym
end
end
absent |= [data_file] unless present.include?(data_file)
end
[present, absent]
end

def validate_hostname?
# make sure that the system hostname is the same as the backup
metadata.fetch('hostname', nil) == hostname
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
120 changes: 0 additions & 120 deletions test/lib/utils/backup_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,18 @@ module ForemanMaintain
file_path = '../../files/backups/katello_online_pulpcore_database'
File.expand_path(file_path, File.dirname(__FILE__))
end
let(:katello_logical) do
file_path = '../../files/backups/katello_logical_pulpcore_database'
File.expand_path(file_path, File.dirname(__FILE__))
end
let(:katello_hybrid_db_backup) do
file_path = '../../files/backups/katello_hybrid_db_backup/'
File.expand_path(file_path, File.dirname(__FILE__))
end
let(:foreman_standard) do
File.expand_path('../../files/backups/foreman_standard', File.dirname(__FILE__))
end
let(:foreman_online) do
File.expand_path('../../files/backups/foreman_online', File.dirname(__FILE__))
end
let(:foreman_logical) do
File.expand_path('../../files/backups/foreman_logical', File.dirname(__FILE__))
end
let(:fpc_standard) do
File.expand_path('../../files/backups/fpc_standard_pulpcore_database', File.dirname(__FILE__))
end
let(:fpc_online) do
File.expand_path('../../files/backups/fpc_online_pulpcore_database', File.dirname(__FILE__))
end
let(:fpc_logical) do
File.expand_path('../../files/backups/fpc_logical_pulpcore_database', File.dirname(__FILE__))
end
let(:fpc_hybrid) do
File.expand_path('../../files/backups/fpc_hybrid_database_backup', File.dirname(__FILE__))
end
let(:no_configs) do
File.expand_path('../../files/backups/no_configs', File.dirname(__FILE__))
end
Expand All @@ -58,168 +41,65 @@ def assume_feature_absent(label)
ForemanMaintain.detector.stubs(:feature).with(label).returns(false)
end

def feature_with_local_method(label, return_value)
fake_feature = Minitest::Mock.new
ret_hash = { 'host' => 'abc.example.com' }
fake_feature.expect(:configuration, ret_hash)
fake_feature.expect(:local?, return_value)
ForemanMaintain.detector.stubs(:feature).with(label).returns(fake_feature)
end

it 'Validates katello standard backup' do
assume_feature_present(:pulpcore_database)
kat_stand_backup = subject.new(katello_standard)
assert kat_stand_backup.katello_standard_backup?
refute kat_stand_backup.katello_online_backup?
refute kat_stand_backup.katello_logical_backup?
refute kat_stand_backup.foreman_online_backup?
refute kat_stand_backup.foreman_logical_backup?
refute kat_stand_backup.fpc_online_backup?
refute kat_stand_backup.fpc_logical_backup?
end

it 'Validates katello online backup' do
assume_feature_present(:pulpcore_database)
kat_online_backup = subject.new(katello_online)
refute kat_online_backup.katello_standard_backup?
assert kat_online_backup.katello_online_backup?
refute kat_online_backup.katello_logical_backup?
refute kat_online_backup.foreman_standard_backup?
refute kat_online_backup.foreman_online_backup?
refute kat_online_backup.foreman_logical_backup?
refute kat_online_backup.fpc_standard_backup?
refute kat_online_backup.fpc_online_backup?
refute kat_online_backup.fpc_logical_backup?
end

it 'Validates katello logical backup' do
assume_feature_present(:pulpcore_database)
kat_logical_backup = subject.new(katello_logical)
refute kat_logical_backup.katello_standard_backup?
refute kat_logical_backup.katello_online_backup?
assert kat_logical_backup.katello_logical_backup?
refute kat_logical_backup.foreman_standard_backup?
refute kat_logical_backup.foreman_online_backup?
refute kat_logical_backup.foreman_logical_backup?
refute kat_logical_backup.fpc_standard_backup?
refute kat_logical_backup.fpc_online_backup?
refute kat_logical_backup.fpc_logical_backup?
end

it 'Validates katello hybrid db backup' do
assume_feature_present(:pulpcore_database)
assume_feature_present(:candlepin_database)
assume_feature_present(:foreman_database)
feature_with_local_method(:pulpcore_database, true)
feature_with_local_method(:candlepin_database, false)
feature_with_local_method(:foreman_database, false)
kat_hybrid_db_backup = subject.new(katello_hybrid_db_backup)
refute kat_hybrid_db_backup.katello_standard_backup?
refute kat_hybrid_db_backup.katello_online_backup?
refute kat_hybrid_db_backup.katello_logical_backup?
assert kat_hybrid_db_backup.katello_hybrid_db_backup?
refute kat_hybrid_db_backup.foreman_standard_backup?
refute kat_hybrid_db_backup.foreman_online_backup?
refute kat_hybrid_db_backup.foreman_logical_backup?
refute kat_hybrid_db_backup.fpc_standard_backup?
refute kat_hybrid_db_backup.fpc_online_backup?
refute kat_hybrid_db_backup.fpc_logical_backup?
end

it 'Validates foreman standard backup' do
foreman_standard_backup = subject.new(foreman_standard)
assert foreman_standard_backup.katello_standard_backup?
refute foreman_standard_backup.katello_online_backup?
refute foreman_standard_backup.katello_logical_backup?
assert foreman_standard_backup.foreman_standard_backup?
refute foreman_standard_backup.foreman_online_backup?
refute foreman_standard_backup.foreman_logical_backup?
assert foreman_standard_backup.fpc_standard_backup?
refute foreman_standard_backup.fpc_online_backup?
refute foreman_standard_backup.fpc_logical_backup?
end

it 'Validates foreman online backup' do
assume_feature_absent(:pulpcore_database)
foreman_online_backup = subject.new(foreman_online)
refute foreman_online_backup.katello_standard_backup?
refute foreman_online_backup.katello_online_backup?
refute foreman_online_backup.katello_logical_backup?
refute foreman_online_backup.foreman_standard_backup?
assert foreman_online_backup.foreman_online_backup?
refute foreman_online_backup.foreman_logical_backup?
refute foreman_online_backup.fpc_standard_backup?
refute foreman_online_backup.fpc_online_backup?
refute foreman_online_backup.fpc_logical_backup?
end

it 'Validates foreman logical backup' do
assume_feature_absent(:pulpcore_database)
foreman_logical_backup = subject.new(foreman_logical)
refute foreman_logical_backup.katello_standard_backup?
refute foreman_logical_backup.katello_online_backup?
refute foreman_logical_backup.katello_logical_backup?
refute foreman_logical_backup.foreman_standard_backup?
refute foreman_logical_backup.foreman_online_backup?
assert foreman_logical_backup.foreman_logical_backup?
refute foreman_logical_backup.fpc_standard_backup?
refute foreman_logical_backup.fpc_online_backup?
refute foreman_logical_backup.fpc_logical_backup?
end

it 'Validates fpc standard backup' do
assume_feature_present(:pulpcore_database)
fpc_standard_backup = subject.new(fpc_standard)
refute fpc_standard_backup.katello_online_backup?
refute fpc_standard_backup.katello_logical_backup?
refute fpc_standard_backup.foreman_online_backup?
refute fpc_standard_backup.foreman_logical_backup?
assert fpc_standard_backup.fpc_standard_backup?
refute fpc_standard_backup.fpc_online_backup?
refute fpc_standard_backup.fpc_logical_backup?
end

it 'Validates fpc online backup' do
assume_feature_present(:pulpcore_database)
fpc_online_backup = subject.new(fpc_online)
refute fpc_online_backup.katello_standard_backup?
refute fpc_online_backup.katello_online_backup?
refute fpc_online_backup.katello_logical_backup?
refute fpc_online_backup.foreman_standard_backup?
refute fpc_online_backup.foreman_online_backup?
refute fpc_online_backup.foreman_logical_backup?
refute fpc_online_backup.fpc_standard_backup?
assert fpc_online_backup.fpc_online_backup?
refute fpc_online_backup.fpc_logical_backup?
end

it 'Validates fpc logical backup' do
assume_feature_present(:pulpcore_database)
fpc_logical_backup = subject.new(fpc_logical)
refute fpc_logical_backup.katello_standard_backup?
refute fpc_logical_backup.katello_online_backup?
refute fpc_logical_backup.katello_logical_backup?
refute fpc_logical_backup.foreman_standard_backup?
refute fpc_logical_backup.foreman_online_backup?
refute fpc_logical_backup.foreman_logical_backup?
refute fpc_logical_backup.fpc_standard_backup?
refute fpc_logical_backup.fpc_online_backup?
assert fpc_logical_backup.fpc_logical_backup?
end

it 'Validates fpc hybrid db backup' do
feature_with_local_method(:pulpcore_database, true)
fpc_hybrid_db_backup = subject.new(fpc_hybrid)
assert fpc_hybrid_db_backup.katello_standard_backup?
refute fpc_hybrid_db_backup.katello_online_backup?
refute fpc_hybrid_db_backup.katello_logical_backup?
assert fpc_hybrid_db_backup.foreman_standard_backup?
refute fpc_hybrid_db_backup.foreman_online_backup?
refute fpc_hybrid_db_backup.foreman_logical_backup?
assert fpc_hybrid_db_backup.fpc_standard_backup?
refute fpc_hybrid_db_backup.fpc_online_backup?
refute fpc_hybrid_db_backup.fpc_logical_backup?
assert fpc_hybrid_db_backup.fpc_hybrid_db_backup?
end

it 'does not validate backup without config_files.tar.gz' do
Expand Down
Loading