diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2014-10-13 14:52:01 -0700 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2014-10-13 14:52:01 -0700 |
commit | 24522cdb406e1de753e336b2036c02df9f611e85 (patch) | |
tree | beb205ebb20f70a6ca1558c80b5560fbcaca62e9 | |
parent | e25fa19082888d0ab26fd1534c3d0ce0ca27bb9f (diff) | |
parent | 3aebce01e5585d527654d2ecd67ddcb3f48229b1 (diff) | |
download | chef-24522cdb406e1de753e336b2036c02df9f611e85.tar.gz |
Merge pull request #2218 from opscode/jdmundrawala/11-stable-issue-2169
Cherry-pick #2190 from opscode/jdmundrawala/issue-2169
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | lib/chef/util/dsc/local_configuration_manager.rb | 6 | ||||
-rw-r--r-- | spec/unit/util/dsc/local_configuration_manager_spec.rb | 8 |
3 files changed, 8 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 4aa7ea0a90..77df6610b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Removed dependencies on the 'json' gem, replaced with ffi-yajl. Use Chef::JSONCompat library for parsing and printing. * [Issue 2027](https://github.com/opscode/chef/issues/2027) Allow recipe using `dsc_script` opportunity to install Powershell 4 or higher +* [Issue 2169](https://github.com/opscode/chef/issues/2169) Attempt to converge DSC configurations with resources that do not correctly support what-if ## Last Release: 11.16.4 diff --git a/lib/chef/util/dsc/local_configuration_manager.rb b/lib/chef/util/dsc/local_configuration_manager.rb index 4a56b6a397..7395dd5bbf 100644 --- a/lib/chef/util/dsc/local_configuration_manager.rb +++ b/lib/chef/util/dsc/local_configuration_manager.rb @@ -29,7 +29,7 @@ class Chef::Util::DSC def test_configuration(configuration_document) status = run_configuration_cmdlet(configuration_document) - handle_what_if_exception!(status.stderr) unless status.succeeded? + log_what_if_exception(status.stderr) unless status.succeeded? configuration_update_required?(status.return_value) end @@ -78,14 +78,14 @@ $ProgressPreference = 'SilentlyContinue';start-dscconfiguration -path #{@configu EOH end - def handle_what_if_exception!(what_if_exception_output) + def log_what_if_exception(what_if_exception_output) if what_if_exception_output.gsub(/\s+/, ' ') =~ /A parameter cannot be found that matches parameter name 'Whatif'/i # LCM returns an error if any of the resources do not support the opptional What-If Chef::Log::warn("Received error while testing configuration due to resource not supporting 'WhatIf'") elsif output_has_dsc_module_failure?(what_if_exception_output) Chef::Log::warn("Received error while testing configuration due to a module for an imported resource possibly not being fully installed:\n#{what_if_exception_output.gsub(/\s+/, ' ')}") else - raise Chef::Exceptions::PowershellCmdletException, "Powershell Cmdlet failed: #{what_if_exception_output.gsub(/\s+/, ' ')}" + Chef::Log::warn("Received error while testing configuration:\n#{what_if_exception_output.gsub(/\s+/, ' ')}") end end diff --git a/spec/unit/util/dsc/local_configuration_manager_spec.rb b/spec/unit/util/dsc/local_configuration_manager_spec.rb index fb6664bd40..c9a63bf816 100644 --- a/spec/unit/util/dsc/local_configuration_manager_spec.rb +++ b/spec/unit/util/dsc/local_configuration_manager_spec.rb @@ -105,15 +105,15 @@ EOH end end - context 'that fails due to an PowerShell cmdlet error that cannot be handled' do + context 'that fails due to an unknown PowerShell cmdlet error' do let(:lcm_standard_output) { 'some output' } let(:lcm_standard_error) { 'Abort, Retry, Fail?' } let(:lcm_cmdlet_success) { false } - it 'should raise a Chef::Exceptions::PowershellCmdletException' do - expect(Chef::Log).not_to receive(:warn) + it 'should log a warning' do + expect(Chef::Log).to receive(:warn) expect(lcm).to receive(:output_has_dsc_module_failure?).and_call_original - expect {lcm.test_configuration('config')}.to raise_error(Chef::Exceptions::PowershellCmdletException) + expect {lcm.test_configuration('config')}.not_to raise_error end end end |