Skip to content

Commit 4c6d915

Browse files
(PE-41341) Allow primary prostgres host to be the failure
1 parent ef6f1f1 commit 4c6d915

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

.github/workflows/test-replace-failed-postgresql.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ jobs:
9999
version=${{ matrix.version }} \
100100
console_password=${{ secrets.CONSOLE_PASSWORD }} \
101101
code_manager_auto_configure=true
102+
- name: Uninstall on primary-pdb-postgresql to emulate it failing
103+
run: |
104+
bundle exec bolt plan run peadm::uninstall \
105+
--modulepath spec/fixtures/modules \
106+
-t $(yq '.groups[].targets[] | select(.vars.role == "primary-pdb-postgresql") | .name' spec/fixtures/litmus_inventory.yaml) \
107+
--no-host-key-check
102108
- name: Replace failed PostgreSQL
103109
run: |
104110
echo ::group::prepare

plans/replace_failed_postgresql.pp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,23 @@
1919
$failed_postgresql_host,
2020
$replacement_postgresql_host,
2121
])
22-
2322
# verify we can connect to targets proded before proceeding
2423
run_command('hostname', $all_hosts)
2524

26-
# Get current peadm config before making modifications
27-
$peadm_config = run_task('peadm::get_peadm_config', $primary_host).first.value
28-
$compilers = $peadm_config['params']['compilers']
25+
# Try to get current peadm config before making modifications
26+
$peadm_config = run_task('peadm::get_peadm_config', $primary_host, { '_catch_errors' => true }).first.value
27+
28+
if $peadm_config == undef or getvar('peadm_config.params') == undef {
29+
out::message('Unable to get config - the failed postgresql host may be the primary')
30+
} else {
31+
$config_replica_host = $peadm_config['params']['replica_host']
32+
$postgresql_a_host = $peadm_config['role-letter']['postgresql']['A']
33+
$postgresql_b_host = $peadm_config['role-letter']['postgresql']['B']
2934

30-
# Bail if we are not running this against an XL deployment with DR enabled - the parameters also enforce this to some extent
31-
if $compilers.empty {
32-
fail_plan('Plan peadm::replace_failed_postgresql is only applicable for XL deployments with DR enabled')
35+
# Bail if we are not running this against an XL deployment with DR enabled - the parameters also enforce this to some extent
36+
if $config_replica_host == undef or $postgresql_a_host == undef or $postgresql_b_host == undef {
37+
fail_plan('Plan peadm::replace_failed_postgresql is only applicable for XL deployments with DR enabled')
38+
}
3339
}
3440

3541
$pe_hosts = peadm::flatten_compact([

0 commit comments

Comments
 (0)