diff options
| author | Markus Roberts <Markus@reality.com> | 2010-01-21 16:03:26 -0800 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2010-01-24 07:29:49 +1100 |
| commit | a91c476387887baa5920f5539a7c4acfaf8cecd9 (patch) | |
| tree | f60946f17d929bf7037ec4dd5102e3e04878913a /lib/puppet | |
| parent | 1a263e27dede28d3844a4f010ab6ce42ef2977b0 (diff) | |
| download | puppet-a91c476387887baa5920f5539a7c4acfaf8cecd9.tar.gz puppet-a91c476387887baa5920f5539a7c4acfaf8cecd9.tar.xz puppet-a91c476387887baa5920f5539a7c4acfaf8cecd9.zip | |
Fix for #3088 (catching Exception also traps SystemExit)
Changing rescues from the default to Exception (to catch errors that don't
descend from StandardError) had the unintended consequence of catching (and
suppressing) SystemExit.
This patch restores the behavior of by reraising the exception.
Of the other exceptions that fall through the same crack (NoMemoryError,
SignalException, LoadError, Interrupt, NotImplementedError, and ScriptError)
this patch also reraises NoMemoryError, SignalException, and Interrupt in the
same way and leaves the rest captured.
Diffstat (limited to 'lib/puppet')
| -rw-r--r-- | lib/puppet/agent.rb | 4 | ||||
| -rw-r--r-- | lib/puppet/configurer.rb | 4 | ||||
| -rw-r--r-- | lib/puppet/configurer/fact_handler.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/configurer/plugin_handler.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/indirector/facts/facter.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/indirector/ldap.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/network/http/handler.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/network/xmlrpc/client.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/provider/augeas/augeas.rb | 4 | ||||
| -rw-r--r-- | lib/puppet/ssl/host.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/util/autoload.rb | 4 | ||||
| -rw-r--r-- | lib/puppet/util/feature.rb | 2 |
12 files changed, 32 insertions, 0 deletions
diff --git a/lib/puppet/agent.rb b/lib/puppet/agent.rb index 789660585..5dbb15227 100644 --- a/lib/puppet/agent.rb +++ b/lib/puppet/agent.rb @@ -51,6 +51,8 @@ class Puppet::Agent with_client do |client| begin sync.synchronize { lock { client.run(*args) } } + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] Puppet.err "Could not run %s: %s" % [client_class, detail] @@ -122,6 +124,8 @@ class Puppet::Agent def with_client begin @client = client_class.new + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] Puppet.err "Could not create instance of %s: %s" % [client_class, detail] diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb index ec61272ef..56217d658 100644 --- a/lib/puppet/configurer.rb +++ b/lib/puppet/configurer.rb @@ -105,6 +105,8 @@ class Puppet::Configurer duration = thinmark do result = catalog_class.find(name, fact_options.merge(:ignore_cache => true)) end + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] Puppet.err "Could not retrieve catalog from remote server: %s" % detail @@ -148,6 +150,8 @@ class Puppet::Configurer def run(options = {}) begin prepare() + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] Puppet.err "Failed to prepare catalog: %s" % detail diff --git a/lib/puppet/configurer/fact_handler.rb b/lib/puppet/configurer/fact_handler.rb index 40e79b6c6..a05d89060 100644 --- a/lib/puppet/configurer/fact_handler.rb +++ b/lib/puppet/configurer/fact_handler.rb @@ -17,6 +17,8 @@ module Puppet::Configurer::FactHandler begin reload_facter() Puppet::Node::Facts.find(Puppet[:certname]) + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] raise Puppet::Error, "Could not retrieve local facts: %s" % detail diff --git a/lib/puppet/configurer/plugin_handler.rb b/lib/puppet/configurer/plugin_handler.rb index e934f5877..856942176 100644 --- a/lib/puppet/configurer/plugin_handler.rb +++ b/lib/puppet/configurer/plugin_handler.rb @@ -19,6 +19,8 @@ module Puppet::Configurer::PluginHandler begin Puppet.info "Loading downloaded plugin %s" % file load file + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail Puppet.err "Could not load downloaded file %s: %s" % [file, detail] end diff --git a/lib/puppet/indirector/facts/facter.rb b/lib/puppet/indirector/facts/facter.rb index 6c6cbc6be..2caeeede2 100644 --- a/lib/puppet/indirector/facts/facter.rb +++ b/lib/puppet/indirector/facts/facter.rb @@ -29,6 +29,8 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code Timeout::timeout(self.timeout) do load file end + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail Puppet.warning "Could not load fact file %s: %s" % [fqfile, detail] end diff --git a/lib/puppet/indirector/ldap.rb b/lib/puppet/indirector/ldap.rb index 51bab0e6e..31ee0e020 100644 --- a/lib/puppet/indirector/ldap.rb +++ b/lib/puppet/indirector/ldap.rb @@ -40,6 +40,8 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus found = true yield entry end + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail if count == 0 # Try reconnecting to ldap if we get an exception and we haven't yet retried. diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb index 65bb0f82c..4d9634f79 100644 --- a/lib/puppet/network/http/handler.rb +++ b/lib/puppet/network/http/handler.rb @@ -66,6 +66,8 @@ module Puppet::Network::HTTP::Handler check_authorization(indirection_request) send("do_%s" % indirection_request.method, indirection_request, request, response) + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => e return do_exception(response, e) end diff --git a/lib/puppet/network/xmlrpc/client.rb b/lib/puppet/network/xmlrpc/client.rb index ee2c008eb..805d99324 100644 --- a/lib/puppet/network/xmlrpc/client.rb +++ b/lib/puppet/network/xmlrpc/client.rb @@ -144,6 +144,8 @@ module Puppet::Network Puppet.debug "Calling %s.%s" % [namespace, method] begin call("%s.%s" % [namespace, method.to_s],*args) + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail retry if self.class.error_handler(detail).execute(self, detail, namespace, method) == :retry end diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb index a645fbe8a..748c84e7d 100644 --- a/lib/puppet/provider/augeas/augeas.rb +++ b/lib/puppet/provider/augeas/augeas.rb @@ -254,6 +254,8 @@ Puppet::Type.type(:augeas).provide(:augeas) do when "get"; return_value = process_get(cmd_array) when "match"; return_value = process_match(cmd_array) end + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => e fail("Error sending command '#{command}' with params #{cmd_array[1..-1].inspect}/#{e.message}") end @@ -335,6 +337,8 @@ Puppet::Type.type(:augeas).provide(:augeas) do aug.insert(path, label, before) else fail("Command '#{command}' is not supported") end + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => e fail("Error sending command '#{command}' with params #{cmd_array.inspect}/#{e.message}") end diff --git a/lib/puppet/ssl/host.rb b/lib/puppet/ssl/host.rb index 75e51e5c8..d6bbc4e5d 100644 --- a/lib/puppet/ssl/host.rb +++ b/lib/puppet/ssl/host.rb @@ -220,6 +220,8 @@ class Puppet::SSL::Host return if certificate generate return if certificate + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail Puppet.err "Could not request certificate: %s" % detail.to_s if time < 1 diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb index ec2f48c7b..142ff293f 100644 --- a/lib/puppet/util/autoload.rb +++ b/lib/puppet/util/autoload.rb @@ -86,6 +86,8 @@ class Puppet::Util::Autoload name = symbolize(name) loaded name, file return true + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail # I have no idea what's going on here, but different versions # of ruby are raising different errors on missing files. @@ -123,6 +125,8 @@ class Puppet::Util::Autoload begin Kernel.require file loaded(name, file) + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail if Puppet[:trace] puts detail.backtrace diff --git a/lib/puppet/util/feature.rb b/lib/puppet/util/feature.rb index add1b2691..8f77a2724 100644 --- a/lib/puppet/util/feature.rb +++ b/lib/puppet/util/feature.rb @@ -83,6 +83,8 @@ class Puppet::Util::Feature begin require lib + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception Puppet.debug "Failed to load library '%s' for feature '%s'" % [lib, name] return false |
