class Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector
Attributes
exception[R]
node[R]
Public Class Methods
new(node, exception)
click to toggle source
# File lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb, line 33 def initialize(node, exception) @node, @exception = node, exception end
Public Instance Methods
add_explanation(error_description)
click to toggle source
# File lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb, line 37 def add_explanation(error_description) case exception when Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError error_description.section("Networking Error:", <<~E) #{exception.message} Your chef_server_url may be misconfigured, or the network could be down. E when Net::HTTPClientException, Net::HTTPFatalError humanize_http_exception(error_description) when Chef::Exceptions::MissingRole describe_missing_role(error_description) when EOFError describe_eof_error(error_description) else error_description.section("Unexpected Error:", "#{exception.class.name}: #{exception.message}") end end
config()
click to toggle source
# File lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb, line 72 def config Chef::Config end
describe_missing_role(error_description)
click to toggle source
# File lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb, line 56 def describe_missing_role(error_description) error_description.section("Missing Role(s) in Run List:", missing_roles_explained) original_run_list = node.run_list.map { |item| "* #{item}" }.join("\n") error_description.section("Original Run List", original_run_list) end
humanize_http_exception(error_description)
click to toggle source
# File lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb, line 76 def humanize_http_exception(error_description) response = exception.response case response when Net::HTTPUnauthorized error_description.section("Authentication Error:", <<~E) Failed to authenticate to the #{Chef::Dist::SERVER_PRODUCT} (http 401). E error_description.section("Server Response:", format_rest_error) error_description.section("Relevant Config Settings:", <<~E) chef_server_url "#{server_url}" node_name "#{username}" client_key "#{api_key}" If these settings are correct, your client_key may be invalid. E when Net::HTTPForbidden # TODO: we're rescuing errors from Node.find_or_create # * could be no write on nodes container # * could be no read on the node error_description.section("Authorization Error", <<~E) Your client is not authorized to load one or more of your roles (HTTP 403). E error_description.section("Server Response:", format_rest_error) error_description.section("Possible Causes:", <<~E) * Your client (#{username}) may have misconfigured authorization permissions. E when Net::HTTPNotAcceptable describe_406_error(error_description, response) when Net::HTTPInternalServerError error_description.section("Unknown Server Error:", <<~E) The server had a fatal error attempting to load a role. E error_description.section("Server Response:", format_rest_error) when Net::HTTPBadGateway, Net::HTTPServiceUnavailable error_description.section("Server Unavailable", "The #{Chef::Dist::SERVER_PRODUCT} is temporarily unavailable") error_description.section("Server Response:", format_rest_error) else error_description.section("Unexpected API Request Failure:", format_rest_error) end end
missing_roles_explained()
click to toggle source
# File lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb, line 62 def missing_roles_explained run_list_expansion.missing_roles_with_including_role.map do |role, includer| "* #{role} included by '#{includer}'" end.join("\n") end
run_list_expansion()
click to toggle source
# File lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb, line 68 def run_list_expansion exception.expansion end