Skip to content

(PE-40386) Phase 3 - Migrate to XL #581

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 2, 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
34 changes: 18 additions & 16 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
---
fixtures:
forge_modules:
ruby_task_helper: "puppetlabs/ruby_task_helper"
service: "puppetlabs/service"
package: "puppetlabs/package"
reboot: "puppetlabs/reboot"
inifile: "puppetlabs/inifile"
ruby_task_helper: puppetlabs/ruby_task_helper
service: puppetlabs/service
package: puppetlabs/package
reboot: puppetlabs/reboot
inifile: puppetlabs/inifile
repositories:
facts: "https://github.com/puppetlabs/puppetlabs-facts.git"
puppet_agent: "https://github.com/puppetlabs/puppetlabs-puppet_agent.git"
provision: "https://github.com/puppetlabs/provision.git"
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
apply_helpers: "https://github.com/puppetlabs/puppetlabs-apply_helpers"
bolt_shim: "https://github.com/puppetlabs/puppetlabs-bolt_shim"
format: "https://github.com/voxpupuli/puppet-format"
container_inventory: "https://gitlab.com/nwops/bolt-container_inventory.git"
node_manager: "https://github.com/puppetlabs/puppetlabs-node_manager.git"
facts: https://github.com/puppetlabs/puppetlabs-facts.git
puppet_agent: https://github.com/puppetlabs/puppetlabs-puppet_agent.git
provision:
repo: https://github.com/puppetlabs/provision.git
ref: v3.0.1
stdlib: https://github.com/puppetlabs/puppetlabs-stdlib.git
apply_helpers: https://github.com/puppetlabs/puppetlabs-apply_helpers
bolt_shim: https://github.com/puppetlabs/puppetlabs-bolt_shim
format: https://github.com/voxpupuli/puppet-format
container_inventory: https://gitlab.com/nwops/bolt-container_inventory.git
node_manager: https://github.com/puppetlabs/puppetlabs-node_manager.git
symlinks:
"peadm": "#{source_dir}"
"peadm_spec": "#{source_dir}/spec/acceptance/peadm_spec"
peadm: '#{source_dir}'
peadm_spec: '#{source_dir}/spec/acceptance/peadm_spec'
18 changes: 16 additions & 2 deletions .github/workflows/test-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ jobs:
- standard
- standard-with-dr
- large
# - extra-large
- extra-large
- large-with-dr
# - extra-large-with-dr
- extra-large-with-dr
version: [2021.7.9, 2023.8.2, 2025.2.0]
image: [almalinux-cloud/almalinux-8]
include:
Expand All @@ -54,6 +54,20 @@ jobs:
version: 2023.8.0
image: almalinux-cloud/almalinux-8
new_pe_version: 2025.2.0
- architecture: extra-large
version: 2023.8.0
image: almalinux-cloud/almalinux-8
new_pe_version: 2025.2.0
# excluding the following combinations as due to their long running nature they always fail due to
# the test nodes in GCP that litmus provisions becoming unreachable after a time. If we address PE-40902
# to change how we provision test nodes in CI then we will hopefully be able to include these
exclude:
- architecture: extra-large-with-dr
version: 2023.8.2
image: almalinux-cloud/almalinux-8
- architecture: extra-large-with-dr
version: 2025.2.0
image: almalinux-cloud/almalinux-8
steps:
- name: Checkout Source
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-upgrade-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
strategy:
fail-fast: false
matrix:
architecture: [standard, extra-large-with-dr]
architecture: [standard, extra-large] # removing xl-with dr until PE-40902 is addressed
version: [2019.8.12, 2021.7.9, 2023.8.2]
version_to_upgrade: [2021.7.9, 2023.8.2, 2025.2.0]
image: [almalinux-cloud/almalinux-8]
Expand Down
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1804,6 +1804,7 @@ The following parameters are available in the `peadm::add_database` plan:
* [`primary_host`](#-peadm--add_database--primary_host)
* [`mode`](#-peadm--add_database--mode)
* [`begin_at_step`](#-peadm--add_database--begin_at_step)
* [`is_migration`](#-peadm--add_database--is_migration)

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

Expand Down Expand Up @@ -1843,6 +1844,14 @@ Optional[Enum[

Default value: `undef`

##### <a name="-peadm--add_database--is_migration"></a>`is_migration`

Data type: `Optional[Boolean]`



Default value: `false`

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

Add or replace a replica host.
Expand Down
12 changes: 9 additions & 3 deletions plans/add_database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'update-db-settings',
'cleanup-db',
'finalize']] $begin_at_step = undef,
Optional[Boolean] $is_migration = false,
) {
$primary_target = peadm::get_targets($primary_host, 1)
$postgresql_target = peadm::get_targets($targets, 1)
Expand All @@ -22,8 +23,9 @@

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

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

Expand Down Expand Up @@ -59,11 +61,15 @@

if $operating_mode == 'init' {
# If no other PSQL node then match primary group letter
$avail_group_letter = peadm::flatten_compact($roles['server'].map |$k,$v| {
$calculated_group_letter = peadm::flatten_compact($roles['server'].map |$k,$v| {
if $v == $primary_host {
$k
}
})[0]
$avail_group_letter = $calculated_group_letter ? {
undef => $is_migration ? { true => 'A', default => undef },
default => $calculated_group_letter,
}
# Assume PuppetDB backend hosted on Primary if in init mode
$source_db_host = $primary_host
} else {
Expand Down
32 changes: 30 additions & 2 deletions plans/migrate.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@
# The new server that will become the PE primary server
# @param upgrade_version
# Optional version to upgrade to after migration is complete
#
# @param replica_host
# Optional new replica server to be added to the cluster
# @param primary_postgresql_host
# Optional new primary PostgreSQL server to be added to the cluster
# @param replica_postgresql_host
# Optional new replica PostgreSQL server to be added to the cluster
plan peadm::migrate (
Peadm::SingleTargetSpec $old_primary_host,
Peadm::SingleTargetSpec $new_primary_host,
Optional[String] $upgrade_version = undef,
Optional[Peadm::SingleTargetSpec] $replica_host = undef,
Optional[Peadm::SingleTargetSpec] $primary_postgresql_host = undef,
Optional[Peadm::SingleTargetSpec] $replica_postgresql_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')
Expand All @@ -25,7 +32,9 @@

$new_hosts = peadm::flatten_compact([
$new_primary_host,
$replica_host ? { undef => [], default => [$replica_host] }
$replica_host ? { undef => [], default => [$replica_host] },
$primary_postgresql_host ? { undef => [], default => [$primary_postgresql_host] },
$replica_postgresql_host ? { undef => [], default => [$replica_postgresql_host] },
].flatten)
$all_hosts = peadm::flatten_compact([
$old_primary_host,
Expand Down Expand Up @@ -118,10 +127,27 @@
out::message('No nodes to purge from old configuration')
}

# provision a postgresql host if one is provided
if $primary_postgresql_host {
run_plan('peadm::add_database', targets => $primary_postgresql_host,
primary_host => $new_primary_host,
is_migration => true,
)
# provision a replica postgresql host if one is provided
if $replica_postgresql_host {
run_plan('peadm::add_database', targets => $replica_postgresql_host,
primary_host => $new_primary_host,
is_migration => true,
)
}
}

# provision a replica if one is provided
if $replica_host {
run_plan('peadm::add_replica', {
primary_host => $new_primary_host,
replica_host => $replica_host,
replica_postgresql_host => $replica_postgresql_host,
})
}

Expand All @@ -134,6 +160,8 @@
version => $upgrade_version,
download_mode => 'direct',
replica_host => $replica_host,
primary_postgresql_host => $primary_postgresql_host,
replica_postgresql_host => $replica_postgresql_host,
})
}
}
4 changes: 2 additions & 2 deletions spec/acceptance/peadm_spec/plans/provision_test_cluster.pp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@
['primary', 'compiler', 'replica', 'compiler', 'new-primary', 'new-replica']
}
'extra-large-migration': {
['primary', 'primary-pdb-postgresql', 'compiler', 'new-primary', 'new-primary-pdb-postgresql']
['primary', 'primary-pdb-postgresql', 'new-primary', 'new-primary-pdb-postgresql']
}
'extra-large-with-dr-migration': {
['primary', 'primary-pdb-postgresql', 'compiler', 'replica', 'replica-pdb-postgresql', 'compiler', 'new-primary', 'new-replica', 'new-primary-pdb-postgresql', 'new-replica-pdb-postgresql']
['primary', 'primary-pdb-postgresql', 'replica', 'replica-pdb-postgresql', 'new-primary', 'new-replica', 'new-primary-pdb-postgresql', 'new-replica-pdb-postgresql']
}
default: {
fail_plan("Unknown architecture: ${architecture}")
Expand Down
6 changes: 4 additions & 2 deletions spec/acceptance/peadm_spec/plans/test_migration.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
new_primary_host => $new_primary_target,
upgrade_version => $upgrade_version,
replica_host => $new_replica_target,
primary_postgresql_host => $new_primary_postgresql_target,
replica_postgresql_host => $new_replica_postgresql_target,
)

# run infra status on the new primary
Expand Down Expand Up @@ -66,9 +68,9 @@
# if new_replica_postgresql_target is supplied then check that is in the expected place in the config
if $new_replica_postgresql_target {
if $peadm_config['params']['replica_postgresql_host'] == $new_replica_postgresql_target.peadm::certname() {
out::message("New primary postgres host ${new_replica_postgresql_target.peadm::certname()} set up correctly")
out::message("New replica postgres host ${new_replica_postgresql_target.peadm::certname()} set up correctly")
} else {
fail_plan("New primary postgres host ${new_replica_postgresql_target.peadm::certname()} was not set up correctly")
fail_plan("New replica postgres host ${new_replica_postgresql_target.peadm::certname()} was not set up correctly")
}
}

Expand Down
Loading