Skip to content

Commit

Permalink
always validate hostname from metadata
Browse files Browse the repository at this point in the history
We introduced this metadata field in
#536 which landed in
0.9.1, which is old enough to rely on and not care for backups that
don't have this metadata field
  • Loading branch information
evgeni committed Jun 4, 2024
1 parent 8dfec8f commit dcfe13a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
19 changes: 1 addition & 18 deletions lib/foreman_maintain/utils/backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,24 +183,7 @@ def dumps_for_hybrid_db_setup(dbs_hash)

def validate_hostname?
# make sure that the system hostname is the same as the backup
hostname_from_metadata = metadata.fetch('hostname', nil)
if hostname_from_metadata
hostname_from_metadata == hostname
else
config_tarball = file_map[:config_files][:path]
tar_cmd = "tar zxf #{config_tarball} etc/httpd/conf/httpd.conf --to-stdout --occurrence=1"
status, httpd_config = execute_with_status(tar_cmd)

# Incremental backups sometimes don't include httpd.conf. Since a "base" backup
# is restored before an incremental, we can assume that the hostname is checked
# during the base backup restore
if status == 0
match = httpd_config.match(/\s*ServerName\s+"*([^ "]+)"*\s*$/)
match ? match[1] == hostname : false
else
true
end
end
metadata.fetch('hostname', nil) == hostname
end

def validate_interfaces
Expand Down
22 changes: 22 additions & 0 deletions test/files/backups/katello_standard_pulpcore_database/metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
os_version: CentOS Stream 8
plugin_list:
- foreman-tasks-9.1.1
- foreman_puppet-6.3.0
- foreman_remote_execution-13.1.0
- katello-4.13.0.pre.master
proxy_features:
- dynflow
- logs
- pulpcore
- puppet
- puppetca
- script
incremental: false
online: false
hostname: sat-6.example.com
proxy_config:
dhcp: false
dhcp_interface: eth0
dns: false
dns_interface: eth0

0 comments on commit dcfe13a

Please sign in to comment.