File tree 3 files changed +22
-0
lines changed
3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,7 @@ def run_event_loop
161
161
reparse_run = Puppet ::Scheduler . create_job ( Puppet [ :filetimeout ] ) do
162
162
Puppet . settings . reparse_config_files
163
163
agent_run . run_interval = Puppet [ :runinterval ]
164
+ agent_run . splay_limit = Puppet [ :splaylimit ] if Puppet [ :splay ]
164
165
if Puppet [ :filetimeout ] == 0
165
166
reparse_run . disable
166
167
else
Original file line number Diff line number Diff line change @@ -23,6 +23,15 @@ def ready?(time)
23
23
end
24
24
end
25
25
26
+ # Recalculates splay.
27
+ #
28
+ # @param splay_limit [Integer] the maximum time (in seconds) to delay before an agent's first run.
29
+ # @return @splay [Integer] a random integer less than or equal to the splay limit that represents the seconds to
30
+ # delay before next agent run.
31
+ def splay_limit = ( splay_limit )
32
+ @splay = calculate_splay ( splay_limit )
33
+ end
34
+
26
35
private
27
36
28
37
def calculate_splay ( limit )
Original file line number Diff line number Diff line change @@ -86,6 +86,18 @@ def run_loop(jobs)
86
86
daemon . start
87
87
expect ( scheduler . jobs [ 0 ] ) . not_to be_enabled
88
88
end
89
+
90
+ it "recalculates splay if splaylimit changes" do
91
+ # Set file timeout so the daemon reparses
92
+ Puppet [ :filetimeout ] = 1
93
+ Puppet [ :splay ] = true
94
+ allow ( agent ) . to receive ( :run )
95
+ daemon . start
96
+ first_splay = scheduler . jobs [ 1 ] . splay
97
+ allow ( Kernel ) . to receive ( :rand ) . and_return ( 1738 )
98
+ scheduler . jobs [ 0 ] . run ( Time . now )
99
+ expect ( scheduler . jobs [ 1 ] . splay ) . to_not eq ( first_splay )
100
+ end
89
101
end
90
102
91
103
describe "when stopping" do
You can’t perform that action at this time.
0 commit comments