-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(PE-40163) automate recovery of failed postgres server #537
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e5f1597
(PE-40163) automate recovery of failed postgres server
davidmalloncares 436b89e
(PE-40163) alternate approach to running a task
davidmalloncares cdae5da
(PE-40163) deal with empty csr attributes
davidmalloncares f71ced7
(PE-40163) update reference.md
davidmalloncares File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# @summary Replaces a failed PostgreSQL host | ||
# @param primary_host - The hostname and certname of the primary Puppet server | ||
# @param replica_host - The hostname and certname of the replica VM | ||
# @param working_postgresql_host - The hostname and certname of the still-working PE-PostgreSQL server | ||
# @param failed_postgresql_host - The hostname and certname of the failed PE-PostgreSQL server | ||
# @param replacement_postgresql_host - The hostname and certname of the server being brought in to replace the failed PE-PostgreSQL server | ||
# | ||
plan peadm::replace_failed_postgresql( | ||
Peadm::SingleTargetSpec $primary_host, | ||
Peadm::SingleTargetSpec $replica_host, | ||
Peadm::SingleTargetSpec $working_postgresql_host, | ||
Peadm::SingleTargetSpec $failed_postgresql_host, | ||
Peadm::SingleTargetSpec $replacement_postgresql_host, | ||
) { | ||
$all_hosts = peadm::flatten_compact([ | ||
$primary_host, | ||
$replica_host, | ||
$working_postgresql_host, | ||
$failed_postgresql_host, | ||
$replacement_postgresql_host, | ||
]) | ||
|
||
# verify we can connect to targets proded before proceeding | ||
run_command('hostname', $all_hosts) | ||
|
||
# Get current peadm config before making modifications | ||
$peadm_config = run_task('peadm::get_peadm_config', $primary_host).first.value | ||
$compilers = $peadm_config['params']['compilers'] | ||
|
||
# Bail if this is trying to be ran against Standard | ||
if $compilers.empty { | ||
fail_plan('Plan peadm::add_database is only applicable for L and XL deployments') | ||
} | ||
|
||
$pe_hosts = peadm::flatten_compact([ | ||
$primary_host, | ||
$replica_host, | ||
]) | ||
|
||
# Stop puppet.service on Puppet server primary and replica | ||
run_task('service', $pe_hosts, 'action' => 'stop', 'name' => 'puppet.service') | ||
|
||
# Temporarily set both primary and replica server nodes so that they use the remaining healthy PE-PostgreSQL server | ||
run_plan('peadm::util::update_db_setting', $pe_hosts, | ||
postgresql_host => $working_postgresql_host, | ||
override => true, | ||
) | ||
|
||
# Restart pe-puppetdb.service on Puppet server primary and replica | ||
run_task('service', $pe_hosts, 'action' => 'restart', 'name' => 'pe-puppetdb.service') | ||
|
||
# Purge failed PE-PostgreSQL node from PuppetDB | ||
run_command("/opt/puppetlabs/bin/puppet node purge ${$failed_postgresql_host}", $primary_host) | ||
|
||
# Run peadm::add_database plan to deploy replacement PE-PostgreSQL server | ||
run_plan('peadm::add_database', targets => $replacement_postgresql_host, | ||
primary_host => $primary_host, | ||
) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ragingra there seems to be an issue with this line. If I run this plan with this line commented out and then run that line manually it all works ok. Do you see anything obvious in how I am calling it here vs how it is called manually?
bolt plan run peadm::add_database -t <replacement-postgres-server-fqdn> primary_host=<primary-server-fqdn>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ragingra I got a fix for the issue I was having and finally got all the tests to go green - could you take a wee look? :)