Skip to content

Commit f9cf46d

Browse files
committed
(PE-39352) Adding patching service database to backup/restore plans
2025.0 adds the pe-patching-service and pe-patching database. This commit updates the recovery metadata to account for the pe-patching database in 2025.0+ versions.
1 parent 94a2ac6 commit f9cf46d

10 files changed

+125
-7
lines changed

functions/amend_recovery_defaults_by_pe_version.pp

+9-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ function peadm::amend_recovery_defaults_by_pe_version (
44
Boolean $opt_value,
55
) {
66
# work around puppet-lint check_unquoted_string_in_case
7-
$semverrange = SemVerRange('>= 2023.7')
7+
$pe_2025_0 = SemVerRange('>= 2025.0')
8+
$pe_2023_7 = SemVerRange('>= 2023.7')
89
case $pe_version {
9-
$semverrange: {
10+
$pe_2025_0: {
11+
$base_opts + {
12+
'hac' => $opt_value,
13+
'patching' => $opt_value,
14+
}
15+
}
16+
$pe_2023_7: {
1017
$base_opts + {
1118
'hac' => $opt_value,
1219
}

functions/validated_pe_version_for_backup_restore.pp

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ function peadm::validated_pe_version_for_backup_restore(
1313
default: {
1414
$msg = @("WARN")
1515
WARNING: Retrieved a missing or unparseable PE version of '${pe_version}'.
16-
The host_action_collector database will be skipped from defaults.
16+
Newer service databases released in 2023.7+ will be skipped from defaults.
17+
(host-action-collector, patching)
1718
|-WARN
1819
out::message($msg)
1920
'0.0.0'

plans/backup.pp

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
'puppetdb' => $puppetdb_postgresql_target,
6060
# (host-action-collector db will be filtered for pe version by recovery_opts)
6161
'hac' => $primary_target,
62+
# (patching db will be filtered for pe version by recovery_opts)
63+
'patching' => $primary_target,
6264
}.filter |$key,$_| {
6365
$recovery_opts[$key] == true
6466
}

plans/restore.pp

+2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@
101101
'puppetdb' => $puppetdb_postgresql_targets,
102102
# (host-action-collector db will be filtered for pe version by recovery_opts)
103103
'hac' => $primary_target,
104+
# (patching db will be filtered for pe version by recovery_opts)
105+
'patching' => $primary_target,
104106
}.filter |$key,$_| {
105107
$recovery_opts[$key] == true
106108
}

spec/functions/migration_opts_default_spec.rb

+17
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,21 @@
3131
},
3232
)
3333
end
34+
35+
it 'returns 2025.0+ defaults with hac and patching' do
36+
is_expected.to run.with_params('2025.0.0').and_return(
37+
{
38+
'activity' => true,
39+
'ca' => true,
40+
'classifier' => true,
41+
'code' => false,
42+
'config' => false,
43+
'orchestrator' => true,
44+
'puppetdb' => true,
45+
'rbac' => true,
46+
'hac' => true,
47+
'patching' => true,
48+
},
49+
)
50+
end
3451
end

spec/functions/recovery_opts_all_spec.rb

+33
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,37 @@
3131
},
3232
)
3333
end
34+
35+
it 'returns 2023.7+ defaults with hac if >2023.7 <2025.0' do
36+
is_expected.to run.with_params('2024.9999.0').and_return(
37+
{
38+
'activity' => true,
39+
'ca' => true,
40+
'classifier' => true,
41+
'code' => true,
42+
'config' => true,
43+
'orchestrator' => true,
44+
'puppetdb' => true,
45+
'rbac' => true,
46+
'hac' => true,
47+
},
48+
)
49+
end
50+
51+
it 'returns 2025.0+ defaults with hac and patching' do
52+
is_expected.to run.with_params('2025.0.0').and_return(
53+
{
54+
'activity' => true,
55+
'ca' => true,
56+
'classifier' => true,
57+
'code' => true,
58+
'config' => true,
59+
'orchestrator' => true,
60+
'puppetdb' => true,
61+
'rbac' => true,
62+
'hac' => true,
63+
'patching' => true,
64+
},
65+
)
66+
end
3467
end

spec/functions/recovery_opts_default_spec.rb

+17
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,21 @@
3131
},
3232
)
3333
end
34+
35+
it 'returns 2025.0+ defaults with hac and patching' do
36+
is_expected.to run.with_params('2025.0.0').and_return(
37+
{
38+
'activity' => false,
39+
'ca' => true,
40+
'classifier' => false,
41+
'code' => true,
42+
'config' => true,
43+
'orchestrator' => false,
44+
'puppetdb' => true,
45+
'rbac' => false,
46+
'hac' => false,
47+
'patching' => false,
48+
},
49+
)
50+
end
3451
end

spec/plans/backup_spec.rb

+22-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
'puppetdb' => false,
2222
'rbac' => false,
2323
'hac' => false,
24+
'patching' => false,
2425
}
2526
}
2627
end
@@ -119,7 +120,25 @@
119120
end
120121
end
121122

122-
context '>= 2023.7.0' do
123+
context '>= 2025.0.0' do
124+
let(:pe_version) { '2025.0.0' }
125+
126+
include_context('all 2023.6.0 backups')
127+
128+
it 'runs with backup type custom, all backup params set to true' do
129+
expect_out_message.with_params('# Backing up database pe-hac')
130+
expect_out_message.with_params('# Backing up database pe-patching')
131+
132+
expect_command('/opt/puppetlabs/server/bin/pg_dump -Fd -Z3 -j4 -f /tmp/pe-backup-1970-01-01T000000Z/hac/pe-hac.dump.d "sslmode=verify-ca host=primary user=pe-hac sslcert=/etc/puppetlabs/puppetdb/ssl/primary.cert.pem sslkey=/etc/puppetlabs/puppetdb/ssl/primary.private_key.pem sslrootcert=/etc/puppetlabs/puppet/ssl/certs/ca.pem dbname=pe-hac"' + "\n")
133+
expect_command('/opt/puppetlabs/server/bin/pg_dump -Fd -Z3 -j4 -f /tmp/pe-backup-1970-01-01T000000Z/patching/pe-patching.dump.d "sslmode=verify-ca host=primary user=pe-patching sslcert=/etc/puppetlabs/puppetdb/ssl/primary.cert.pem sslkey=/etc/puppetlabs/puppetdb/ssl/primary.private_key.pem sslrootcert=/etc/puppetlabs/puppet/ssl/certs/ca.pem dbname=pe-patching"' + "\n")
134+
135+
expect(run_plan('peadm::backup', all_backup_options)).to be_ok
136+
end
137+
end
138+
139+
context '>= 2023.7.0 < 2025.0' do
140+
let(:pe_version) { '2023.7.0' }
141+
123142
include_context('all 2023.6.0 backups')
124143

125144
it 'runs with backup type custom, all backup params set to true' do
@@ -149,7 +168,8 @@
149168
it 'warns that hac is ignored' do
150169
expect_out_message.with_params(<<~MSG.strip)
151170
WARNING: Retrieved a missing or unparseable PE version of ''.
152-
The host_action_collector database will be skipped from defaults.
171+
Newer service databases released in 2023.7+ will be skipped from defaults.
172+
(host-action-collector, patching)
153173
MSG
154174

155175
expect(run_plan('peadm::backup', all_backup_options)).to be_ok

spec/plans/restore_spec.rb

+20-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
'orchestrator' => false,
4646
'puppetdb' => false,
4747
'rbac' => false,
48+
'hac' => false,
49+
'patching' => false,
4850
}
4951
}
5052
end
@@ -175,7 +177,22 @@ def expect_peadm_config_fallback(backup_dir, file)
175177
end
176178
end
177179

178-
context '>= 2023.7.0' do
180+
context '>= 2025.0.0' do
181+
let(:pe_version) { '2025.0.0' }
182+
183+
include_context('all 2023.6.0 backups')
184+
185+
it 'runs with backup type custom, all params set to true', valid_cluster: true do
186+
expect_restore_for_db('hac', 'primary')
187+
expect_restore_for_db('patching', 'primary')
188+
189+
expect(run_plan('peadm::restore', all_recovery_options)).to be_ok
190+
end
191+
end
192+
193+
context '>= 2023.7.0 < 2025.0' do
194+
let(:pe_version) { '2023.7.0' }
195+
179196
include_context('all 2023.6.0 backups')
180197

181198
it 'runs with backup type custom, all params set to true', valid_cluster: true do
@@ -211,7 +228,8 @@ def expect_peadm_config_fallback(backup_dir, file)
211228
it 'warns that hac is ignored', valid_cluster: false do
212229
expect_out_message.with_params(<<~MSG.strip)
213230
WARNING: Retrieved a missing or unparseable PE version of ''.
214-
The host_action_collector database will be skipped from defaults.
231+
Newer service databases released in 2023.7+ will be skipped from defaults.
232+
(host-action-collector, patching)
215233
MSG
216234

217235
expect_peadm_config_fallback(backup_dir, 'peadm_config.no_pe_version.json')

types/recovery_opts.pp

+1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
'puppetdb' => Optional[Boolean],
99
'rbac' => Optional[Boolean],
1010
'hac' => Optional[Boolean],
11+
'patching' => Optional[Boolean],
1112
}]

0 commit comments

Comments
 (0)