summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy J. Miller <jm@chef.io>2016-10-06 17:46:26 -0400
committerJeremy J. Miller <jm@chef.io>2016-10-06 18:05:05 -0400
commit1a2f0c6422adc4c304bdd36af9fcdbb43df54e3a (patch)
tree064f5b11070241aeec410bdd4f919bb6afa497cc
parent1a0c4c533be9e8a35a6fa8650e7a478f19d90ae6 (diff)
downloadchef-1a2f0c6422adc4c304bdd36af9fcdbb43df54e3a.tar.gz
Adding support for rfc 62 exit code 213
Signed-off-by: Jeremy J. Miller <jm@chef.io>
-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)