diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-03-12 15:19:47 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2019-03-12 15:19:47 -0700 |
commit | 909fa8a404b37f7faad24aacd87c95dc80462256 (patch) | |
tree | 00d43e77693d69b6d47d830d84fc95a447d9df24 | |
parent | 549ea9415b4e6e31a90a777f676d6478c6faa74a (diff) | |
download | chef-audit.tar.gz |
resimplify + fix specsaudit
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | lib/chef/client.rb | 28 | ||||
-rw-r--r-- | spec/unit/client_spec.rb | 13 |
2 files changed, 10 insertions, 31 deletions
diff --git a/lib/chef/client.rb b/lib/chef/client.rb index edf071b4b4..c547a8c39a 100644 --- a/lib/chef/client.rb +++ b/lib/chef/client.rb @@ -222,8 +222,6 @@ class Chef def run start_profiling - run_error = nil - runlock = RunLock.new(Chef::Config.lockfile) # TODO feels like acquire should have its own block arg for this runlock.acquire @@ -265,8 +263,7 @@ class Chef load_required_recipe(@rest, run_context) unless Chef::Config[:solo_legacy_mode] - converge_error = converge_and_save(run_context) - raise converge_error if converge_error + converge_and_save(run_context) run_status.stop_clock logger.info("Chef Run complete in #{run_status.elapsed_time} seconds") @@ -664,33 +661,18 @@ class Chef converge_exception end - # # Converge the node via and then save it if successful. # - # @param run_context The run context. + # If converge() raises it is important that save_updated_node is bypassed. # + # @param run_context [Chef::RunContext] The run context. # @raise Any converge or node save exception # - # @see #converge - # @see #save_updated_mode - # # @api private # - # We don't want to change the old API on the `converge` method to have it perform - # saving. So we wrap it in this method. - # TODO given this seems to be pretty internal stuff, how badly do we need to - # split this stuff up? - # def converge_and_save(run_context) - converge_exception = converge(run_context) - unless converge_exception - begin - save_updated_node - rescue Exception => e - converge_exception = e - end - end - converge_exception + converge(run_context) + save_updated_node end # diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index 41091f5716..6fb5a7df64 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -252,7 +252,7 @@ shared_context "run failed" do end before do - expect(Chef::Application).to receive(:debug_stacktrace).with an_instance_of(Chef::Exceptions::RunFailedWrappingError) + expect(Chef::Application).to receive(:debug_stacktrace).with(converge_error) end end @@ -278,13 +278,7 @@ shared_examples "a failed run" do include_context "run failed" it "skips node save and raises the error in a wrapping error" do - expect { client.run }.to raise_error(Chef::Exceptions::RunFailedWrappingError) do |error| - expect(error.wrapped_errors.size).to eq(run_errors.size) - run_errors.each do |run_error| - expect(error.wrapped_errors).to include(run_error) - expect(error.backtrace).to include(*run_error.backtrace) - end - end + expect { client.run }.to raise_error(converge_error) end end @@ -505,6 +499,9 @@ describe Chef::Client do describe "when converge errors" do include_context "a client run" include_context "converge failed" + include_examples "a failed run" do + let(:run_errors) { [converge_error] } + end end end |