Skip to content
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

Removed local:// dependency for upgrades #24

Merged
merged 3 commits into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions functions/fail_on_transport.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Fails if any nodes have the chosen transport.
#
# Useful for excluding PCP when it's not appopriate
#
function pe_xl::fail_on_transport (
TargetSpec $nodes,
String $transport,
) {
$targets = get_targets($nodes)
$targets.each |$target| {
if $target.protocol == $transport {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

God damn it. How did I miss this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should delete my function then (pe_xl::transport)

fail_plan(
"${target.name} uses ${transport} transport. This is not supported",
'unexpected-transport',
{
'target' => $target,
'transport' => $transport,
}
)
}
}
}
34 changes: 23 additions & 11 deletions plans/upgrade.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,25 @@
Optional[String[1]] $master_replica_host = undef,
Optional[String[1]] $puppetdb_database_replica_host = undef,

String[1] $version = '2018.1.4',
String[1] $version,

# This parameter exists to enable the use case of running pe_xl::upgrade over
# the PCP transport. An orchestrator restart happens during provision
# replica. Running `bolt plan run` directly on the master and using local
# transport for that node will let the plan to run to completion without
# failing due to being disconnected from the orchestrator.
Boolean $executing_on_master = false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to do this though? Wouldn't it be better for the user to just specify the target properly? Instead of not specifying it then telling the plan it's running on the master, who not just have the user supply local://master.whatever?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would, yeah. However, at that point we would need to do a little more work to update the plans to use proper Target objects so that we can distinguish between their hostnames / assumed certnames, and the protocol+name used to connect to them. The variables are currently used kind of interchangeably. For example, it wouldn't be good to end up writing a whitelist file that specified "local://master".

I implemented it this way for now to match the pe_xl::configure plan. It should be a straightforward iteration to clean up the code to use get_targets() and real target objects, be specific about when we want a name vs. when we want the protocol-inclusive Target object, and remove these executing_on_master parameters then.


String[1] $stagingdir = '/tmp',
String[1] $pe_source = "https://s3.amazonaws.com/pe-builds/released/${version}/puppet-enterprise-${version}-el-7-x86_64.tar.gz",
) {

# Allow for the upgrade task to be run local to the master.
$master_target = $executing_on_master ? {
true => "local://${master_host}",
false => $master_host,
}

$ha_replica_target = [
$master_replica_host,
].pe_xl::flatten_compact()
Expand Down Expand Up @@ -40,23 +53,24 @@
| PQL

$all_hosts = [
$master_host,
$master_target,
$puppetdb_database_host,
$master_replica_host,
$puppetdb_database_replica_host,
$compiler_cluster_master_hosts,
$compiler_cluster_master_replica_hosts,
].pe_xl::flatten_compact()

$master_local = "local://${master_host}"
# We need to make sure we aren't using PCP as this will go down during the upgrade
$all_hosts.pe_xl::fail_on_transport('pcp')

# TODO: Do we need to update the pe.conf(s) with a console password?

# Download the PE tarball on the nodes that need it
$upload_tarball_path = "/tmp/puppet-enterprise-${version}-el-7-x86_64.tar.gz"

$download_hosts = [
$master_host,
$master_target,
$puppetdb_database_host,
$puppetdb_database_replica_host,
].pe_xl::flatten_compact()
Expand All @@ -81,17 +95,15 @@
# Shut down pe-* services on the master. Only shutting down the ones
# that have failover pairs on the master replica.
['pe-console-services', 'pe-nginx', 'pe-puppetserver', 'pe-puppetdb', 'pe-postgresql'].each |$service| {
run_task('service', $master_local,
run_task('service', $master_target,
action => 'stop',
name => $service,
)
}

# TODO: Firewall up the master

# Upgrade the master using the local:// transport in anticipation of
# the orchestrator service being restarted during the upgrade.
run_task('pe_xl::pe_install', $master_local,
run_task('pe_xl::pe_install', $master_target,
tarball => $upload_tarball_path,
)

Expand All @@ -104,23 +116,23 @@
run_task('pe_xl::puppet_runonce', $puppetdb_database_host)

# Stop PuppetDB on the master
run_task('service', $master_local,
run_task('service', $master_target,
action => 'stop',
name => 'pe-puppetdb',
)

# TODO: Unblock 8081 between the master and the master replica

# Start PuppetDB on the master
run_task('service', $master_local,
run_task('service', $master_target,
action => 'start',
name => 'pe-puppetdb',
)

# TODO: Remove remaining firewall blocks

# Wait until orchestrator service is healthy to proceed
run_task('pe_xl::orchestrator_healthcheck', $master_local)
run_task('pe_xl::orchestrator_healthcheck', $master_target)

# Upgrade the compiler group A hosts
run_task('pe_xl::agent_upgrade', $compiler_cluster_master_hosts,
Expand Down