Skip to content

Commit 761290c

Browse files
committed
(PUP-12061) Log when periodic agent runs
Provide more context when the agent runs so it's clearer whether splay is enabled and what the limits are. We don't want to do this for the reparse and signal jobs, because they run every 15 and 5 seconds, respectively. The info message is of the form: Running agent every 20 seconds with splay 5 of 10 seconds This message is logged whenever the agent is running periodically, not for onetime runs. Whether we're daemonized doesn't affect the behavior. This is because we always call Puppet::Daemon#start when running periodically to run the event loop.
1 parent 9aa2275 commit 761290c

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

lib/puppet/daemon.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,13 @@ def remove_pidfile
157157

158158
# Loop forever running events - or, at least, until we exit.
159159
def run_event_loop
160-
agent_run = Puppet::Scheduler.create_job(Puppet[:runinterval], Puppet[:splay], Puppet[:splaylimit]) do
160+
agent_run = Puppet::Scheduler.create_job(Puppet[:runinterval], Puppet[:splay], Puppet[:splaylimit]) do |job|
161+
if job.splay != 0
162+
Puppet.info "Running agent every #{job.run_interval} seconds with splay #{job.splay} of #{job.splay_limit} seconds"
163+
else
164+
Puppet.info "Running agent every #{job.run_interval} seconds"
165+
end
166+
161167
# Splay for the daemon is handled in the scheduler
162168
agent.run(:splay => false)
163169
end

lib/puppet/scheduler/splay_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module Puppet::Scheduler
44
class SplayJob < Job
5-
attr_reader :splay
5+
attr_reader :splay, :splay_limit
66

77
def initialize(run_interval, splay_limit, &block)
88
@splay, @splay_limit = calculate_splay(splay_limit)

spec/unit/scheduler/splay_job_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,8 @@
4444
job.splay_limit = splay_limit + 1
4545
expect(job.splay).to eq(new_splay)
4646
end
47+
48+
it "returns the splay_limit" do
49+
expect(job.splay_limit).to eq(splay_limit)
50+
end
4751
end

0 commit comments

Comments
 (0)