|
7 | 7 | String $new_replica_host, |
8 | 8 | String $new_primary_postgresql_host, |
9 | 9 | String $new_replica_postgresql_host, |
| 10 | + String $new_pe_version, |
10 | 11 | ) { |
11 | 12 | out::message("primary_host:${primary_host}.") |
12 | 13 | out::message("replica_host:${replica_host}.") |
|
54 | 55 | # new_primary_host => $new_primary_host, |
55 | 56 | # ) |
56 | 57 |
|
57 | | - # # run infra status on the new primary |
58 | | - # out::message("Running peadm::status on new primary host ${new_primary_host}") |
59 | | - # $new_primary_status = run_plan('peadm::status', $new_primary_host, { 'format' => 'json' }) |
60 | | - # out::message($primary_status) |
| 58 | + # run infra status on the new primary |
| 59 | + out::message("Running peadm::status on new primary host ${new_primary_target}") |
| 60 | + $new_primary_status = run_plan('peadm::status', $new_primary_target, { 'format' => 'json' }) |
| 61 | + out::message($new_primary_status) |
61 | 62 |
|
62 | | - # if empty($new_primary_status['failed']) { |
63 | | - # out::message('Migrated cluster is healthy, continuing') |
64 | | - # } else { |
65 | | - # fail_plan('Migrated cluster is not healthy, aborting') |
66 | | - # } |
| 63 | + if empty($new_primary_status['failed']) { |
| 64 | + out::message('Migrated cluster is healthy, continuing') |
| 65 | + } else { |
| 66 | + fail_plan('Migrated cluster is not healthy, aborting') |
| 67 | + } |
67 | 68 |
|
68 | | - # MIGHT WANT TO ADD CHECKS HERE TO VERIFY THE NEW ARCHITECTURE IS AS EXPECTED |
| 69 | + # get the config from new_primary_target and verify config looks as expected |
| 70 | + $result = run_task('peadm::get_peadm_config', $new_primary_target, '_catch_errors' => true).first.to_data() |
| 71 | + out::message("peadm_config: ${result}") |
| 72 | + # if new_replica_host is not empty then check that is in the expected place in the config |
| 73 | + if $new_replica_host != '' { |
| 74 | + if $peadm_config['params']['replica_host'] == $new_replica_host { |
| 75 | + out::message("New replica host ${new_replica_host} set up correctly") |
| 76 | + } else { |
| 77 | + fail_plan("New replica host ${new_replica_host} was not set up correctly") |
| 78 | + } |
| 79 | + } |
69 | 80 |
|
70 | | - # # get the config from primary_target and verify failed_postgresql_host is removed and replacement was added |
71 | | - # $result = run_task('peadm::get_peadm_config', $primary_target, '_catch_errors' => true).first.to_data() |
72 | | - # $primary_postgres_host = $result['value']['params']['primary_postgresql_host'] |
73 | | - # $replica_postgres_host = $result['value']['params']['replica_postgresql_host'] |
| 81 | + # if new_primary_postgresql_host is not empty then check that is in the expected place in the config |
| 82 | + if $new_primary_postgresql_host != '' { |
| 83 | + if $peadm_config['params']['primary_postgresql_host'] == $new_primary_postgresql_host { |
| 84 | + out::message("New primary postgres host ${new_primary_postgresql_host} set up correctly") |
| 85 | + } else { |
| 86 | + fail_plan("New primary postgres host ${new_primary_postgresql_host} was not set up correctly") |
| 87 | + } |
| 88 | + } |
74 | 89 |
|
75 | | - # if $primary_postgres_host == $failed_postgresql_host or $replica_postgres_host == $failed_postgresql_host { |
76 | | - # fail_plan("Failed PostgreSQL host ${failed_postgresql_host} was not removed from the PE configuration") |
77 | | - # } else { |
78 | | - # out::message("Failed PostgreSQL host ${failed_postgresql_host} was removed from the PE configuration") |
79 | | - # } |
80 | | - # if $primary_postgres_host == $replacement_postgresql_host or $replica_postgres_host == $replacement_postgresql_host { |
81 | | - # out::message("Replacement PostgreSQL host ${replacement_postgresql_host} was added to the PE configuration") |
82 | | - # } else { |
83 | | - # fail_plan("Replacement PostgreSQL host ${replacement_postgresql_host} was not added the PE configuration") |
84 | | - # } |
| 90 | + # if new_replica_postgresql_host is not empty then check that is in the expected place in the config |
| 91 | + if $new_replica_postgresql_host != '' { |
| 92 | + if $peadm_config['params']['replica_postgresql_host'] == $new_replica_postgresql_host { |
| 93 | + out::message("New primary postgres host ${new_replica_postgresql_host} set up correctly") |
| 94 | + } else { |
| 95 | + fail_plan("New primary postgres host ${new_replica_postgresql_host} was not set up correctly") |
| 96 | + } |
| 97 | + } |
| 98 | +
|
| 99 | + # if a new PE version was specified then check it has been upgraded |
| 100 | + if ($new_pe_version != '') { |
| 101 | + if $peadm_config['params']['pe_version'] == $new_pe_version { |
| 102 | + out::message("Upgraded to new PE version ${new_pe_version} correctly") |
| 103 | + } else { |
| 104 | + fail_plan("Failed to upgrade to new PE version ${new_pe_version} correctly") |
| 105 | + } |
| 106 | + } |
85 | 107 | } |
0 commit comments