Skip to content

Commit

Permalink
Update splaylimit during daemon run
Browse files Browse the repository at this point in the history
Prior to this commit, updates to splay settings in the Puppet
configuration file (puppet.conf) would not get picked up in a daemonized
Puppet run.

This commit updates the daemon class to call a new public method in the
splay job class to update the splaylimit.
  • Loading branch information
mhashizume committed May 14, 2024
1 parent ca922ca commit aae86b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/puppet/daemon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def run_event_loop
reparse_run = Puppet::Scheduler.create_job(Puppet[:filetimeout]) do
Puppet.settings.reparse_config_files
agent_run.run_interval = Puppet[:runinterval]
agent_run.splay_limit = Puppet[:splaylimit] if Puppet[:splay]
if Puppet[:filetimeout] == 0
reparse_run.disable
else
Expand Down
8 changes: 8 additions & 0 deletions lib/puppet/scheduler/splay_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ def ready?(time)
end
end

# Recalculates the splay limit.
#
# @param splay_limit [Integer] The maximum time to delay before an agent's first run.
# @return [Integer] A random integer less than or equal to the splay limit.
def splay_limit=(splay_limit)
@splay = calculate_splay(splay_limit)
end

private

def calculate_splay(limit)
Expand Down

0 comments on commit aae86b0

Please sign in to comment.