Skip to content

Commit

Permalink
Fixes #36694 - Show failed resources on installation
Browse files Browse the repository at this point in the history
Kafo 7.1.0 has started to capture Puppet reports and in 7.2.0 it was
extended for better messages. This allows showing the failed resources
which makes it easier to troubleshoot failures.  Ideally speaking the
user doesn't have to open the installer log anymore and the regular
installer command is sufficient.
  • Loading branch information
ekohl committed Sep 26, 2023
1 parent 889b267 commit 0d2fb67
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source 'https://rubygems.org'
# We don't want to list psych since that updates the bundled version
gem 'rdoc', '< 6.4'

gem 'kafo', '>= 6.4', '< 8'
gem 'kafo', '>= 7.2', '< 8'
gem 'librarian-puppet', '>= 3.0'
gem 'puppet', ENV.key?('PUPPET_VERSION') ? "~> #{ENV['PUPPET_VERSION']}" : '~> 7.0'
gem 'facter', '>= 3.0', '!= 4.0.52'
Expand Down
30 changes: 26 additions & 4 deletions hooks/boot/02-message-helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,35 @@ def dev_new_install_message(kafo)
end

def failure_message
say "\n <%= color('There were errors detected during install.', :bad) %>"
say " Please address the errors and re-run the installer to ensure the system is properly configured."
say " Failing to do so is likely to result in broken functionality."
message = 'There were errors detected during installation.'

if puppet_report&.failed_resources&.any?
say "\n"

puppet_report.failed_resources.each_with_index do |failed_resource, index|
say "Error #{index + 1}: #{failed_resource} failed. Logs:"
failed_resource.log_messages_by_source.each do |source, log_messages|
say " #{source}"
log_messages.each do |log_message|
say " #{log_message}"
end
end
end

message = if puppet_report.failed_resources.length == 1
'1 error was detected during installation.'
else
"#{puppet_report.failed_resources.length} errors were detected."
end
end

say "\n<%= color('#{message}', :bad) %>"
say "Please address the errors and re-run the installer to ensure the system is properly configured."
say "Failing to do so is likely to result in broken functionality."
end

def log_message(kafo)
say "\n The full log is at <%= color('#{kafo.config.log_file}', :info) %>"
say "\nThe full log is at <%= color('#{kafo.config.log_file}', :info) %>"
end
end

Expand Down

0 comments on commit 0d2fb67

Please sign in to comment.