diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-01-26 21:54:18 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-01-26 21:54:18 +0000 |
commit | 6475487218f9dbe210f79e59b9b7c1be46f18280 (patch) | |
tree | 2d0626c0855fc434befe9815fc01d294b7c58016 | |
parent | a081d418937248c33387f94af17849ecb7566e26 (diff) | |
download | puppet-6475487218f9dbe210f79e59b9b7c1be46f18280.tar.gz puppet-6475487218f9dbe210f79e59b9b7c1be46f18280.tar.xz puppet-6475487218f9dbe210f79e59b9b7c1be46f18280.zip |
Fixing #423. Configurations now default to timing out after 30 seconds (tunable with configtimeout). This only happens for remote configurations, not local configs compiled using puppet.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2095 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/puppet/client/master.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/puppet/client/master.rb b/lib/puppet/client/master.rb index 65bdbf19a..261119bfa 100644 --- a/lib/puppet/client/master.rb +++ b/lib/puppet/client/master.rb @@ -1,5 +1,6 @@ # The client for interacting with the puppetmaster config server. require 'sync' +require 'timeout' class Puppet::Client::MasterClient < Puppet::Client unless defined? @@sync @@ -22,6 +23,11 @@ class Puppet::Client::MasterClient < Puppet::Client ) Puppet.setdefaults(:puppetd, + :configtimeout => [30, + "How long the client should wait for the configuration to be retrieved + before considering it a failure. This can help reduce flapping if too + many clients contact the server at one time." + ], :reportserver => ["$server", "The server to which to send transaction reports." ], @@ -298,6 +304,19 @@ class Puppet::Client::MasterClient < Puppet::Client self.class.instance = self @running = false + + @timeout = Puppet[:configtimeout] + case @timeout + when String: + if @timeout =~ /^\d+$/ + @timeout = Integer(@timeout) + else + raise ArgumentError, "Configuration timeout must be an integer" + end + when Integer: # nothing + else + raise ArgumentError, "Configuration timeout must be an integer" + end end # Mark that we should restart. The Puppet module checks whether we're running, @@ -540,7 +559,14 @@ class Puppet::Client::MasterClient < Puppet::Client if @local return get_local_config(facts) else - return get_remote_config(facts) + begin + Timeout::timeout(@timeout) do + return get_remote_config(facts) + end + rescue Timeout::Error + Puppet.err "Configuration retrieval timed out" + return nil + end end end |