summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2016-10-07 17:40:32 +0100
committerGitHub <noreply@github.com>2016-10-07 17:40:32 +0100
commit504a4f19e01a964503c5fabd8bed92ea18338a02 (patch)
tree21d91efc6de0a90c0a9bb0584d7516e523403826
parentb22c9b270fe5ec18d670f14481f1065e098246b4 (diff)
parentf0a28c5a578fd67dd4cbc16c3df1d54fc5a9f9d9 (diff)
downloadchef-504a4f19e01a964503c5fabd8bed92ea18338a02.tar.gz
Merge pull request #5428 from jeremymv2/exit_code_213
Adding support for rfc 62 exit code 213
-rw-r--r--lib/chef/application/exit_code.rb9
-rw-r--r--lib/chef/exceptions.rb1
-rw-r--r--spec/unit/application/exit_code_spec.rb10
3 files changed, 20 insertions, 0 deletions
diff --git a/lib/chef/application/exit_code.rb b/lib/chef/application/exit_code.rb
index 753f1a0d80..6fec2524dd 100644
--- a/lib/chef/application/exit_code.rb
+++ b/lib/chef/application/exit_code.rb
@@ -35,6 +35,7 @@ class Chef
REBOOT_NEEDED: 37,
REBOOT_FAILED: 41,
AUDIT_MODE_FAILURE: 42,
+ CLIENT_UPGRADED: 213,
}
DEPRECATED_RFC_062_EXIT_CODES = {
@@ -127,6 +128,8 @@ class Chef
VALID_RFC_062_EXIT_CODES[:REBOOT_FAILED]
elsif audit_failure?(exception)
VALID_RFC_062_EXIT_CODES[:AUDIT_MODE_FAILURE]
+ elsif client_upgraded?(exception)
+ VALID_RFC_062_EXIT_CODES[:CLIENT_UPGRADED]
else
VALID_RFC_062_EXIT_CODES[:GENERIC_FAILURE]
end
@@ -162,6 +165,12 @@ class Chef
end
end
+ def client_upgraded?(exception)
+ resolve_exception_array(exception).any? do |e|
+ e.is_a? Chef::Exceptions::ClientUpgraded
+ end
+ end
+
def sigint_received?(exception)
resolve_exception_array(exception).any? do |e|
e.is_a? Chef::Exceptions::SigInt
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb
index ea779754e2..7126323ff7 100644
--- a/lib/chef/exceptions.rb
+++ b/lib/chef/exceptions.rb
@@ -79,6 +79,7 @@ class Chef
class Reboot < Exception; end
class RebootPending < Exception; end
class RebootFailed < Mixlib::ShellOut::ShellCommandFailed; end
+ class ClientUpgraded < Exception; end
class PrivateKeyMissing < RuntimeError; end
class CannotWritePrivateKey < RuntimeError; end
class RoleNotFound < RuntimeError; end
diff --git a/spec/unit/application/exit_code_spec.rb b/spec/unit/application/exit_code_spec.rb
index 73a113e554..59ee400c23 100644
--- a/spec/unit/application/exit_code_spec.rb
+++ b/spec/unit/application/exit_code_spec.rb
@@ -64,6 +64,10 @@ describe Chef::Application::ExitCode do
it "validates a REBOOT_FAILED return code of 41" do
expect(valid_rfc_exit_codes.include?(41)).to eq(true)
end
+
+ it "validates a CLIENT_UPGRADED return code of 213" do
+ expect(valid_rfc_exit_codes.include?(213)).to eq(true)
+ end
end
context "when Chef::Config :exit_status is not configured" do
@@ -215,6 +219,12 @@ describe Chef::Application::ExitCode do
expect(exit_codes.normalize_exit_code(runtime_error)).to eq(37)
end
+ it "returns CLIENT_UPGRADED when the client was upgraded during converge" do
+ client_upgraded_error = Chef::Exceptions::ClientUpgraded.new("BOOM")
+ runtime_error = Chef::Exceptions::RunFailedWrappingError.new(client_upgraded_error)
+ expect(exit_codes.normalize_exit_code(runtime_error)).to eq(213)
+ end
+
it "returns SIGINT_RECEIVED when a SIGINT is received." do
sigint_error = Chef::Exceptions::SigInt.new("BOOM")
runtime_error = Chef::Exceptions::RunFailedWrappingError.new(sigint_error)