Skip to content

Commit 688bf6f

Browse files
committed
(PUP-1881) Correct Windows runinterval behavior
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.
1 parent 2fafe0b commit 688bf6f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: ext/windows/service/daemon.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,13 @@ def report_windows_event(type, id, message)
161161
# @return runinterval [Integer] How often to do a Puppet run, in seconds.
162162
def parse_runinterval(puppet_path)
163163
begin
164-
runinterval = %x(#{puppet_path} config --section agent --log_level notice print runinterval).to_i
165-
if runinterval == 0
164+
runinterval = %x(#{puppet_path} config --section agent --log_level notice print runinterval).chomp
165+
if runinterval == ''
166166
runinterval = 1800
167167
log_err("Failed to determine runinterval, defaulting to #{runinterval} seconds")
168+
else
169+
# Use Kernel#Integer because to_i will return 0 with non-numeric strings.
170+
runinterval = Integer(runinterval)
168171
end
169172
rescue Exception => e
170173
log_exception(e)

0 commit comments

Comments
 (0)