summaryrefslogtreecommitdiff
path: root/lib/chef/formatters/error_inspectors
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-02-05 15:00:00 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-02-05 15:00:00 -0800
commit686113531d23f30e9973d659c456ae33eb9cff1f (patch)
treef225de7251a8b49b8d183dd168bab0a0addbe23f /lib/chef/formatters/error_inspectors
parentd1cf34b059a16a81e0fc48de52ba29863bb41fe6 (diff)
downloadchef-686113531d23f30e9973d659c456ae33eb9cff1f.tar.gz
autofixing whitespace cops
4174 Style/SpaceInsideHashLiteralBraces 1860 Style/SpaceAroundOperators 1336 Style/SpaceInsideBlockBraces 1292 Style/AlignHash 997 Style/SpaceAfterComma 860 Style/SpaceAroundEqualsInParameterDefault 310 Style/EmptyLines 294 Style/IndentationConsistency 267 Style/TrailingWhitespace 238 Style/ExtraSpacing 212 Style/SpaceBeforeBlockBraces 166 Style/MultilineOperationIndentation 144 Style/TrailingBlankLines 120 Style/EmptyLineBetweenDefs 101 Style/IndentationWidth 82 Style/SpaceAroundBlockParameters 40 Style/EmptyLinesAroundMethodBody 29 Style/EmptyLinesAroundAccessModifier 1 Style/RescueEnsureAlignment
Diffstat (limited to 'lib/chef/formatters/error_inspectors')
-rw-r--r--lib/chef/formatters/error_inspectors/api_error_formatting.rb23
-rw-r--r--lib/chef/formatters/error_inspectors/compile_error_inspector.rb16
-rw-r--r--lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb7
-rw-r--r--lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb2
-rw-r--r--lib/chef/formatters/error_inspectors/node_load_error_inspector.rb15
-rw-r--r--lib/chef/formatters/error_inspectors/registration_error_inspector.rb32
-rw-r--r--lib/chef/formatters/error_inspectors/resource_failure_inspector.rb11
-rw-r--r--lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb18
8 files changed, 59 insertions, 65 deletions
diff --git a/lib/chef/formatters/error_inspectors/api_error_formatting.rb b/lib/chef/formatters/error_inspectors/api_error_formatting.rb
index 0ea313eb92..2415d0f4bb 100644
--- a/lib/chef/formatters/error_inspectors/api_error_formatting.rb
+++ b/lib/chef/formatters/error_inspectors/api_error_formatting.rb
@@ -26,18 +26,18 @@ class Chef
NETWORK_ERROR_CLASSES = [Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError]
def describe_network_errors(error_description)
- error_description.section("Networking Error:",<<-E)
+ error_description.section("Networking Error:", <<-E)
#{exception.message}
Your chef_server_url may be misconfigured, or the network could be down.
E
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
chef_server_url "#{server_url}"
E
end
def describe_eof_error(error_description)
- error_description.section("Authentication Error:",<<-E)
+ error_description.section("Authentication Error:", <<-E)
Received an EOF on transport socket. This almost always indicates a network
error external to chef-client. Some causes include:
@@ -74,18 +74,18 @@ broken virtual networking code.
def describe_401_error(error_description)
if clock_skew?
- error_description.section("Authentication Error:",<<-E)
+ error_description.section("Authentication Error:", <<-E)
Failed to authenticate to the chef server (http 401).
The request failed because your clock has drifted by more than 15 minutes.
Syncing your clock to an NTP Time source should resolve the issue.
E
else
- error_description.section("Authentication Error:",<<-E)
+ error_description.section("Authentication Error:", <<-E)
Failed to authenticate to the chef server (http 401).
E
error_description.section("Server Response:", format_rest_error)
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
chef_server_url "#{server_url}"
node_name "#{username}"
client_key "#{api_key}"
@@ -97,10 +97,10 @@ E
end
def describe_400_error(error_description)
- error_description.section("Invalid Request Data:",<<-E)
+ error_description.section("Invalid Request Data:", <<-E)
The data in your request was invalid (HTTP 400).
E
- error_description.section("Server Response:",format_rest_error)
+ error_description.section("Server Response:", format_rest_error)
end
def describe_406_error(error_description, response)
@@ -110,7 +110,7 @@ E
min_server_version = version_header["min_version"]
max_server_version = version_header["max_version"]
- error_description.section("Incompatible server API version:",<<-E)
+ error_description.section("Incompatible server API version:", <<-E)
This version of the API that this Chef request specified is not supported by the Chef server you sent this request to.
The server supports a min API version of #{min_server_version} and a max API version of #{max_server_version}.
Chef just made a request with an API version of #{client_api_version}.
@@ -122,18 +122,17 @@ E
end
def describe_500_error(error_description)
- error_description.section("Unknown Server Error:",<<-E)
+ error_description.section("Unknown Server Error:", <<-E)
The server had a fatal error attempting to load the node data.
E
error_description.section("Server Response:", format_rest_error)
end
def describe_503_error(error_description)
- error_description.section("Server Unavailable","The Chef Server is temporarily unavailable")
+ error_description.section("Server Unavailable", "The Chef Server is temporarily unavailable")
error_description.section("Server Response:", format_rest_error)
end
-
# Fallback for unexpected/uncommon http errors
def describe_http_error(error_description)
error_description.section("Unexpected API Request Failure:", format_rest_error)
diff --git a/lib/chef/formatters/error_inspectors/compile_error_inspector.rb b/lib/chef/formatters/error_inspectors/compile_error_inspector.rb
index 589f98ddf2..d5ed69a83d 100644
--- a/lib/chef/formatters/error_inspectors/compile_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/compile_error_inspector.rb
@@ -40,7 +40,7 @@ class Chef
error_description.section(exception.class.name, exception.message)
if found_error_in_cookbooks?
- traceback = filtered_bt.map {|line| " #{line}"}.join("\n")
+ traceback = filtered_bt.map { |line| " #{line}" }.join("\n")
error_description.section("Cookbook Trace:", traceback)
error_description.section("Relevant File Content:", context)
end
@@ -107,22 +107,22 @@ class Chef
def culprit_backtrace_entry
@culprit_backtrace_entry ||= begin
- bt_entry = filtered_bt.first
- Chef::Log.debug("Backtrace entry for compile error: '#{bt_entry}'")
- bt_entry
+ bt_entry = filtered_bt.first
+ Chef::Log.debug("Backtrace entry for compile error: '#{bt_entry}'")
+ bt_entry
end
end
def culprit_line
@culprit_line ||= begin
- line_number = culprit_backtrace_entry[/^(?:.\:)?[^:]+:([\d]+)/,1].to_i
+ line_number = culprit_backtrace_entry[/^(?:.\:)?[^:]+:([\d]+)/, 1].to_i
Chef::Log.debug("Line number of compile error: '#{line_number}'")
line_number
end
end
def culprit_file
- @culprit_file ||= culprit_backtrace_entry[/^((?:.\:)?[^:]+):([\d]+)/,1]
+ @culprit_file ||= culprit_backtrace_entry[/^((?:.\:)?[^:]+):([\d]+)/, 1]
end
def filtered_bt
@@ -136,8 +136,8 @@ class Chef
def backtrace_lines_in_cookbooks
@backtrace_lines_in_cookbooks ||=
begin
- filters = Array(Chef::Config.cookbook_path).map {|p| /^#{Regexp.escape(p)}/i }
- r = exception.backtrace.select {|line| filters.any? {|filter| line =~ filter }}
+ filters = Array(Chef::Config.cookbook_path).map { |p| /^#{Regexp.escape(p)}/i }
+ r = exception.backtrace.select { |line| filters.any? { |filter| line =~ filter } }
Chef::Log.debug("Filtered backtrace of compile error: #{r.join(",")}")
r
end
diff --git a/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb b/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb
index b60b9d91d1..eb1aa629ff 100644
--- a/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb
@@ -42,7 +42,7 @@ class Chef
when *NETWORK_ERROR_CLASSES
describe_network_errors(error_description)
else
- error_description.section("Unexpected Error:","#{exception.class.name}: #{exception.message}")
+ error_description.section("Unexpected Error:", "#{exception.class.name}: #{exception.message}")
end
end
@@ -56,7 +56,7 @@ class Chef
# 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)
+ error_description.section("Authorization Error", <<-E)
This client is not authorized to read some of the information required to
access its cookbooks (HTTP 403).
@@ -128,7 +128,7 @@ EOM
end
def expanded_run_list_ul
- @expanded_run_list.map {|i| "* #{i}"}.join("\n")
+ @expanded_run_list.map { |i| "* #{i}" }.join("\n")
end
# In my tests, the error from the server is double JSON encoded, but we
@@ -162,7 +162,6 @@ EOM
maybe_json_string
end
-
end
end
end
diff --git a/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb b/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb
index 5ac39d7a83..3bd9b419fa 100644
--- a/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb
@@ -48,7 +48,7 @@ class Chef
when *NETWORK_ERROR_CLASSES
describe_network_errors(error_description)
else
- error_description.section("Unexpected Error:","#{exception.class.name}: #{exception.message}")
+ error_description.section("Unexpected Error:", "#{exception.class.name}: #{exception.message}")
end
end
diff --git a/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb b/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb
index b3196caddb..c52dad4c09 100644
--- a/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb
@@ -22,7 +22,6 @@ class Chef
module Formatters
module ErrorInspectors
-
# == APIErrorInspector
# Wraps exceptions caused by API calls to the server.
class NodeLoadErrorInspector
@@ -44,11 +43,11 @@ class Chef
when Net::HTTPServerException, Net::HTTPFatalError
humanize_http_exception(error_description)
when Chef::Exceptions::PrivateKeyMissing
- error_description.section("Private Key Not Found:",<<-E)
+ error_description.section("Private Key Not Found:", <<-E)
Your private key could not be loaded. If the key file exists, ensure that it is
readable by chef-client.
E
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
client_key "#{api_key}"
E
when EOFError
@@ -56,7 +55,7 @@ E
when *NETWORK_ERROR_CLASSES
describe_network_errors(error_description)
else
- error_description.section("Unexpected Error:","#{exception.class.name}: #{exception.message}")
+ error_description.section("Unexpected Error:", "#{exception.class.name}: #{exception.message}")
end
end
@@ -70,12 +69,12 @@ E
# 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)
+ error_description.section("Authorization Error", <<-E)
Your client is not authorized to load the node data (HTTP 403).
E
error_description.section("Server Response:", format_rest_error)
- error_description.section("Possible Causes:",<<-E)
+ error_description.section("Possible Causes:", <<-E)
* Your client (#{username}) may have misconfigured authorization permissions.
E
when Net::HTTPBadRequest
@@ -98,10 +97,10 @@ E
# one, e.g., PUT http://wrong.url/nodes/node-name becomes a GET after a
# redirect.
def describe_404_error(error_description)
- error_description.section("Resource Not Found:",<<-E)
+ error_description.section("Resource Not Found:", <<-E)
The server returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.
E
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
chef_server_url "#{server_url}"
E
end
diff --git a/lib/chef/formatters/error_inspectors/registration_error_inspector.rb b/lib/chef/formatters/error_inspectors/registration_error_inspector.rb
index 8c070742f7..c7c1454311 100644
--- a/lib/chef/formatters/error_inspectors/registration_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/registration_error_inspector.rb
@@ -26,25 +26,25 @@ class Chef
when Net::HTTPServerException, Net::HTTPFatalError
humanize_http_exception(error_description)
when Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError
- error_description.section("Network Error:",<<-E)
+ error_description.section("Network Error:", <<-E)
There was a network error connecting to the Chef Server:
#{exception.message}
E
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
chef_server_url "#{server_url}"
If your chef_server_url is correct, your network could be down.
E
when Chef::Exceptions::PrivateKeyMissing
- error_description.section("Private Key Not Found:",<<-E)
+ error_description.section("Private Key Not Found:", <<-E)
Your private key could not be loaded. If the key file exists, ensure that it is
readable by chef-client.
E
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
validation_key "#{api_key}"
E
when Chef::Exceptions::InvalidRedirect
- error_description.section("Invalid Redirect:",<<-E)
+ error_description.section("Invalid Redirect:", <<-E)
Change your server location in client.rb to the server's FQDN to avoid unwanted redirections.
E
when EOFError
@@ -59,18 +59,18 @@ E
case response
when Net::HTTPUnauthorized
if clock_skew?
- error_description.section("Authentication Error:",<<-E)
+ error_description.section("Authentication Error:", <<-E)
Failed to authenticate to the chef server (http 401).
The request failed because your clock has drifted by more than 15 minutes.
Syncing your clock to an NTP Time source should resolve the issue.
E
else
- error_description.section("Authentication Error:",<<-E)
+ error_description.section("Authentication Error:", <<-E)
Failed to authenticate to the chef server (http 401).
E
error_description.section("Server Response:", format_rest_error)
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
chef_server_url "#{server_url}"
validation_client_name "#{username}"
validation_key "#{api_key}"
@@ -79,34 +79,34 @@ If these settings are correct, your validation_key may be invalid.
E
end
when Net::HTTPForbidden
- error_description.section("Authorization Error:",<<-E)
+ error_description.section("Authorization Error:", <<-E)
Your validation client is not authorized to create the client for this node (HTTP 403).
E
- error_description.section("Possible Causes:",<<-E)
+ error_description.section("Possible Causes:", <<-E)
* There may already be a client named "#{config[:node_name]}"
* Your validation client (#{username}) may have misconfigured authorization permissions.
E
when Net::HTTPBadRequest
- error_description.section("Invalid Request Data:",<<-E)
+ error_description.section("Invalid Request Data:", <<-E)
The data in your request was invalid (HTTP 400).
E
- error_description.section("Server Response:",format_rest_error)
+ error_description.section("Server Response:", format_rest_error)
when Net::HTTPNotFound
- error_description.section("Resource Not Found:",<<-E)
+ error_description.section("Resource Not Found:", <<-E)
The server returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.
E
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
chef_server_url "#{server_url}"
E
when Net::HTTPNotAcceptable
describe_406_error(error_description, response)
when Net::HTTPInternalServerError
- error_description.section("Unknown Server Error:",<<-E)
+ error_description.section("Unknown Server Error:", <<-E)
The server had a fatal error attempting to load the node data.
E
error_description.section("Server Response:", format_rest_error)
when Net::HTTPBadGateway, Net::HTTPServiceUnavailable
- error_description.section("Server Unavailable","The Chef Server is temporarily unavailable")
+ error_description.section("Server Unavailable", "The Chef Server is temporarily unavailable")
error_description.section("Server Response:", format_rest_error)
else
error_description.section("Unexpected API Request Failure:", format_rest_error)
diff --git a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
index 73e2f0c4d3..f5936285be 100644
--- a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
@@ -69,7 +69,6 @@ class Chef
relevant_lines = ["# In #{file}\n\n"]
-
current_line = line - 1
current_line = 0 if current_line < 0
nesting = 0
@@ -99,8 +98,8 @@ class Chef
end
def filtered_bt
- filters = Array(Chef::Config.cookbook_path).map {|p| /^#{Regexp.escape(p)}/ }
- exception.backtrace.select {|line| filters.any? {|filter| line =~ filter }}
+ filters = Array(Chef::Config.cookbook_path).map { |p| /^#{Regexp.escape(p)}/ }
+ exception.backtrace.select { |line| filters.any? { |filter| line =~ filter } }
end
private
@@ -112,15 +111,13 @@ class Chef
end
def parse_source
- resource.source_line[/^(([\w]:)?[^:]+):([\d]+)/,1]
+ resource.source_line[/^(([\w]:)?[^:]+):([\d]+)/, 1]
end
def parse_line(source)
- resource.source_line[/^#{Regexp.escape(source)}:([\d]+)/,1].to_i
+ resource.source_line[/^#{Regexp.escape(source)}:([\d]+)/, 1].to_i
end
-
-
end
end
end
diff --git a/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb b/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb
index 08fcdea609..e94b347378 100644
--- a/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb
@@ -36,7 +36,7 @@ class Chef
def add_explanation(error_description)
case exception
when Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError
- error_description.section("Networking Error:",<<-E)
+ error_description.section("Networking Error:", <<-E)
#{exception.message}
Your chef_server_url may be misconfigured, or the network could be down.
@@ -48,13 +48,13 @@ E
when EOFError
describe_eof_error(error_description)
else
- error_description.section("Unexpected Error:","#{exception.class.name}: #{exception.message}")
+ error_description.section("Unexpected Error:", "#{exception.class.name}: #{exception.message}")
end
end
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")
+ original_run_list = node.run_list.map { |item| "* #{item}" }.join("\n")
error_description.section("Original Run List", original_run_list)
end
@@ -76,12 +76,12 @@ E
response = exception.response
case response
when Net::HTTPUnauthorized
- error_description.section("Authentication Error:",<<-E)
+ error_description.section("Authentication Error:", <<-E)
Failed to authenticate to the chef server (http 401).
E
error_description.section("Server Response:", format_rest_error)
- error_description.section("Relevant Config Settings:",<<-E)
+ error_description.section("Relevant Config Settings:", <<-E)
chef_server_url "#{server_url}"
node_name "#{username}"
client_key "#{api_key}"
@@ -92,23 +92,23 @@ E
# 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)
+ 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)
+ 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)
+ 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 Server is temporarily unavailable")
+ error_description.section("Server Unavailable", "The Chef Server is temporarily unavailable")
error_description.section("Server Response:", format_rest_error)
else
error_description.section("Unexpected API Request Failure:", format_rest_error)