Skip to content

Commit 6d3fcd1

Browse files
committed
output parameters used in plans upgrade, install and migrate to aid in debugging. hosts, pe version,
include logs as allowed in 'basic functionality' expect the out message PE-40508) Add infra-assistant to add_database plan (#580) Co-authored-by: Neil Anderson <[email protected]> Co-authored-by: ragingra <[email protected]> add XL with and without DR to test migration and migrate plans (#581)
1 parent ebf3164 commit 6d3fcd1

File tree

16 files changed

+212
-38
lines changed

16 files changed

+212
-38
lines changed

.fixtures.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
---
22
fixtures:
33
forge_modules:
4-
ruby_task_helper: "puppetlabs/ruby_task_helper"
5-
service: "puppetlabs/service"
6-
package: "puppetlabs/package"
7-
reboot: "puppetlabs/reboot"
8-
inifile: "puppetlabs/inifile"
4+
ruby_task_helper: puppetlabs/ruby_task_helper
5+
service: puppetlabs/service
6+
package: puppetlabs/package
7+
reboot: puppetlabs/reboot
8+
inifile: puppetlabs/inifile
99
repositories:
10-
facts: "https://github.com/puppetlabs/puppetlabs-facts.git"
11-
puppet_agent: "https://github.com/puppetlabs/puppetlabs-puppet_agent.git"
12-
provision: "https://github.com/puppetlabs/provision.git"
13-
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
14-
apply_helpers: "https://github.com/puppetlabs/puppetlabs-apply_helpers"
15-
bolt_shim: "https://github.com/puppetlabs/puppetlabs-bolt_shim"
16-
format: "https://github.com/voxpupuli/puppet-format"
17-
container_inventory: "https://gitlab.com/nwops/bolt-container_inventory.git"
18-
node_manager: "https://github.com/puppetlabs/puppetlabs-node_manager.git"
10+
facts: https://github.com/puppetlabs/puppetlabs-facts.git
11+
puppet_agent: https://github.com/puppetlabs/puppetlabs-puppet_agent.git
12+
provision:
13+
repo: https://github.com/puppetlabs/provision.git
14+
ref: v3.0.1
15+
stdlib: https://github.com/puppetlabs/puppetlabs-stdlib.git
16+
apply_helpers: https://github.com/puppetlabs/puppetlabs-apply_helpers
17+
bolt_shim: https://github.com/puppetlabs/puppetlabs-bolt_shim
18+
format: https://github.com/voxpupuli/puppet-format
19+
container_inventory: https://gitlab.com/nwops/bolt-container_inventory.git
20+
node_manager: https://github.com/puppetlabs/puppetlabs-node_manager.git
1921
symlinks:
20-
"peadm": "#{source_dir}"
21-
"peadm_spec": "#{source_dir}/spec/acceptance/peadm_spec"
22+
peadm: '#{source_dir}'
23+
peadm_spec: '#{source_dir}/spec/acceptance/peadm_spec'

.github/workflows/test-migration.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ jobs:
4040
- standard
4141
- standard-with-dr
4242
- large
43-
# - extra-large
43+
- extra-large
4444
- large-with-dr
45-
# - extra-large-with-dr
45+
- extra-large-with-dr
4646
version: [2021.7.9, 2023.8.2, 2025.2.0]
4747
image: [almalinux-cloud/almalinux-8]
4848
include:
@@ -54,6 +54,20 @@ jobs:
5454
version: 2023.8.0
5555
image: almalinux-cloud/almalinux-8
5656
new_pe_version: 2025.2.0
57+
- architecture: extra-large
58+
version: 2023.8.0
59+
image: almalinux-cloud/almalinux-8
60+
new_pe_version: 2025.2.0
61+
# excluding the following combinations as due to their long running nature they always fail due to
62+
# the test nodes in GCP that litmus provisions becoming unreachable after a time. If we address PE-40902
63+
# to change how we provision test nodes in CI then we will hopefully be able to include these
64+
exclude:
65+
- architecture: extra-large-with-dr
66+
version: 2023.8.2
67+
image: almalinux-cloud/almalinux-8
68+
- architecture: extra-large-with-dr
69+
version: 2025.2.0
70+
image: almalinux-cloud/almalinux-8
5771
steps:
5872
- name: Checkout Source
5973
uses: actions/checkout@v4

.github/workflows/test-upgrade-matrix.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
strategy:
3737
fail-fast: false
3838
matrix:
39-
architecture: [standard, extra-large-with-dr]
39+
architecture: [standard, extra-large] # removing xl-with dr until PE-40902 is addressed
4040
version: [2019.8.12, 2021.7.9, 2023.8.2]
4141
version_to_upgrade: [2021.7.9, 2023.8.2, 2025.2.0]
4242
image: [almalinux-cloud/almalinux-8]

REFERENCE.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
* [`peadm::generate_pe_conf`](#peadm--generate_pe_conf): Generate a pe.conf file in JSON format
3333
* [`peadm::get_pe_conf`](#peadm--get_pe_conf)
3434
* [`peadm::get_targets`](#peadm--get_targets): Accept undef or a SingleTargetSpec, and return an Array[Target, 1, 0]. This differs from get_target() in that: - It returns an Array[Target
35+
* [`peadm::log_plan_parameters`](#peadm--log_plan_parameters)
3536
* [`peadm::migration_opts_default`](#peadm--migration_opts_default)
37+
* [`peadm::module_version`](#peadm--module_version)
3638
* [`peadm::node_manager_yaml_location`](#peadm--node_manager_yaml_location)
3739
* [`peadm::oid`](#peadm--oid)
3840
* [`peadm::pe_db_names`](#peadm--pe_db_names)
@@ -786,6 +788,24 @@ Data type: `Optional[Integer[1,1]]`
786788

787789

788790

791+
### <a name="peadm--log_plan_parameters"></a>`peadm::log_plan_parameters`
792+
793+
Type: Puppet Language
794+
795+
The peadm::log_plan_parameters function.
796+
797+
#### `peadm::log_plan_parameters(Hash $params)`
798+
799+
The peadm::log_plan_parameters function.
800+
801+
Returns: `Any`
802+
803+
##### `params`
804+
805+
Data type: `Hash`
806+
807+
808+
789809
### <a name="peadm--migration_opts_default"></a>`peadm::migration_opts_default`
790810

791811
Type: Puppet Language
@@ -798,6 +818,18 @@ The peadm::migration_opts_default function.
798818

799819
Returns: `Any`
800820

821+
### <a name="peadm--module_version"></a>`peadm::module_version`
822+
823+
Type: Ruby 4.x API
824+
825+
The peadm::module_version function.
826+
827+
#### `peadm::module_version()`
828+
829+
The peadm::module_version function.
830+
831+
Returns: `Any`
832+
801833
### <a name="peadm--node_manager_yaml_location"></a>`peadm::node_manager_yaml_location`
802834

803835
Type: Ruby 4.x API
@@ -1804,6 +1836,7 @@ The following parameters are available in the `peadm::add_database` plan:
18041836
* [`primary_host`](#-peadm--add_database--primary_host)
18051837
* [`mode`](#-peadm--add_database--mode)
18061838
* [`begin_at_step`](#-peadm--add_database--begin_at_step)
1839+
* [`is_migration`](#-peadm--add_database--is_migration)
18071840

18081841
##### <a name="-peadm--add_database--targets"></a>`targets`
18091842

@@ -1843,6 +1876,14 @@ Optional[Enum[
18431876

18441877
Default value: `undef`
18451878

1879+
##### <a name="-peadm--add_database--is_migration"></a>`is_migration`
1880+
1881+
Data type: `Optional[Boolean]`
1882+
1883+
1884+
1885+
Default value: `false`
1886+
18461887
### <a name="peadm--add_replica"></a>`peadm::add_replica`
18471888

18481889
Add or replace a replica host.

plans/util/log_plans_params.pp renamed to functions/log_plan_parameters.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
function peadm::log_plan_parameters(Hash $params) {
2+
out::message("PEADM Module version: ${peadm::module_version()}")
23
$params.each |$key, $value| {
34
out::message("Parameter '${key}': [${value}]")
45
}

functions/pe_db_names.pp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,20 @@ function peadm::pe_db_names (
99
'pe-rbac',
1010
]
1111

12+
$pe_2025_3_or_later = SemVerRange('>= 2025.3.0')
1213
$pe_2025_or_later = SemVerRange('>= 2025.0.0')
1314
$pe_2023_8_or_later = SemVerRange('>= 2023.8.0')
1415

1516
case $pe_ver {
17+
# The infra-assistant was added in 2025.3.0
18+
$pe_2025_3_or_later: {
19+
$original_db_names + [
20+
'pe-hac',
21+
'pe-patching',
22+
'pe-infra-assistant',
23+
]
24+
}
25+
1626
# The patching service was added in 2025.0.0
1727
$pe_2025_or_later: {
1828
$original_db_names + [
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Puppet::Functions.create_function(:'peadm::module_version', Puppet::Functions::InternalFunction) do
2+
dispatch :module_version do
3+
scope_param
4+
end
5+
6+
def module_version(scope)
7+
scope.compiler.environment.module('peadm').version
8+
end
9+
end

plans/add_database.pp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
'update-db-settings',
1010
'cleanup-db',
1111
'finalize']] $begin_at_step = undef,
12+
Optional[Boolean] $is_migration = false,
1213
) {
1314
$primary_target = peadm::get_targets($primary_host, 1)
1415
$postgresql_target = peadm::get_targets($targets, 1)
@@ -22,8 +23,9 @@
2223

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

25-
# Bail if this is trying to be ran against Standard
26-
if $compilers.empty {
26+
# Bail if this is trying to be ran against Standard. We need to allow this plan to progress for a migration
27+
# though as initially the installation will not have compilers added
28+
if $compilers.empty and !$is_migration {
2729
fail_plan('Plan peadm::add_database is only applicable for L and XL deployments')
2830
}
2931

@@ -59,11 +61,15 @@
5961

6062
if $operating_mode == 'init' {
6163
# If no other PSQL node then match primary group letter
62-
$avail_group_letter = peadm::flatten_compact($roles['server'].map |$k,$v| {
64+
$calculated_group_letter = peadm::flatten_compact($roles['server'].map |$k,$v| {
6365
if $v == $primary_host {
6466
$k
6567
}
6668
})[0]
69+
$avail_group_letter = $calculated_group_letter ? {
70+
undef => $is_migration ? { true => 'A', default => undef },
71+
default => $calculated_group_letter,
72+
}
6773
# Assume PuppetDB backend hosted on Primary if in init mode
6874
$source_db_host = $primary_host
6975
} else {

plans/install.pp

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,39 @@
7575
Boolean $permit_unsafe_versions = false,
7676
String $token_lifetime = '1y',
7777
) {
78+
# Log parameters for debugging
79+
peadm::log_plan_params({
80+
'primary_host' => $primary_host,
81+
'replica_host' => $replica_host,
82+
'compiler_hosts' => $compiler_hosts,
83+
'legacy_compilers' => $legacy_compilers,
84+
'primary_postgresql_host' => $primary_postgresql_host,
85+
'replica_postgresql_host' => $replica_postgresql_host,
86+
'version' => $version,
87+
})
88+
7889
peadm::assert_supported_bolt_version()
7990

8091
peadm::assert_supported_pe_version($version, $permit_unsafe_versions)
8192

82-
# Log parameters for debugging
83-
peadm::log_plan_parameters({
84-
'targets' => $targets,
93+
<<<<<<< HEAD
94+
# Log parameters for debugging
95+
peadm::log_plan_params({
8596
'primary_host' => $primary_host,
86-
'mode' => $mode,
87-
'begin_at_step' => $begin_at_step,
97+
'replica_host' => $replica_host,
98+
'compiler_hosts' => $compiler_hosts,
99+
'legacy_compilers' => $legacy_compilers,
100+
'primary_postgresql_host' => $primary_postgresql_host,
101+
'replica_postgresql_host' => $replica_postgresql_host,
102+
'version' => $version,
88103
})
89104

105+
peadm::assert_supported_bolt_version()
106+
107+
peadm::assert_supported_pe_version($version, $permit_unsafe_versions)
108+
109+
=======
110+
>>>>>>> 431141a (move declaration)
90111
$install_result = run_plan('peadm::subplans::install',
91112
# Standard
92113
primary_host => $primary_host,

plans/migrate.pp

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,31 @@
88
# The new server that will become the PE primary server
99
# @param upgrade_version
1010
# Optional version to upgrade to after migration is complete
11-
#
11+
# @param replica_host
12+
# Optional new replica server to be added to the cluster
13+
# @param primary_postgresql_host
14+
# Optional new primary PostgreSQL server to be added to the cluster
15+
# @param replica_postgresql_host
16+
# Optional new replica PostgreSQL server to be added to the cluster
1217
plan peadm::migrate (
1318
Peadm::SingleTargetSpec $old_primary_host,
1419
Peadm::SingleTargetSpec $new_primary_host,
1520
Optional[String] $upgrade_version = undef,
1621
Optional[Peadm::SingleTargetSpec] $replica_host = undef,
22+
Optional[Peadm::SingleTargetSpec] $primary_postgresql_host = undef,
23+
Optional[Peadm::SingleTargetSpec] $replica_postgresql_host = undef,
1724
) {
25+
# Log parameters for debugging
26+
peadm::log_plan_parameters({
27+
'new_primary_host' => $new_primary_host,
28+
'replica_host' => $replica_host,
29+
'compiler_hosts' => $compiler_hosts,
30+
'legacy_compilers' => $legacy_compilers,
31+
'primary_postgresql_host' => $primary_postgresql_host,
32+
'replica_postgresql_host' => $replica_postgresql_host,
33+
'upgrade_version' => $upgrade_version,
34+
})
35+
1836
# pre-migration checks
1937
out::message('This plan is a work in progress and it is not recommended to be used until it is fully implemented and supported')
2038
peadm::assert_supported_bolt_version()
@@ -25,7 +43,9 @@
2543

2644
$new_hosts = peadm::flatten_compact([
2745
$new_primary_host,
28-
$replica_host ? { undef => [], default => [$replica_host] }
46+
$replica_host ? { undef => [], default => [$replica_host] },
47+
$primary_postgresql_host ? { undef => [], default => [$primary_postgresql_host] },
48+
$replica_postgresql_host ? { undef => [], default => [$replica_postgresql_host] },
2949
].flatten)
3050
$all_hosts = peadm::flatten_compact([
3151
$old_primary_host,
@@ -118,10 +138,27 @@
118138
out::message('No nodes to purge from old configuration')
119139
}
120140

141+
# provision a postgresql host if one is provided
142+
if $primary_postgresql_host {
143+
run_plan('peadm::add_database', targets => $primary_postgresql_host,
144+
primary_host => $new_primary_host,
145+
is_migration => true,
146+
)
147+
# provision a replica postgresql host if one is provided
148+
if $replica_postgresql_host {
149+
run_plan('peadm::add_database', targets => $replica_postgresql_host,
150+
primary_host => $new_primary_host,
151+
is_migration => true,
152+
)
153+
}
154+
}
155+
156+
# provision a replica if one is provided
121157
if $replica_host {
122158
run_plan('peadm::add_replica', {
123159
primary_host => $new_primary_host,
124160
replica_host => $replica_host,
161+
replica_postgresql_host => $replica_postgresql_host,
125162
})
126163
}
127164

@@ -134,6 +171,8 @@
134171
version => $upgrade_version,
135172
download_mode => 'direct',
136173
replica_host => $replica_host,
174+
primary_postgresql_host => $primary_postgresql_host,
175+
replica_postgresql_host => $replica_postgresql_host,
137176
})
138177
}
139178
}

0 commit comments

Comments
 (0)