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

(PE-39351) Update add_database plan to work with patching/HAC #531

Merged
merged 3 commits into from
Dec 16, 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
19 changes: 19 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* [`peadm::migration_opts_default`](#peadm--migration_opts_default)
* [`peadm::node_manager_yaml_location`](#peadm--node_manager_yaml_location)
* [`peadm::oid`](#peadm--oid)
* [`peadm::pe_db_names`](#peadm--pe_db_names)
* [`peadm::plan_step`](#peadm--plan_step)
* [`peadm::recovery_opts_all`](#peadm--recovery_opts_all)
* [`peadm::recovery_opts_default`](#peadm--recovery_opts_default)
Expand Down Expand Up @@ -823,6 +824,24 @@ Data type: `String`



### <a name="peadm--pe_db_names"></a>`peadm::pe_db_names`

Type: Puppet Language

The peadm::pe_db_names function.

#### `peadm::pe_db_names(String $pe_ver)`

The peadm::pe_db_names function.

Returns: `Array`

##### `pe_ver`

Data type: `String`



### <a name="peadm--plan_step"></a>`peadm::plan_step`

Type: Ruby 4.x API
Expand Down
33 changes: 33 additions & 0 deletions functions/pe_db_names.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function peadm::pe_db_names (
String $pe_ver,
) >> Array {
$original_db_names = [
'pe-activity',
'pe-classifier',
'pe-inventory',
'pe-orchestrator',
'pe-rbac',
]

$pe_2025_or_later = SemVerRange('>= 2025.0.0')
$pe_2023_8_or_later = SemVerRange('>= 2023.8.0')

case $pe_ver {
# The patching service was added in 2025.0.0
$pe_2025_or_later: {
$original_db_names + [
'pe-hac',
'pe-patching',
]
}

# The host-action-collector (hac) was added in 2023.8
$pe_2023_8_or_later: {
$original_db_names + ['pe-hac']
}

default: {
$original_db_names
}
}
}
15 changes: 5 additions & 10 deletions plans/add_database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# Get current peadm config before making modifications and shutting down
# PuppetDB
$peadm_config = run_task('peadm::get_peadm_config', $primary_target).first.value
$pe_ver = $peadm_config['pe_version']

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

Expand All @@ -41,7 +42,7 @@
$operating_mode = $mode
out::message("Operating mode overridden by parameter mode set to ${mode}")
} else {
# If array is empty then no external databases were previously configured
# If array is empty then no external databases were previously configured
$no_external_db = peadm::flatten_compact([
$postgresql_a_host,
$postgresql_b_host,
Expand Down Expand Up @@ -87,7 +88,7 @@

peadm::plan_step('init-db-node') || {
# Install PSQL on new node to be used as external PuppetDB backend by using
# puppet in lieu of installer
# puppet in lieu of installer
run_plan('peadm::subplans::component_install', $postgresql_target,
primary_host => $primary_target,
avail_group_letter => $avail_group_letter,
Expand Down Expand Up @@ -162,16 +163,10 @@
if $operating_mode == 'init' {
# Clean up old puppetdb database on primary and those which were copied to
# new host.
$target_db_purge = [
'pe-activity',
'pe-classifier',
'pe-inventory',
'pe-orchestrator',
'pe-rbac',
]
$target_db_purge = peadm::pe_db_names($pe_ver)

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