Skip to content
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

Merged

Conversation

mhashizume
Copy link
Contributor

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.

@mhashizume mhashizume added the bug Something isn't working label Jun 17, 2024
@mhashizume mhashizume requested a review from a team as a code owner June 17, 2024 22:23
runinterval = 1800
log_err("Failed to determine runinterval, defaulting to #{runinterval} seconds")
else
runinterval = runinterval.to_i
Copy link
Contributor

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.

@mhashizume mhashizume force-pushed the PUP-1881/main/windows-runinterval branch 2 times, most recently from 99bf548 to 525ebda Compare June 18, 2024 17:40
Copy link
Contributor

@joshcooper joshcooper left a 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.
@mhashizume mhashizume force-pushed the PUP-1881/main/windows-runinterval branch from 525ebda to 688bf6f Compare June 18, 2024 18:25
@joshcooper joshcooper changed the title Correct Windows runinterval behavior (PUP-1881) Correct Windows runinterval behavior Jun 18, 2024
@joshcooper joshcooper merged commit d9265ab into puppetlabs:main Jun 18, 2024
9 checks passed
@mhashizume mhashizume deleted the PUP-1881/main/windows-runinterval branch June 18, 2024 19:58
@tvpartytonight
Copy link
Contributor

@mhashizume does this need to get backported to 7.x?

@mhashizume mhashizume added the backport 7.x Generate a backport PR to 7.x label Jun 20, 2024
Copy link

Backport failed for 7.x, because it was unable to cherry-pick the commit(s).

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 7.x Generate a backport PR to 7.x bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants