From d69499ee2338a8353c6ce77139493ae52922327c Mon Sep 17 00:00:00 2001 From: Christopher Thorn Date: Wed, 24 May 2017 12:50:32 -0700 Subject: [PATCH] (PE-20589) After a simple monolithic install run puppet on non-infrastructure 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. --- lib/beaker-pe/install/pe_utils.rb | 10 ++++++++- spec/beaker-pe/install/pe_utils_spec.rb | 28 ++++++++++++++++++------- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/lib/beaker-pe/install/pe_utils.rb b/lib/beaker-pe/install/pe_utils.rb index 44724986..6644f579 100644 --- a/lib/beaker-pe/install/pe_utils.rb +++ b/lib/beaker-pe/install/pe_utils.rb @@ -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| @@ -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] 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. # diff --git a/spec/beaker-pe/install/pe_utils_spec.rb b/spec/beaker-pe/install/pe_utils_spec.rb index 8403c442..ccdfa9d7 100644 --- a/spec/beaker-pe/install/pe_utils_spec.rb +++ b/spec/beaker-pe/install/pe_utils_spec.rb @@ -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 @@ -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])