-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(PUP-1881) Correct Windows runinterval behavior #9397
(PUP-1881) Correct Windows runinterval behavior #9397
Conversation
ext/windows/service/daemon.rb
Outdated
runinterval = 1800 | ||
log_err("Failed to determine runinterval, defaulting to #{runinterval} seconds") | ||
else | ||
runinterval = runinterval.to_i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if we should be more defensive as String#to_i
has some surprising behavior:
irb(main):002:0> "foo".to_i
=> 0
However, this seems more strict/correct:
irb(main):003:0> Integer("foo")
(irb):3:in `Integer': invalid value for Integer(): "foo" (ArgumentError)
from (irb):3:in `<main>'
In theory, this should never happen, because puppet config print runtinterval
doesn't allow invalid durations to be set:
$ bundle exec puppet config set runinterval minutes --section main
Error: Invalid duration format '"minutes"' for parameter: runinterval
Error: Try 'puppet help config set' for usage
And if something else writes to puppet.conf
, the puppet config print
command will error and return empty string to stdout:
$ grep runinterval ~/.puppetlabs/etc/puppet/puppet.conf
runinterval=minutes
$ bundle exec puppet config print runinterval --section main
Error: Invalid duration format '"minutes"' for parameter: runinterval
Error: Try 'puppet help config print' for usage
That said, 0 means run all the time, so I think additional strictness would be good.
99bf548
to
525ebda
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, could you (PUP-1881)
to the git commit summary?
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.
525ebda
to
688bf6f
Compare
@mhashizume does this need to get backported to 7.x? |
Backport failed for Please cherry-pick the changes locally. git fetch origin 7.x
git worktree add -d .worktree/backport-9397-to-7.x origin/7.x
cd .worktree/backport-9397-to-7.x
git checkout -b backport-9397-to-7.x
ancref=$(git merge-base 56d07e923c9c7cfd1a9c4e8553ae30fcbd82ee25 688bf6fb24a53f8a8ffefefcea972cabbe3c790f)
git cherry-pick -x $ancref..688bf6fb24a53f8a8ffefefcea972cabbe3c790f |
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.