Skip to content

Commit bbda40d

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 adab0ff commit bbda40d

File tree

9 files changed

+102
-15
lines changed

9 files changed

+102
-15
lines changed

REFERENCE.md

Lines changed: 32 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

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
}
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/install.pp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,36 @@
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+
# Log parameters for debugging
94+
peadm::log_plan_params({
8595
'primary_host' => $primary_host,
86-
'mode' => $mode,
87-
'begin_at_step' => $begin_at_step,
96+
'replica_host' => $replica_host,
97+
'compiler_hosts' => $compiler_hosts,
98+
'legacy_compilers' => $legacy_compilers,
99+
'primary_postgresql_host' => $primary_postgresql_host,
100+
'replica_postgresql_host' => $replica_postgresql_host,
101+
'version' => $version,
88102
})
89103

104+
peadm::assert_supported_bolt_version()
105+
106+
peadm::assert_supported_pe_version($version, $permit_unsafe_versions)
107+
90108
$install_result = run_plan('peadm::subplans::install',
91109
# Standard
92110
primary_host => $primary_host,

plans/migrate.pp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@
2222
Optional[Peadm::SingleTargetSpec] $primary_postgresql_host = undef,
2323
Optional[Peadm::SingleTargetSpec] $replica_postgresql_host = undef,
2424
) {
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+
2536
# pre-migration checks
2637
out::message('This plan is a work in progress and it is not recommended to be used until it is fully implemented and supported')
2738
peadm::assert_supported_bolt_version()

plans/replace_failed_postgresql.pp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@
1212
Peadm::SingleTargetSpec $failed_postgresql_host,
1313
Peadm::SingleTargetSpec $replacement_postgresql_host,
1414
) {
15+
# Log parameters for debugging
16+
peadm::log_plan_parameters({
17+
'primary_host' => $primary_host,
18+
'replica_host' => $replica_host,
19+
'compiler_hosts' => $compiler_hosts,
20+
'legacy_compilers' => $legacy_compilers,
21+
'working_postgresql_host' => $working_postgresql_host,
22+
'failed_postgresql_host' => $failed_postgresql_host,
23+
'replacement_postgresql_host' => $replacement_postgresql_host,
24+
'replica_postgresql_host' => $replica_postgresql_host,
25+
'version' => $version,
26+
})
27+
1528
$all_hosts = peadm::flatten_compact([
1629
$primary_host,
1730
$replica_host,

plans/upgrade.pp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@
6262

6363
Optional[Peadm::UpgradeSteps] $begin_at_step = undef,
6464
) {
65+
# Log parameters for debugging
66+
peadm::log_plan_parameters({
67+
'primary_host' => $primary_host,
68+
'replica_host' => $replica_host,
69+
'compiler_hosts' => $compiler_hosts,
70+
'primary_postgresql_host' => $primary_postgresql_host,
71+
'replica_postgresql_host' => $replica_postgresql_host,
72+
'version' => $version,
73+
})
74+
6575
out::message('# Validating inputs')
6676

6777
# Ensure input valid for a supported architecture
@@ -73,14 +83,6 @@
7383
$compiler_hosts,
7484
)
7585

76-
# Log parameters for debugging
77-
peadm::log_plan_parameters({
78-
'targets' => $targets,
79-
'primary_host' => $primary_host,
80-
'mode' => $mode,
81-
'begin_at_step' => $begin_at_step,
82-
})
83-
8486
# Convert inputs into targets.
8587
$primary_target = peadm::get_targets($primary_host, 1)
8688
$replica_target = peadm::get_targets($replica_host, 1)

spec/plans/install_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
describe 'basic functionality' do
77
it 'runs successfully with the minimum required parameters' do
8+
allow_out_message
89
expect_plan('peadm::subplans::install')
910
expect_plan('peadm::subplans::configure')
1011
expect(run_plan('peadm::install', 'primary_host' => 'primary', 'console_password' => 'puppetLabs123!', 'version' => '2021.7.9')).to be_ok

spec/plans/subplans/install_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
},
2525
)
2626

27-
#########
27+
##########
2828
## <🤮>
29-
# rubocop:disable AnyInstance
29+
rubocop:disable AnyInstance
3030
allow(Tempfile).to receive(:new).and_call_original
3131
allow(Pathname).to receive(:new).and_call_original
3232
allow(Puppet::FileSystem).to receive(:exist?).and_call_original

0 commit comments

Comments
 (0)