Skip to content
23 changes: 23 additions & 0 deletions plans/migrate.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,37 @@
# @param upgrade_version
# Optional version to upgrade to after migration is complete
#
#
plan peadm::migrate (
Peadm::SingleTargetSpec $old_primary_host,
Peadm::SingleTargetSpec $new_primary_host,
Optional[String] $upgrade_version = undef,
Optional[Peadm::SingleTargetSpec] $replica_host = undef,
) {
# 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()
peadm::assert_supported_pe_version($pe_version, $permit_unsafe_versions)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line will fail as the params $pe_version and $permit_unsafe_versions are not defined. For $pe_version we can use $upgrade_version but we need to define $permit_unsafe_versions and set it to either true or false (search through the codebase for other instances of 'peadm::assert_supported_pe_version' to see what is generally passed in for $permit_unsafe_versions). We should also wrap that line in an 'if' statement like we do near the bottom of this file:

if $upgrade_version and $upgrade_version != '' and !empty($upgrade_version) {
    peadm::assert_supported_pe_version($pe_version, $permit_unsafe_versions)
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still failing with: Evaluation Error: Unknown variable: 'pe_version'. (file: /home/runner/work/puppetlabs-peadm/puppetlabs-peadm/spec/fixtures/modules/peadm/plans/migrate.pp, line: 22, column: 38)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

found the problem: in assert_supported_pe_version being called the variable is just called $version not $pe_version


$all_hosts = peadm::flatten_compact([
$old_primary_host,
$new_primary_host,
])
run_command('hostname', $all_hosts) # verify can connect to targets

# verify the cluster we are migrating from is operational and is a supported architecture
$cluster = run_task('peadm::get_peadm_config', $old_primary_host).first.value
$error = getvar('cluster.error')
if $error {
fail_plan($error)
}
$arch = peadm::assert_supported_architecture(
getvar('cluster.params.primary_host'),
getvar('cluster.params.replica_host'),
getvar('cluster.params.primary_postgresql_host'),
getvar('cluster.params.replica_postgresql_host'),
getvar('cluster.params.compiler_hosts'),
)

$backup_file = run_plan('peadm::backup', $old_primary_host, {
backup_type => 'migration',
Expand Down
Loading