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

(PE-14934) Add more robust puppetdb check #3

Merged
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
63 changes: 43 additions & 20 deletions lib/beaker-pe/install/pe_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require "beaker/dsl/install_utils/#{lib}"
end
require "beaker-answers"
require "timeout"
module Beaker
module DSL
module InstallUtils
Expand Down Expand Up @@ -443,17 +444,20 @@ def do_install hosts, opts = {}
# Wait for PuppetDB to be totally up and running (post 3.0 version of pe only)
sleep_until_puppetdb_started(database) unless pre30database

# Run the agent once to ensure everything is in the dashboard
install_hosts.each do |host|
on host, puppet_agent('-t'), :acceptable_exit_codes => [0,2]

# Workaround for PE-1105 when deploying 3.0.0
# The installer did not respect our database host answers in 3.0.0,
# and would cause puppetdb to be bounced by the agent run. By sleeping
# again here, we ensure that if that bounce happens during an upgrade
# test we won't fail early in the install process.
if host['pe_ver'] == '3.0.0' and host == database
sleep_until_puppetdb_started(database)
step "First puppet agent run" do
# Run the agent once to ensure everything is in the dashboard
install_hosts.each do |host|
on host, puppet_agent('-t'), :acceptable_exit_codes => [0,2]

# Workaround for PE-1105 when deploying 3.0.0
# The installer did not respect our database host answers in 3.0.0,
# and would cause puppetdb to be bounced by the agent run. By sleeping
# again here, we ensure that if that bounce happens during an upgrade
# test we won't fail early in the install process.
if host == database && ! pre30database
sleep_until_puppetdb_started(database)
check_puppetdb_status_endpoint(database)
Copy link
Contributor

Choose a reason for hiding this comment

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

Britt and I are discussing that we probably need to gate this function only to run on 2016.1.x, since the status end point won't be there for all versions.

end
end
end

Expand All @@ -471,15 +475,18 @@ def do_install hosts, opts = {}
on dashboard, "/opt/puppet/bin/rake -sf /opt/puppet/share/puppet-dashboard/Rakefile #{task} RAILS_ENV=production"
end

# Now that all hosts are in the dashbaord, run puppet one more
# time to configure mcollective
install_hosts.each do |host|
on host, puppet_agent('-t'), :acceptable_exit_codes => [0,2]
# To work around PE-14318 if we just ran puppet agent on the
# database node we will need to wait until puppetdb is up and
# running before continuing
if host == database
sleep_until_puppetdb_started(database)
step "Final puppet agent run" do
# Now that all hosts are in the dashbaord, run puppet one more
# time to configure mcollective
install_hosts.each do |host|
on host, puppet_agent('-t'), :acceptable_exit_codes => [0,2]
# To work around PE-14318 if we just ran puppet agent on the
# database node we will need to wait until puppetdb is up and
# running before continuing
if host == database && ! pre30database
sleep_until_puppetdb_started(database)
check_puppetdb_status_endpoint(database)
end
end
end
end
Expand Down Expand Up @@ -540,6 +547,22 @@ def install_pe
install_pe_on(hosts, options)
end

def check_puppetdb_status_endpoint(host)
if version_is_less(host['pe_ver'], '2016.1.0')
Copy link
Contributor

Choose a reason for hiding this comment

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

You could inline this conditional.

return true
end
Timeout.timeout(60) do
match = nil
while not match
output = on(host, "curl -s http://localhost:8080/pdb/meta/v1/version", :accept_all_exit_codes => true)
match = output.stdout =~ /version.*\d+\.\d+\.\d+/
sleep 1
Copy link

Choose a reason for hiding this comment

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

if at first you don't succeed...

end
end
rescue Timeout::Error
fail_test "PuppetDB took too long to start"
end

#Install PE based upon host configuration and options
#
# @param [Host, Array<Host>] install_hosts One or more hosts to act upon
Expand Down