diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-05-18 23:45:30 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-05-18 23:45:30 +0000 |
| commit | 6f83d4daab56385df9a1625cf8ffc64b6a8958f7 (patch) | |
| tree | 96f5d3eb98f0e61396e02256b2071170fb65c88e /lib | |
| parent | 7d1f7606c38ad7b32651e8bc98e2258feda99294 (diff) | |
| download | puppet-6f83d4daab56385df9a1625cf8ffc64b6a8958f7.tar.gz puppet-6f83d4daab56385df9a1625cf8ffc64b6a8958f7.tar.xz puppet-6f83d4daab56385df9a1625cf8ffc64b6a8958f7.zip | |
Fixing #501 -- there is now a splay option, disabled by default and when running under --test
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2528 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/configuration.rb | 8 | ||||
| -rw-r--r-- | lib/puppet/network/client/master.rb | 17 |
2 files changed, 24 insertions, 1 deletions
diff --git a/lib/puppet/configuration.rb b/lib/puppet/configuration.rb index 3b90916c6..d1526e2be 100644 --- a/lib/puppet/configuration.rb +++ b/lib/puppet/configuration.rb @@ -400,7 +400,13 @@ module Puppet :dynamicfacts => ["memorysize,memoryfree,swapsize,swapfree", "Facts that are dynamic; these facts will be ignored when deciding whether changed facts should result in a recompile. Multiple facts should be - comma-separated."] + comma-separated."], + :splaylimit => ["$runinterval", + "The maximum time to delay before runs. Defaults to being the same as the + run interval."], + :splay => [false, + "Whether to sleep for a pseudo-random (but consistent) amount of time before + a run."] ) self.setdefaults(:puppetd, diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb index 7eb009b2d..2b9490539 100644 --- a/lib/puppet/network/client/master.rb +++ b/lib/puppet/network/client/master.rb @@ -293,6 +293,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client # The code that actually runs the configuration. def run(tags = nil, ignoreschedules = false) got_lock = false + splay Puppet::Util.sync(:puppetrun).synchronize(Sync::EX) do if !lockfile.lock Puppet.notice "Lock file %s exists; skipping configuration run" % @@ -663,6 +664,22 @@ class Puppet::Network::Client::Master < Puppet::Network::Client @lockfile end + + # Sleep when splay is enabled; else just return. + def splay + return unless Puppet[:splay] + + limit = Integer(Puppet[:splaylimit]) + + # Pick a splay time and then cache it. + unless time = Puppet::Util::Storage.cache(:configuration)[:splay_time] + time = rand(limit) + Puppet::Util::Storage.cache(:configuration)[:splay_time] = time + end + + Puppet.info "Sleeping for %s seconds (splay is enabled)" % time + sleep(time) + end end # $Id$ |
