|
44 | 44 | new_primary_host => $new_primary_target, |
45 | 45 | ) |
46 | 46 |
|
| 47 | + # Initialize a variable to track the overall success status |
| 48 | + $all_checks_passed = true |
| 49 | + |
47 | 50 | # run infra status on the new primary |
48 | 51 | out::message("Running peadm::status on new primary host ${new_primary_target}") |
49 | 52 | $new_primary_status = run_plan('peadm::status', $new_primary_target, { 'format' => 'json' }) |
|
52 | 55 | if empty($new_primary_status['failed']) { |
53 | 56 | out::message('Migrated cluster is healthy, continuing') |
54 | 57 | } else { |
55 | | - fail_plan('Migrated cluster is not healthy, aborting') |
| 58 | + out::message('FAIL: Migrated cluster is not healthy') |
| 59 | + $all_checks_passed = false |
56 | 60 | } |
57 | 61 |
|
58 | 62 | # get the config from new_primary_target and verify config looks as expected |
59 | 63 | $peadm_config = run_task('peadm::get_peadm_config', $new_primary_target, '_catch_errors' => true).first.to_data() |
60 | 64 | out::message("peadm_config: ${peadm_config}") |
| 65 | +
|
61 | 66 | # if new_replica_target is supplied then check that is in the expected place in the config |
62 | 67 | if $new_replica_target { |
63 | 68 | if $peadm_config['params']['replica_host'] == $new_replica_target { |
64 | 69 | out::message("New replica host ${new_replica_target} set up correctly") |
65 | 70 | } else { |
66 | | - fail_plan("New replica host ${new_replica_target} was not set up correctly") |
| 71 | + out::message("FAIL: New replica host ${new_replica_target} was not set up correctly") |
| 72 | + $all_checks_passed = false |
67 | 73 | } |
68 | 74 | } |
69 | 75 |
|
|
72 | 78 | if $peadm_config['params']['primary_postgresql_host'] == $new_primary_postgresql_target { |
73 | 79 | out::message("New primary postgres host ${new_primary_postgresql_target} set up correctly") |
74 | 80 | } else { |
75 | | - fail_plan("New primary postgres host ${new_primary_postgresql_target} was not set up correctly") |
| 81 | + out::message("FAIL: New primary postgres host ${new_primary_postgresql_target} was not set up correctly") |
| 82 | + $all_checks_passed = false |
76 | 83 | } |
77 | 84 | } |
78 | 85 |
|
|
81 | 88 | if $peadm_config['params']['replica_postgresql_host'] == $new_replica_postgresql_target { |
82 | 89 | out::message("New primary postgres host ${new_replica_postgresql_target} set up correctly") |
83 | 90 | } else { |
84 | | - fail_plan("New primary postgres host ${new_replica_postgresql_target} was not set up correctly") |
| 91 | + out::message("FAIL: New primary postgres host ${new_replica_postgresql_target} was not set up correctly") |
| 92 | + $all_checks_passed = false |
85 | 93 | } |
86 | 94 | } |
87 | 95 |
|
|
90 | 98 | if $peadm_config['params']['pe_version'] == $upgrade_version { |
91 | 99 | out::message("Upgraded to new PE version ${upgrade_version} correctly") |
92 | 100 | } else { |
93 | | - fail_plan("Failed to upgrade to new PE version ${upgrade_version} correctly") |
| 101 | + out::message("FAIL: Upgrade to new PE version ${upgrade_version} did not work correctly") |
| 102 | + $all_checks_passed = false |
94 | 103 | } |
95 | 104 | } |
| 105 | +
|
| 106 | + # fail plan if any of the checks failed |
| 107 | + if $all_checks_passed { |
| 108 | + out::message('All checks passed') |
| 109 | + } else { |
| 110 | + fail_plan('Migration of cluster failed') |
| 111 | + } |
96 | 112 | } |
0 commit comments