Skip to content

Commit d5ab3a4

Browse files
committed
(PE-39351) Update add_database plan to work with patching/HAC
This commit updates the add_database plan to include the pe-patching and pe-hac databases when it cleans up the original postgres on the primary. The add_database plan uses pg_basebackup to copy the entire contents of the postgres DB from the original primary DB to the new DB node's postgres. That process doesn't individually update a list of databases, so there's no context of "which DBs to move", because it just moves everything. However, during the cleanup process on the original DB That exists on the primary, the plan _does_ need to list the individual internal postgres dbs that need to be deleted.
1 parent 66567dc commit d5ab3a4

File tree

2 files changed

+45
-10
lines changed

2 files changed

+45
-10
lines changed

functions/pe_db_names.pp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
function peadm::pe_db_names (
2+
String $pe_ver,
3+
) >> Array {
4+
case $pe_ver {
5+
# The patching service was added in 2025.0.0
6+
SemVerRange('>= 2025.0.0'): {
7+
[
8+
'pe-activity',
9+
'pe-classifier',
10+
'pe-inventory',
11+
'pe-orchestrator',
12+
'pe-rbac',
13+
'pe-hac',
14+
'pe-patching',
15+
]
16+
}
17+
18+
# The host-action-collector (hac) was added in 2023.8
19+
SemVerRange('>= 2023.8.0'): {
20+
[
21+
'pe-activity',
22+
'pe-classifier',
23+
'pe-inventory',
24+
'pe-orchestrator',
25+
'pe-rbac',
26+
'pe-hac',
27+
]
28+
}
29+
30+
default: {
31+
[
32+
'pe-activity',
33+
'pe-classifier',
34+
'pe-inventory',
35+
'pe-orchestrator',
36+
'pe-rbac',
37+
]
38+
}
39+
}
40+
}

plans/add_database.pp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# Get current peadm config before making modifications and shutting down
1919
# PuppetDB
2020
$peadm_config = run_task('peadm::get_peadm_config', $primary_target).first.value
21+
$pe_ver = $peadm_config['pe_version']
2122

2223
$compilers = $peadm_config['params']['compilers']
2324

@@ -41,7 +42,7 @@
4142
$operating_mode = $mode
4243
out::message("Operating mode overridden by parameter mode set to ${mode}")
4344
} else {
44-
# If array is empty then no external databases were previously configured
45+
# If array is empty then no external databases were previously configured
4546
$no_external_db = peadm::flatten_compact([
4647
$postgresql_a_host,
4748
$postgresql_b_host,
@@ -87,7 +88,7 @@
8788

8889
peadm::plan_step('init-db-node') || {
8990
# Install PSQL on new node to be used as external PuppetDB backend by using
90-
# puppet in lieu of installer
91+
# puppet in lieu of installer
9192
run_plan('peadm::subplans::component_install', $postgresql_target,
9293
primary_host => $primary_target,
9394
avail_group_letter => $avail_group_letter,
@@ -162,16 +163,10 @@
162163
if $operating_mode == 'init' {
163164
# Clean up old puppetdb database on primary and those which were copied to
164165
# new host.
165-
$target_db_purge = [
166-
'pe-activity',
167-
'pe-classifier',
168-
'pe-inventory',
169-
'pe-orchestrator',
170-
'pe-rbac',
171-
]
166+
$target_db_purge = peadm::pe_db_names($pe_ver)
172167

173168
# If a primary replica exists then pglogical is enabled and will prevent
174-
# the clean up of databases on our target because it opens a connection.
169+
# the clean up of databases on our target because it opens a connection.
175170
if $replica_host {
176171
run_plan('peadm::util::db_disable_pglogical', $postgresql_target, databases => $target_db_purge)
177172
}

0 commit comments

Comments
 (0)