Skip to content

Commit

Permalink
(PE-20589) After a simple monolithic install run puppet on non-infras…
Browse files Browse the repository at this point in the history
…tructure agents

Previously after agents were installed via simple mono install, we ran the agents
all at once. This include the master. Occasionaly there would be a change done to
the console services that would require a restart.
This would cause other agent runs to fail. So to not have that happen, we will run
only the non-infrastructure agents. That should be fine since part of the process
of installing PE should have the puppet runs included there.
  • Loading branch information
Christopher Thorn authored and kevpl committed May 26, 2017
1 parent 0fddaad commit d69499e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
10 changes: 9 additions & 1 deletion lib/beaker-pe/install/pe_utils.rb
Expand Up @@ -483,7 +483,7 @@ def simple_monolithic_install(master, agents, opts={})
end

step "Run puppet to setup mcollective and pxp-agent" do
on all_hosts, puppet_agent('-t'), :acceptable_exit_codes => [0,2], :run_in_parallel => true
run_puppet_on_non_infrastructure_nodes(all_hosts)

#Workaround for windows frictionless install, see BKR-943 for the reason
agents.select {|agent| agent['platform'] =~ /windows/}.each do |agent|
Expand Down Expand Up @@ -771,6 +771,14 @@ def install_via_msi?(host)
(host['platform'] =~ /windows-2008r2/ && (!version_is_less(host['pe_ver'], '2016.4.99') && version_is_less(host['pe_ver'], '2016.5.99') && !version_is_less(host['pe_ver'], '3.99')))
end

# Runs puppet on all nodes, unless they have the roles: master,database,console/dashboard
# @param [Array<Host>] hosts The sorted hosts to install or upgrade PE on
def run_puppet_on_non_infrastructure_nodes(all_hosts)
pe_infrastructure = select_hosts({:roles => ['master', 'compile_master', 'dashboard', 'database']}, all_hosts)
non_infrastructure = all_hosts.reject{|host| pe_infrastructure.include? host}
on non_infrastructure, puppet_agent('-t'), :acceptable_exit_codes => [0,2], :run_in_parallel => true
end

# True if version is greater than or equal to MEEP_CLASSIFICATION_VERSION
# (PE-18718) AND the temporary feature flag is true.
#
Expand Down
28 changes: 21 additions & 7 deletions spec/beaker-pe/install/pe_utils_spec.rb
Expand Up @@ -254,6 +254,27 @@ def logger
end
end

describe 'run_puppet_on_non_infrastructure_nodes' do
let(:monolithic) { make_host('monolithic', :pe_ver => '2016.4', :platform => 'el-7-x86_64', :roles => [ 'master', 'database', 'dashboard' ]) }
let(:el_agent) { make_host('agent', :pe_ver => '2016.4', :platform => 'el-7-x86_64', :roles => ['frictionless']) }
let(:deb_agent) { make_host('agent', :pe_ver => '2016.4', :platform => 'debian-7-x86_64', :roles => ['frictionless']) }
let(:master) { make_host('master', :pe_ver => '2016.4', :platform => 'el-7-x86_64', :roles => [ 'master']) }
let(:database) { make_host('database', :pe_ver => '2016.4', :platform => 'el-7-x86_64', :roles => [ 'database']) }
let(:dashboard) { make_host('dashboard', :pe_ver => '2016.4', :platform => 'el-7-x86_64', :roles => [ 'dashboard']) }
it 'runs puppet on non-infra nodes with a monolithic master' do
expect(subject).to receive(:on).with([el_agent, deb_agent], proc {|cmd| cmd.command == "puppet agent"}, hash_including(:run_in_parallel => true)).once
expect(subject).to receive(:on).with([monolithic], proc {|cmd| cmd.command == "puppet agent"}, hash_including(:run_in_parallel => true)).never
subject.run_puppet_on_non_infrastructure_nodes([monolithic, el_agent, deb_agent])
end
it 'runs puppet on non-infra nodes with a split topology' do
expect(subject).to receive(:on).with([el_agent, deb_agent], proc {|cmd| cmd.command == "puppet agent"}, hash_including(:run_in_parallel => true)).once
expect(subject).to receive(:on).with([master], proc {|cmd| cmd.command == "puppet agent"}, hash_including(:run_in_parallel => true)).never
expect(subject).to receive(:on).with([database], proc {|cmd| cmd.command == "puppet agent"}, hash_including(:run_in_parallel => true)).never
expect(subject).to receive(:on).with([dashboard], proc {|cmd| cmd.command == "puppet agent"}, hash_including(:run_in_parallel => true)).never
subject.run_puppet_on_non_infrastructure_nodes([master, database, dashboard, el_agent, deb_agent])
end
end

describe 'install_via_msi?' do
it 'returns true if pe_version is before PE 2016.4.0' do
the_host = winhost.dup
Expand Down Expand Up @@ -1351,13 +1372,6 @@ def slice_installer_options(host)
subject.simple_monolithic_install(monolithic, agents)
end

it 'runs agents in parallel, only one time' do
agents = [el_agent, el_agent, deb_agent, deb_agent]
expect(subject).to receive(:on).with([monolithic, *agents], proc {|cmd| cmd.command == "puppet agent"}, hash_including(:run_in_parallel => true)).once

subject.simple_monolithic_install(monolithic, agents)
end

it "calls prepare_hosts on all hosts instead of just master" do
expect(subject).to receive(:prepare_hosts).with([monolithic] + [el_agent, el_agent, el_agent], {})
subject.simple_monolithic_install(monolithic, [el_agent, el_agent, el_agent])
Expand Down

0 comments on commit d69499e

Please sign in to comment.