Skip to content

Commit 34a72b7

Browse files
committed
output parameters used in plans upgrade, install and migrate to aid in debugging. hosts, pe version,
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 ef6f1f1 commit 34a72b7

File tree

9 files changed

+110
-2
lines changed

9 files changed

+110
-2
lines changed

REFERENCE.md

+32
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

functions/log_plan_parameters.pp

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function peadm::log_plan_parameters(Hash $params) {
2+
out::message("PEADM Module version: ${peadm::module_version()}")
3+
$params.each |$key, $value| {
4+
out::message("Parameter '${key}': [${value}]")
5+
}
6+
}
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

+26
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,32 @@
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+
89+
peadm::assert_supported_bolt_version()
90+
91+
peadm::assert_supported_pe_version($version, $permit_unsafe_versions)
92+
93+
# Log parameters for debugging
94+
peadm::log_plan_params({
95+
'primary_host' => $primary_host,
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,
102+
})
103+
78104
peadm::assert_supported_bolt_version()
79105

80106
peadm::assert_supported_pe_version($version, $permit_unsafe_versions)

plans/migrate.pp

+11
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

+13
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

+10
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

spec/plans/install_spec.rb

+1
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

+2-2
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)