Skip to content

(PE-40350) add plan parameters to log stream #587

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

Merged
merged 1 commit into from
May 8, 2025
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
32 changes: 32 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
* [`peadm::generate_pe_conf`](#peadm--generate_pe_conf): Generate a pe.conf file in JSON format
* [`peadm::get_pe_conf`](#peadm--get_pe_conf)
* [`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
* [`peadm::log_plan_parameters`](#peadm--log_plan_parameters)
* [`peadm::migration_opts_default`](#peadm--migration_opts_default)
* [`peadm::module_version`](#peadm--module_version)
* [`peadm::node_manager_yaml_location`](#peadm--node_manager_yaml_location)
* [`peadm::oid`](#peadm--oid)
* [`peadm::pe_db_names`](#peadm--pe_db_names)
Expand Down Expand Up @@ -786,6 +788,24 @@ Data type: `Optional[Integer[1,1]]`



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

Type: Puppet Language

The peadm::log_plan_parameters function.

#### `peadm::log_plan_parameters(Hash $params)`

The peadm::log_plan_parameters function.

Returns: `Any`

##### `params`

Data type: `Hash`



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

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

Returns: `Any`

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

Type: Ruby 4.x API

The peadm::module_version function.

#### `peadm::module_version()`

The peadm::module_version function.

Returns: `Any`

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

Type: Ruby 4.x API
Expand Down
6 changes: 6 additions & 0 deletions functions/log_plan_parameters.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function peadm::log_plan_parameters(Hash $params) {
out::message("PEADM Module version: ${peadm::module_version()}")
$params.each |$key, $value| {
out::message("Parameter '${key}': [${value}]")
}
}
9 changes: 9 additions & 0 deletions lib/puppet/functions/peadm/module_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Puppet::Functions.create_function(:'peadm::module_version', Puppet::Functions::InternalFunction) do
dispatch :module_version do
scope_param
end

def module_version(scope)
scope.compiler.environment.module('peadm').version
end
end
11 changes: 11 additions & 0 deletions plans/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@
Boolean $permit_unsafe_versions = false,
String $token_lifetime = '1y',
) {
# Log parameters for debugging
peadm::log_plan_parameters({
'primary_host' => $primary_host,
'replica_host' => $replica_host,
'compiler_hosts' => $compiler_hosts,
'legacy_compilers' => $legacy_compilers,
'primary_postgresql_host' => $primary_postgresql_host,
'replica_postgresql_host' => $replica_postgresql_host,
'version' => $version,
})

peadm::assert_supported_bolt_version()

peadm::assert_supported_pe_version($version, $permit_unsafe_versions)
Expand Down
10 changes: 10 additions & 0 deletions plans/migrate.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
Optional[Peadm::SingleTargetSpec] $primary_postgresql_host = undef,
Optional[Peadm::SingleTargetSpec] $replica_postgresql_host = undef,
) {
# Log parameters for debugging
peadm::log_plan_parameters({
'old_primary_host' => $old_primary_host,
'new_primary_host' => $new_primary_host,
'replica_host' => $replica_host,
'primary_postgresql_host' => $primary_postgresql_host,
'replica_postgresql_host' => $replica_postgresql_host,
'upgrade_version' => $upgrade_version,
})

# pre-migration checks
out::message('This plan is a work in progress and it is not recommended to be used until it is fully implemented and supported')
peadm::assert_supported_bolt_version()
Expand Down
9 changes: 9 additions & 0 deletions plans/replace_failed_postgresql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
Peadm::SingleTargetSpec $failed_postgresql_host,
Peadm::SingleTargetSpec $replacement_postgresql_host,
) {
# Log parameters for debugging
peadm::log_plan_parameters({
'primary_host' => $primary_host,
'replica_host' => $replica_host,
'working_postgresql_host' => $working_postgresql_host,
'failed_postgresql_host' => $failed_postgresql_host,
'replacement_postgresql_host' => $replacement_postgresql_host,
})

$all_hosts = peadm::flatten_compact([
$primary_host,
$replica_host,
Expand Down
10 changes: 10 additions & 0 deletions plans/upgrade.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@

Optional[Peadm::UpgradeSteps] $begin_at_step = undef,
) {
# Log parameters for debugging
peadm::log_plan_parameters({
'primary_host' => $primary_host,
'replica_host' => $replica_host,
'compiler_hosts' => $compiler_hosts,
'primary_postgresql_host' => $primary_postgresql_host,
'replica_postgresql_host' => $replica_postgresql_host,
'version' => $version,
})

out::message('# Validating inputs')

# Ensure input valid for a supported architecture
Expand Down
1 change: 1 addition & 0 deletions spec/plans/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

describe 'basic functionality' do
it 'runs successfully with the minimum required parameters' do
allow_out_message
expect_plan('peadm::subplans::install')
expect_plan('peadm::subplans::configure')
expect(run_plan('peadm::install', 'primary_host' => 'primary', 'console_password' => 'puppetLabs123!', 'version' => '2021.7.9')).to be_ok
Expand Down
Loading