issue 1491
Took the splay out of the run method in master.rb and do it once in puppetd
before the timer starts. This is actually a bad bug IMHO, because it changes
the period cycles and creates the potential for all the clients to eventually
run at the same time.
Signed-off-by: Andrew Shafer <[EMAIL PROTECTED]>
---
bin/puppetd | 6 ++++++
lib/puppet/network/client/master.rb | 17 -----------------
lib/puppet/splay.rb | 7 +++++++
spec/unit/splay.rb | 15 +++++++++++++++
4 files changed, 28 insertions(+), 17 deletions(-)
create mode 100644 lib/puppet/splay.rb
create mode 100755 spec/unit/splay.rb
diff --git a/bin/puppetd b/bin/puppetd
index 0813745..b440ce4 100755
--- a/bin/puppetd
+++ b/bin/puppetd
@@ -434,6 +434,12 @@ else
Puppet.settraps
+ if Puppet[:splay]
+ require 'puppet/splay'
+ Puppet.info "Sleeping (splay is enabled)"
+ Puppet.info "Slept for %s seconds" % Splay.splay(Puppet[:splaylimit])
+ end
+
Puppet.start
end
diff --git a/lib/puppet/network/client/master.rb
b/lib/puppet/network/client/master.rb
index 6f8e277..64c5270 100644
--- a/lib/puppet/network/client/master.rb
+++ b/lib/puppet/network/client/master.rb
@@ -232,7 +232,6 @@ class Puppet::Network::Client::Master <
Puppet::Network::Client
# which accepts :tags and :ignoreschedules.
def run(options = {})
got_lock = false
- splay
Puppet::Util.sync(:puppetrun).synchronize(Sync::EX) do
if !lockfile.lock
Puppet.notice "Lock file %s exists; skipping catalog run" %
@@ -478,22 +477,6 @@ 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
-
private
# Use our cached config, optionally specifying whether this is
diff --git a/lib/puppet/splay.rb b/lib/puppet/splay.rb
new file mode 100644
index 0000000..7b46e1c
--- /dev/null
+++ b/lib/puppet/splay.rb
@@ -0,0 +1,7 @@
+module Splay
+ def self.splay(limit)
+ time = rand(Integer(limit))
+ sleep(time)
+ time
+ end
+end
diff --git a/spec/unit/splay.rb b/spec/unit/splay.rb
new file mode 100755
index 0000000..c463d2b
--- /dev/null
+++ b/spec/unit/splay.rb
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+
+Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ?
require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+
+require 'puppet/splay'
+
+describe Splay do
+ describe "when splaying :/" do
+ it "should splay, sleep, and return" do
+ Splay.expects(:rand).with(10).returns(1)
+ Splay.expects(:sleep).with(1)
+ Splay.splay(10).should == 1
+ end
+ end
+end
--
1.5.3.7
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---