Skip to content

Commit 5b34c6e

Browse files
B00885424davidmalloncares
authored andcommitted
add XL with and without DR to test migration and migrate plans
1 parent 255b974 commit 5b34c6e

File tree

6 files changed

+58
-10
lines changed

6 files changed

+58
-10
lines changed

.fixtures.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ fixtures:
99
repositories:
1010
facts: "https://github.com/puppetlabs/puppetlabs-facts.git"
1111
puppet_agent: "https://github.com/puppetlabs/puppetlabs-puppet_agent.git"
12-
provision: "https://github.com/puppetlabs/provision.git"
12+
provision:
13+
repo: 'https://github.com/puppetlabs/provision.git'
14+
ref: v3.0.1
1315
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
1416
apply_helpers: "https://github.com/puppetlabs/puppetlabs-apply_helpers"
1517
bolt_shim: "https://github.com/puppetlabs/puppetlabs-bolt_shim"

.github/workflows/test-migration.yaml

+6-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ jobs:
4040
- standard
4141
- standard-with-dr
4242
- large
43-
# - extra-large
43+
- extra-large
4444
- large-with-dr
45-
# - extra-large-with-dr
45+
- extra-large-with-dr
4646
version: [2021.7.9, 2023.8.2, 2025.2.0]
4747
image: [almalinux-cloud/almalinux-8]
4848
include:
@@ -54,6 +54,10 @@ jobs:
5454
version: 2023.8.0
5555
image: almalinux-cloud/almalinux-8
5656
new_pe_version: 2025.2.0
57+
- architecture: extra-large
58+
version: 2023.8.0
59+
image: almalinux-cloud/almalinux-8
60+
new_pe_version: 2025.2.0
5761
steps:
5862
- name: Checkout Source
5963
uses: actions/checkout@v4

REFERENCE.md

+9
Original file line numberDiff line numberDiff line change
@@ -1804,6 +1804,7 @@ The following parameters are available in the `peadm::add_database` plan:
18041804
* [`primary_host`](#-peadm--add_database--primary_host)
18051805
* [`mode`](#-peadm--add_database--mode)
18061806
* [`begin_at_step`](#-peadm--add_database--begin_at_step)
1807+
* [`is_migration`](#-peadm--add_database--is_migration)
18071808

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

@@ -1843,6 +1844,14 @@ Optional[Enum[
18431844

18441845
Default value: `undef`
18451846

1847+
##### <a name="-peadm--add_database--is_migration"></a>`is_migration`
1848+
1849+
Data type: `Optional[Boolean]`
1850+
1851+
1852+
1853+
Default value: `false`
1854+
18461855
### <a name="peadm--add_replica"></a>`peadm::add_replica`
18471856

18481857
Add or replace a replica host.

plans/add_database.pp

+9-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
'update-db-settings',
1010
'cleanup-db',
1111
'finalize']] $begin_at_step = undef,
12+
Optional[Boolean] $is_migration = false,
1213
) {
1314
$primary_target = peadm::get_targets($primary_host, 1)
1415
$postgresql_target = peadm::get_targets($targets, 1)
@@ -22,8 +23,9 @@
2223

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

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

@@ -59,11 +61,15 @@
5961

6062
if $operating_mode == 'init' {
6163
# If no other PSQL node then match primary group letter
62-
$avail_group_letter = peadm::flatten_compact($roles['server'].map |$k,$v| {
64+
$calculated_group_letter = peadm::flatten_compact($roles['server'].map |$k,$v| {
6365
if $v == $primary_host {
6466
$k
6567
}
6668
})[0]
69+
$avail_group_letter = $calculated_group_letter ? {
70+
undef => $is_migration ? { true => 'A', default => undef },
71+
default => $calculated_group_letter,
72+
}
6773
# Assume PuppetDB backend hosted on Primary if in init mode
6874
$source_db_host = $primary_host
6975
} else {

plans/migrate.pp

+27-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@
88
# The new server that will become the PE primary server
99
# @param upgrade_version
1010
# Optional version to upgrade to after migration is complete
11-
#
11+
# @param replica_host
12+
# Optional new replica server to be added to the cluster
13+
# @param primary_postgresql_host
14+
# Optional new primary PostgreSQL server to be added to the cluster
15+
# @param replica_postgresql_host
16+
# Optional new replica PostgreSQL server to be added to the cluster
1217
plan peadm::migrate (
1318
Peadm::SingleTargetSpec $old_primary_host,
1419
Peadm::SingleTargetSpec $new_primary_host,
1520
Optional[String] $upgrade_version = undef,
1621
Optional[Peadm::SingleTargetSpec] $replica_host = undef,
22+
Optional[Peadm::SingleTargetSpec] $primary_postgresql_host = undef,
23+
Optional[Peadm::SingleTargetSpec] $replica_postgresql_host = undef,
1724
) {
1825
# pre-migration checks
1926
out::message('This plan is a work in progress and it is not recommended to be used until it is fully implemented and supported')
@@ -25,7 +32,9 @@
2532

2633
$new_hosts = peadm::flatten_compact([
2734
$new_primary_host,
28-
$replica_host ? { undef => [], default => [$replica_host] }
35+
$replica_host ? { undef => [], default => [$replica_host] },
36+
$primary_postgresql_host ? { undef => [], default => [$primary_postgresql_host] },
37+
$replica_postgresql_host ? { undef => [], default => [$replica_postgresql_host] },
2938
].flatten)
3039
$all_hosts = peadm::flatten_compact([
3140
$old_primary_host,
@@ -118,10 +127,24 @@
118127
out::message('No nodes to purge from old configuration')
119128
}
120129

130+
if $primary_postgresql_host {
131+
run_plan('peadm::add_database', targets => $primary_postgresql_host,
132+
primary_host => $new_primary_host,
133+
is_migration => true,
134+
)
135+
if $replica_postgresql_host {
136+
run_plan('peadm::add_database', targets => $replica_postgresql_host,
137+
primary_host => $new_primary_host,
138+
is_migration => true,
139+
)
140+
}
141+
}
142+
121143
if $replica_host {
122144
run_plan('peadm::add_replica', {
123145
primary_host => $new_primary_host,
124146
replica_host => $replica_host,
147+
replica_postgresql_host => $replica_postgresql_host,
125148
})
126149
}
127150

@@ -134,6 +157,8 @@
134157
version => $upgrade_version,
135158
download_mode => 'direct',
136159
replica_host => $replica_host,
160+
primary_postgresql_host => $primary_postgresql_host,
161+
replica_postgresql_host => $replica_postgresql_host,
137162
})
138163
}
139164
}

spec/acceptance/peadm_spec/plans/test_migration.pp

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
new_primary_host => $new_primary_target,
3131
upgrade_version => $upgrade_version,
3232
replica_host => $new_replica_target,
33+
primary_postgresql_host => $new_primary_postgresql_target,
34+
replica_postgresql_host => $new_replica_postgresql_target,
3335
)
3436

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

0 commit comments

Comments
 (0)