diff options
author | Josh Cooper <josh@puppetlabs.com> | 2011-06-10 14:09:32 -0700 |
---|---|---|
committer | Josh Cooper <josh@puppetlabs.com> | 2011-06-10 14:09:32 -0700 |
commit | 98ba4071f424932173b450d1a94a9ae39f33a6c7 (patch) | |
tree | 2fad134e944ba296304912caf6c38a64792fb3bd /lib/puppet/resource/catalog.rb | |
parent | 6996e0bbfb3559773e5fa0d133a7632dcb06b2d5 (diff) | |
download | puppet-98ba4071f424932173b450d1a94a9ae39f33a6c7.tar.gz puppet-98ba4071f424932173b450d1a94a9ae39f33a6c7.tar.xz puppet-98ba4071f424932173b450d1a94a9ae39f33a6c7.zip |
(#7127) Stop puppet if a prerun command fails
Before this change there were several problems with pre and post run
commands, logging, and sending of reports.
1. If a prerun command failed, puppet would attempt to apply the
catalog. Now puppet will not apply the catalog, but it will run the
postrun command and send the report (as it did before).
2. If a postrun command failed, puppet would not send the report. Sending the
report is now in an outer ensure block from the postrun command, so
postrun failures won't prevent the report from being sent.
3. Errors, e.g. Puppet.err, occuring during the prepare step, which
which includes plugin/fact download and prerun commands were not
appended to the report. Now the report log destination is registered as
early as possible, and unregistered as late as possible to ensure
Configurer errors that occur in the run method are included in the report.
4. The transaction was closing the Configurer's report destination out
from underneath it. As a result, postrun errors were not included in the
report.
Paired-with: Nick Lewis <nick@puppetlabs.com>
Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
Diffstat (limited to 'lib/puppet/resource/catalog.rb')
-rw-r--r-- | lib/puppet/resource/catalog.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb index 8d4918bbf..0a63ff172 100644 --- a/lib/puppet/resource/catalog.rb +++ b/lib/puppet/resource/catalog.rb @@ -132,7 +132,9 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph expire Puppet::Util::Storage.load if host_config? + transaction = Puppet::Transaction.new(self, options[:report]) + register_report = options[:report].nil? transaction.tags = options[:tags] if options[:tags] transaction.ignoreschedules = true if options[:ignoreschedules] @@ -140,7 +142,12 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph transaction.add_times :config_retrieval => self.retrieval_duration || 0 begin - transaction.evaluate + Puppet::Util::Log.newdestination(transaction.report) if register_report + begin + transaction.evaluate + ensure + Puppet::Util::Log.close(transaction.report) if register_report + end rescue Puppet::Error => detail puts detail.backtrace if Puppet[:trace] Puppet.err "Could not apply complete catalog: #{detail}" |