diff options
author | Jesse Wolfe <jes5199@gmail.com> | 2010-04-26 17:01:01 -0700 |
---|---|---|
committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
commit | ddd40bbc3a90133f223e91d6d4be21aada064a26 (patch) | |
tree | f2fe0e0b8d9d0073ca43df6e0f7367900bafcd25 /lib | |
parent | d61a69a0e5a87a95846a4d39115eac80e4984cac (diff) | |
download | puppet-ddd40bbc3a90133f223e91d6d4be21aada064a26.tar.gz puppet-ddd40bbc3a90133f223e91d6d4be21aada064a26.tar.xz puppet-ddd40bbc3a90133f223e91d6d4be21aada064a26.zip |
Fix for #3690 failing to calculate error codes
This failure was getting caused by what I believe to be a bug in
Puppet::Configurer where it always generated a new
Puppet::Transaction::Report, even if one existed in an outer scope.
In puppetd --test, a different Report was getting queried to generate
the exit status than the one that was passed to the transaction -- this
Report had no Metrics and would fail when queried.
This obscured a second bug that Metrics could return nil for values if
the Transaction had applied an empty Catalog, but Transaction::Report
assumes that values will always be integers.
It could be argued that an empty Report should be populated with empty
Metrics before a Transaction is run, which would have prevented
Report#exit_status from raising an exception ... which would have made
these bugs much harder to track down. So, I've decided to leave that
unchanged.
Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/configurer.rb | 3 | ||||
-rw-r--r-- | lib/puppet/resource/catalog.rb | 1 | ||||
-rw-r--r-- | lib/puppet/transaction.rb | 2 | ||||
-rw-r--r-- | lib/puppet/util/metric.rb | 2 |
4 files changed, 5 insertions, 3 deletions
diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb index 0ff87e640..d45c4a79c 100644 --- a/lib/puppet/configurer.rb +++ b/lib/puppet/configurer.rb @@ -140,7 +140,8 @@ class Puppet::Configurer Puppet.err "Failed to prepare catalog: %s" % detail end - report = initialize_report() + options[:report] ||= initialize_report() + report = options[:report] Puppet::Util::Log.newdestination(report) if catalog = options[:catalog] diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb index 6aeda0957..97c036b03 100644 --- a/lib/puppet/resource/catalog.rb +++ b/lib/puppet/resource/catalog.rb @@ -133,6 +133,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph Puppet::Util::Storage.load if host_config? transaction = Puppet::Transaction.new(self) + transaction.report = options[:report] if options[:report] transaction.tags = options[:tags] if options[:tags] transaction.ignoreschedules = true if options[:ignoreschedules] diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index f8ed503d8..e57fe5648 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -16,7 +16,7 @@ class Puppet::Transaction attr_accessor :sorted_resources, :configurator # The report, once generated. - attr_reader :report + attr_accessor :report # Routes and stores any events and subscriptions. attr_reader :event_manager diff --git a/lib/puppet/util/metric.rb b/lib/puppet/util/metric.rb index b713246d5..8717fe0b9 100644 --- a/lib/puppet/util/metric.rb +++ b/lib/puppet/util/metric.rb @@ -14,7 +14,7 @@ class Puppet::Util::Metric if value = @values.find { |v| v[0] == name } return value[2] else - return nil + return 0 end end |