-
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
[common] handle all_logs when snap package is installed #3684
[common] handle all_logs when snap package is installed #3684
Conversation
Putting this as an idea, but, maybe we can do something in check_enabled instead to simplify this |
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. |
I like the idea overall, but I think the logic could be improved a bit, left some comments on it |
8546e2d
to
08050c2
Compare
Put in 2 ideas
if we decide the second option is better, then we could split this PR into 2, and have one for standardising thoughts? |
08050c2
to
908c6e4
Compare
alternatively, we can the change below (after the recent PR) but that defeats the purpose of the original commit of having commands outputting to file with diff --git a/sos/report/plugins/__init__.py b/sos/report/plugins/__init__.py
index 74ade1fb..2009a2cf 100644
--- a/sos/report/plugins/__init__.py
+++ b/sos/report/plugins/__init__.py
@@ -1990,7 +1990,8 @@ class Plugin():
kwargs['priority'] = 10
if 'changes' not in kwargs:
kwargs['changes'] = False
- if self.get_option('all_logs') or kwargs['sizelimit'] == 0:
+ if not self.is_snap and (self.get_option('all_logs') or
+ kwargs['sizelimit'] == 0):
kwargs['to_file'] = True
soscmd = SoSCommand(**kwargs)
self._log_debug("packed command: " + soscmd.__str__()) |
I'm not a big fan of inserting a I'm onboard with your first idea, allowing the plugin to disable/override/etc any enabling of |
c8737aa
to
1ff241e
Compare
Add a new flag to add_cmd_output to suggest a snap_cmd, so that sos does not direct the command directly to a file. Resolves: sosreport#3683 Signed-off-by: Arif Ali <arif.ali@canonical.com>
1ff241e
to
f0413be
Compare
if self.get_option('all_logs') or kwargs['sizelimit'] == 0: | ||
if (not getattr(SoSCommand(**kwargs), "snap_cmd", False) and | ||
(self.get_option('all_logs') or kwargs['sizelimit'] == 0)): |
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.
So the impact of the snap_cmd
option will be "dont store directly to file even when all_logs is set"? That is independent on snap packaging, so I suggest changing option name.
E.g. why not to use to_file
directly? We would just have to change condition at https://github.com/sosreport/sos/blob/main/sos/report/plugins/__init__.py#L2010 .
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 could use to_file directly to be set false for snap specific, but we can't afford to have to_file
to be true if the command is being run is a snap command. We'd need a different test here for this then, if we drop the snap_cmd
paramater. Ultimately to_file
is False by default, so somehow we need to detect is the command being run is a snap or not, maybe check where the command is coming from, i.e. /snap/bin
.
We don't want to do a blanket all commands to be not run to file, as journalctl wouldn't be snapped, and hence can write to file.
So, we could have for example
sunbeam cluster list <--snap
journalctl <-- not snap
now, the latter command, we can run with to_file=True
, but the former we can't
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 see. One part of my concern was also to the parameter name itself, trying to keep Plugin
independent on packaging implementation (same concernt I would raise against, say, is_rpm
parameter name). But I cant figure out some generic enough name (force_to_file
? too long..) that I would suggest to use.
So ACK from me.
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.
As mentioned on IRC, I have some concerns around maintainability and the potential for snap_cmd=True
to be marked for commands that aren't coming from a snap in a given installation - but for the state of sos today at least, that doesn't appear to be an actual potential issue.
Ack for the current PR, but we'll want to keep this in mind going forward so that we don't drown ourselves in a sort of "snap_cmd dance" for more generalized plugins.
Add a new flag to add_cmd_output to suggest a snap_cmd, so that sos
does not direct the command directly to a file.
Resolves: #3683
Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines