Skip to content

(MODULES-7018) Fix Zero Timeout Behavior #225

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

Conversation

RandomNoun7
Copy link
Contributor

Some other Puppet Exec providers will treat a timeout value of 0 as
an infinite timeout. We have chosen not to support an infinite timeout
in this provider, so this change will ensure that a sensible value is
used if the user passes in 0 as the timeout. It also fixes the README
documentation to make it clearer that 0 is not supported, and that
attempting to use it will result in the default timeout of 300 seconds
being used instead.

Some other Puppet Exec providers will treat a `timeout` value of `0` as
an infinite timeout. We have chosen not to support an infinite timeout
in this provider, so this change will ensure that a sensible value is
used if the user passes in `0` as the timeout. It also fixes the README
documentation to make it clearer that `0` is not supported, and that
attempting to use it will result in the default timeout of 300 seconds
being used instead.
@RandomNoun7 RandomNoun7 force-pushed the tickets/master/MODULES-7018-Fix-timeout-zero-behavior branch from 6354421 to ffc970d Compare May 1, 2018 20:45
@RandomNoun7 RandomNoun7 changed the title (MODULES-7018) Fix Zero Tmeout Behavior (MODULES-7018) Fix Zero Timeout Behavior May 2, 2018
@@ -177,7 +177,7 @@ Lists the expected return code(s). If the executed command returns something els

##### `timeout`

Sets the maximum time in seconds that the command should take. Valid options: Number or string representation of a number. Default: 300.
Sets the maximum time in seconds that the command should take. Valid options: Number or string representation of a number. Default: 300. A value of `0` for this property will result in using the default timeout of 300. Inifinite timeout is not supported in this module, but large timeouts are allowed if needed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a maximum allowed timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module code does not enforce one.

@michaeltlombardi michaeltlombardi merged commit a97fae9 into puppetlabs:master May 2, 2018
# as an infinite timeout. We don't support infinite, so for the case
# of a user specifying zero, we sub in the default value of 300
# seconds.
if (timeout_ms == 0) then timeout_ms = 300 * 1000 end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems really far down the callstack given we already perform a calculation for seconds to milliseconds in the provider code at

timeout_ms = resource[:timeout].nil? ? nil : resource[:timeout] * 1000

That would give us the opportunity to emit a warning to the user via Puppet.warning as well.

It actually seems best served to correct this value in the munge for the type, but since the type is defined elsewhere, we're not afforded that opportunity. Seems like provider is the next best spot.

Had you considered that approach instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered higher in the stack, but decided to put it as close to the eventual preparation of the PowerShell code as possible. It’s a habit from my database days I guess where the general rule is that a constraint on the way data should be handled should happen as close to the storage and retrieval of the data as possible.

@RandomNoun7 RandomNoun7 deleted the tickets/master/MODULES-7018-Fix-timeout-zero-behavior branch May 3, 2018 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants