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

[sosreport] Allow user-controllable plugin timeouts #1499

Closed

Conversation

TurboTurtle
Copy link
Member

Allows users to specify a timeout for each plugin using the '-k
plugin.timeout=value' syntax by adding the 'timeout' option to every
plugin.

Additionally, adds the --plugin-timeout option to set a timeout for
all plugins. If --plugin-timeout and a specific -k timeout option is
provided, the -k timeout option will be applied for those specific
plugins, with --plugin-timeout being applied to all others.

In either case, specifying a timeout of 0 seconds results in no timeout
being applied. In the event that an invalid timeout is set, the timeout
will be set to the default value for the plugin.

Signed-off-by: Jake Hunsaker jhunsake@redhat.com


Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines

  • Is the commit message split over multiple lines and hard-wrapped at 72 characters?
  • Is the subject and message clear and concise?
  • Does the subject start with [plugin_name] if submitting a plugin patch or a [section_name] if part of the core sosreport code?
  • Does the commit contain a Signed-off-by: First Lastname email@example.com?

Allows users to specify a timeout for each plugin using the '-k
plugin.timeout=value' syntax by adding the 'timeout' option to every
plugin.

Additionally, adds the --plugin-timeout option to set a timeout for
_all_ plugins. If --plugin-timeout and a specific -k timeout option is
provided, the -k timeout option will be applied for those specific
plugins, with --plugin-timeout being applied to all others.

In either case, specifying a timeout of 0 seconds results in no timeout
being applied. In the event that an invalid timeout is set, the timeout
will be set to the default value for the plugin.

Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
if _timeout is not None and _timeout > -1:
return _timeout
return self.plugin_timeout

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought the elif are wrong but I am unable to find particular counter-example.

Can't something be simplified if we allow just numerical values for the options? Like ./sosreport --log-size=a1 fails with sosreport: error: argument --log-size: invalid int value: 'a1'?

Copy link
Member Author

Choose a reason for hiding this comment

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

While it'd certainly be helpful to restrict the type of the options, I don't think that'd make this block any simpler. The issue comes in with how both argparse and the futures libraries handle int zero (differently), so we have to do some shuffling here to compensate for that.

I'm certainly open for suggestions on how to condense it, as I'm not particularly fond of it myself right now either - I just couldn't come up with another solution.

Copy link
Contributor

Choose a reason for hiding this comment

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

Havent realized that complexity behind, what can easily justify that code, then.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that kinda sucks but as @TurboTurtle explained it's a consequence of how the Python bits deal with certain special values. All that said, it's really not too bad - we have far more icky blocks in the rest of the codebase, and the logic is quite easy to follow if you understand the intent of the precedence.

@pmoravec
Copy link
Contributor

pmoravec commented Jan 1, 2019

+1, maybe the restriction of argument values to numbers only would be beneficial?

@bmr-cymru bmr-cymru closed this in 031ff48 Mar 12, 2019
@bmr-cymru
Copy link
Member

Thanks for working on this - very nice feature.

@bmr-cymru
Copy link
Member

maybe the restriction of argument values to numbers only would be beneficial?

Let's keep that discussion going in #1526

@bmr-cymru bmr-cymru added this to the 3.7 milestone Mar 26, 2019
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.

None yet

3 participants