-
Notifications
You must be signed in to change notification settings - Fork 542
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
[plugins] maxage and all_logs on all plugins #3681
base: main
Are you sure you want to change the base?
Conversation
Congratulations! One of the builds has completed. 🍾 You can install the built RPMs by following these steps:
Please note that the RPMs should be used only in a testing environment. |
sos/report/plugins/__init__.py
Outdated
if self.get_option('since'): | ||
since = self.get_option('since') | ||
|
||
# User's plugin option argument takes precedence over plugin passed arg | ||
maxage = self.get_option('maxage') or maxage | ||
|
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.
Shall not we unify the code here? Both manipulations perform the same at the end, the unification would improve clarity of code.
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.
Sorry I don't understand what you mean by "unify the code".
The kdump
plugin passes the maxage
argument, so this code preserves existing behavior 1. Otherwise this would become a breaking change.
sos/report/__init__.py
Outdated
report_grp.add_argument("--maxage", action="store", | ||
dest="maxage", default=None, type=int, | ||
help="Escapes archived files older (according " | ||
"to `mktime`) than this many hours. This will " | ||
"also affect --all-logs (sets the default for " | ||
"all plugins)") |
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.
Would it be clear for users the option takes values in hours? Esp. if --since
is primarily in days (default expected format is a day, optionally time)? Should not we rename it to, I dont know, --maxhours
? (that sounds badly to me, I like the --maxage
more).
I can easily be wrong here. I really dont know what users' perception would be here.
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.
I like the suggested change to maxhours
, as it has the benefit of including the unit in the name and not force people to look at the description to figure it out.
I'll make the change.
6dd2683
to
afbfafe
Compare
I meant that
applies same logical change to either
or:
The first construction is more concise, the second more explicit. I like the first more but 2nd is fully OK for sure. |
desc='Escapes archived files older (according to `mktime`) ' | ||
'than this many hours' | ||
), | ||
'all_logs': PluginOpt( |
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.
We recently standardized on using hyphens for plugin options, to match the "top level" options which are all hyphens. So this will need to be all-logs
(though the internal dest
naming will of course still be all_logs
).
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.
I'm new to this, but I assumed looking at the kernel plugin with-timer
definition and how it is accessed as with-timer
and not with_timer
that there is no translation on the PluginOpt
.
I looked a bit into the get_option
and PluginOpt
and didn't find any translation mechanism so I went with the solution that required fewer code changes.
But it is true that it would be weird to call it --all-logs
only to have to use all_logs
in the plugins.
I'll see if I can use all-logs
everywhere.
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.
Done
In a quick test, this change works for sos/sos/report/plugins/__init__.py Lines 1544 to 1564 in 7b0d5a4
|
812a081
to
9d19e66
Compare
Current `PluginOpt` code doesn't have the possibility of having a different name for the parameter and the reference used in the code. This would be the equivalent in arg parser to not having a `dest` argument available to us. This patch proposes a change to allow this using a new `PluginOpt` field called `param_name`. This new field will only be used when interfacing with users. In other words, when showing the options to users (eg: `list_plugins`), when parsing the command line arguments (eg: `_set_tunables`), and when reading the config file (this doesn't require code changes because it leverages the normal `_set_tunables` method). Signed-off-by: Gorka Eguileor <[email protected]>
9d19e66
to
ab16bbf
Compare
This patch makes 2 options settable globally and per-plugin: `maxhours` and `all-logs`. The `maxhours` option maps to what the code used to call `maxage`, which has also been renamed to `maxhours` to be consistent. Examples: ``` sos report --all-logs --maxhours=1 sos report -k container_log.all-logs=on,container_log.maxhours=1 sos report --all-logs --maxhours=1 \ -k container_log.all-logs=off,container_log.maxhours=2 ``` This adds flexibility to what users want to retrieve. Signed-off-by: Gorka Eguileor <[email protected]>
ab16bbf
to
8bc2ccb
Compare
Done, I implemented it in what I consider the safest way, and it also adds a missing feature: different variable and user facing parameter name for plugin options. Alternatively the |
Sorry for the silence here, cycling around on it now. The Internally, developers just need to know that hyphens become underscores when accessing the associated variables, which is the case for any project using argparse and directly accessing the parsed options. So, we're good with the original intent of the PR - expanding all-logs and maxage/maxhours to all plugins on a potentially individual basis, but we don't need to mess around with internal references to option names. |
This patch makes 2 options settable globally and per-plugin:
maxage
andall_logs
.Examples:
This adds flexibility to what users want to retrieve.
Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines