From de3ac97643c4ce0ae5799088c33b9f4ed8172d2e Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Mon, 13 May 2024 09:46:06 -0700 Subject: [PATCH] Update splaylimit during daemon run 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. --- lib/puppet/daemon.rb | 1 + lib/puppet/scheduler/splay_job.rb | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/puppet/daemon.rb b/lib/puppet/daemon.rb index ce7fddbef1a..64802143ecb 100644 --- a/lib/puppet/daemon.rb +++ b/lib/puppet/daemon.rb @@ -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 diff --git a/lib/puppet/scheduler/splay_job.rb b/lib/puppet/scheduler/splay_job.rb index dd91165ddc5..125f728b889 100644 --- a/lib/puppet/scheduler/splay_job.rb +++ b/lib/puppet/scheduler/splay_job.rb @@ -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)