diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2014-12-15 21:34:41 -0800 |
---|---|---|
committer | Bryan McLellan <btm@loftninjas.org> | 2014-12-17 20:16:12 -0500 |
commit | 60cf0de3e368168ba0a5ed8d9d4d9f261aed6431 (patch) | |
tree | 37ce4b7ad49e4ef3916568b9b4ba8eafef15a486 /lib | |
parent | 1d5b9bf57df6812b6f6a2961d0995aa6c2d8f695 (diff) | |
download | chef-60cf0de3e368168ba0a5ed8d9d4d9f261aed6431.tar.gz |
Fix bug where error parser what-if output causes resource to be considered converged.
We now fall back to assuming the resource is not converged if we cannot parse
information about a dsc resource.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/exceptions.rb | 1 | ||||
-rw-r--r-- | lib/chef/util/dsc/lcm_output_parser.rb | 10 | ||||
-rw-r--r-- | lib/chef/util/dsc/local_configuration_manager.rb | 2 |
3 files changed, 9 insertions, 4 deletions
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb index f5d91c24a6..48ab821cab 100644 --- a/lib/chef/exceptions.rb +++ b/lib/chef/exceptions.rb @@ -124,6 +124,7 @@ class Chef class DuplicateDataBagItem < RuntimeError; end class PowershellCmdletException < RuntimeError; end + class LCMParserException < RuntimeError; end class CannotDetermineHomebrewOwner < Package; end diff --git a/lib/chef/util/dsc/lcm_output_parser.rb b/lib/chef/util/dsc/lcm_output_parser.rb index f8f853a33a..37908d064b 100644 --- a/lib/chef/util/dsc/lcm_output_parser.rb +++ b/lib/chef/util/dsc/lcm_output_parser.rb @@ -18,6 +18,7 @@ require 'chef/log' require 'chef/util/dsc/resource_info' +require 'chef/exceptions' class Chef class Util @@ -53,8 +54,7 @@ class Chef # ] # def self.parse(lcm_output) - return [] unless lcm_output - + lcm_output ||= "" current_resource = Hash.new resources = [] @@ -96,7 +96,11 @@ class Chef resources.push(current_resource) end - build_resource_info(resources) + if resources.length > 0 + build_resource_info(resources) + else + raise Chef::Exceptions::LCMParserException, "Could not parse:\n#{lcm_output}" + end end def self.parse_line(line) diff --git a/lib/chef/util/dsc/local_configuration_manager.rb b/lib/chef/util/dsc/local_configuration_manager.rb index f498a2bfea..55ffc7943c 100644 --- a/lib/chef/util/dsc/local_configuration_manager.rb +++ b/lib/chef/util/dsc/local_configuration_manager.rb @@ -103,7 +103,7 @@ EOH Chef::Log.debug("DSC: DSC returned the following '-whatif' output from test operation:\n#{what_if_output}") begin Parser::parse(what_if_output) - rescue Chef::Util::DSC::LocalConfigurationManager::Parser => e + rescue Chef::Exceptions::LCMParserException => e Chef::Log::warn("Could not parse LCM output: #{e}") [Chef::Util::DSC::ResourceInfo.new('Unknown DSC Resources', true, ['Unknown changes because LCM output was not parsable.'])] end |