Skip to content

Commit

Permalink
Correct Windows runinterval behavior
Browse files Browse the repository at this point in the history
Previously when Puppet parsed a runinterval of 0 on Windows, it would
set the runinterval to 1800 seconds, Puppet's default runinterval value.
This was incorrect behavior, as on other platforms and in the
documentation, a runinterval of 0 indicates that Puppet should run
continuously.

This commit updates the Windows daemon to set the runinterval to 1800
seconds when it receives an empty string and cast to integer in all
other cases.
  • Loading branch information
mhashizume committed Jun 18, 2024
1 parent 2fafe0b commit 99bf548
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ext/windows/service/daemon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,13 @@ def report_windows_event(type, id, message)
# @return runinterval [Integer] How often to do a Puppet run, in seconds.
def parse_runinterval(puppet_path)
begin
runinterval = %x(#{puppet_path} config --section agent --log_level notice print runinterval).to_i
if runinterval == 0
runinterval = %x(#{puppet_path} config --section agent --log_level notice print runinterval)&.chomp
if runinterval == ''
runinterval = 1800
log_err("Failed to determine runinterval, defaulting to #{runinterval} seconds")
else
# Use Kernel#Integer because to_i will return 0 with non-numeric strings.
runinterval = Integer(runinterval)
end
rescue Exception => e
log_exception(e)
Expand Down

0 comments on commit 99bf548

Please sign in to comment.