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