-
Notifications
You must be signed in to change notification settings - Fork 536
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
[Plugin] Standardize directory listings with new method #3664
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. |
3005544
to
0bfb87d
Compare
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.
One nit, there is some inconsistency where we have used -R
previously and hence stuff with the new default or recursive=True
. But we've had newer updates here now where some places where we didn't have -R
before we are now doing recursive and some we aren't.
Happy though, if this was all intended
'/var/lib/awx', | ||
'/var/lib/awx/venv', | ||
'/etc/tower', | ||
]) |
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.
Missing recursive=False
?
(should recursive
have default value True
or False
? I would expect False
since that follows default ls
behaviour and I would expect it as a human-default thinking of "list directory" as well; also since the patch replaces 38 instances of recursive listings and 32 non-recursive ones, there is no need to have such strong preference to the "recursive is far more used default")
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.
(should
recursive
have default valueTrue
orFalse
? I would expectFalse
since that follows defaultls
behaviour and I would expect it as a human-default thinking of "list directory" as well; also since the patch replaces 38 instances of recursive listings and 32 non-recursive ones, there is no need to have such strong preference to the "recursive is far more used default")
When I was first reviewing the PR I was thinking the same, and missed the recursive=True
as the default in the function definition, and had put in ~10 comments before abandoning it. I would agree with @pmoravec here, I think having recursive=False
should be default and we use recursive=True
where needed
0bfb87d
to
845ba3f
Compare
I've swapped the default to |
34da14d
to
c674473
Compare
@arif-ali - updated and I dropped the duplicate collection from |
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.
Hopefully last review, missed a couple where -d
is being used, where it only gives the information of that dir, and doesn't actually list the contents of the directory. It does give the same info at the top, with .
for the directory, instead of the directory name.
sos/report/plugins/filesys.py
Outdated
@@ -108,6 +108,6 @@ class RedHatFilesys(Filesys, RedHatPlugin): | |||
|
|||
def setup(self): | |||
super().setup() | |||
self.add_cmd_output("ls -ltradZ /tmp") | |||
self.add_dir_listing('/tmp') |
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.
what this did before, and what it will give now are 2 distinct things, not sure how we best want to do that
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.
These options are being removed: -d
to list just directory like:
$ ls -ltradZ /tmp
drwxrwxrwt. 25 root root system_u:object_r:tmp_t:s0 640 Jun 22 14:44 /tmp
$
and not the directory content. -t
and -r
to sort reversely by time is irelevant with -d
option.
Calling self.add_dir_listing('/tmp')
would collect same info via:
$ ls -alhZ /tmp
total 44K
drwxrwxrwt. 25 root root system_u:object_r:tmp_t:s0 640 Jun 22 14:44 .
..
line, but will also et details about files under /tmp
. I doubt the content of the directory is important to collect at all, moreover listing the dir can be undesired ("show me your temporary filenames" has some Big Brother vibes).
We requested the current info in #1327 and that is reasonable request. Content of the directory is irelevant. So I would vote for keeping the current ls
command (maybe strip redundant options to ls -ladZ /tmp
?), or for some equivalent (stat
?).
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.
Ack, will move this one back to ls
directly. a
also is meaningless with d
, so this will become ls -ldZ /tmp
.
]) | ||
|
||
self.add_dir_listing( | ||
['/etc/vdsm', '/rhev/data-center'], |
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.
same here, the -ldZ
gives only the details of the directory, and no listing
sos/report/plugins/ssh.py
Outdated
@@ -84,6 +84,6 @@ def user_ssh_files_permissions(self): | |||
for user in users_data: | |||
home_dir = self.path_join(user.pw_dir, '.ssh') | |||
if self.path_isdir(home_dir): |
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.
is it worth removing this check now, as you're checking if the path exists in add_dir_listing()
I think we can accept that difference. For the vdsm ones, RHV is an EOL product that won't be getting updated further, and I wasn't aware of any automation around those collections when I left RH, and I seriously doubt anything has been added for it since. For
Oh, good eye. I'll drop that check in the next update, pending Pavel's thoughts on |
self.add_cmd_output("aap-gateway-manage list_services") | ||
self.add_dir_listing("/etc/ansible-automation-platform/", | ||
recursive=True) |
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 will additionally collect all recursive subdirs of /etc/ansible-automation-platform/
but I doubt that will cause an issue (like, speculating, some fiel in nested dir has some secret name we should not collect - but I doubt that would ever happen). ACK
I see one skipped placefor the new method:
|
self.add_dir_listing(["/etc/rhsm", "/sys/kernel", "/var/lib/sss"], | ||
recursive=True) |
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 stop adding tags here. Also not sure if -n
is important or not (like -l, but list numeric user and group IDs
).
I am checking this internally..
self.add_cmd_output(f"ls -lanH {' '.join(dirs)}", | ||
suggest_filename="ld_so_cache") | ||
self.add_dir_listing( | ||
f"{' '.join(dirs)}", | ||
suggest_filename='ld_so_cache' | ||
) |
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.
self.add_cmd_output("ls -lanR /tftpboot") | ||
self.add_cmd_output('ls -lanR /srv/tftp') | ||
|
||
self.add_dir_listing(['/tftpboot', '/sr/tftp'], recursive=True) |
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.
Also removing -n
option, again no idea if it matters or not. I am ok with removal, if somebody will miss it, we can add it back.
No need for UID indeed.
On Saturday, June 22, 2024, Pavel Moravec ***@***.***> wrote:
@pmoravec commented on this pull request.
________________________________
In sos/report/plugins/tftpserver.py:
> @@ -21,8 +21,6 @@ class TftpServer(Plugin, IndependentPlugin):
packages = ('tftp-server',)
def setup(self):
- self.add_cmd_output("ls -lanR /tftpboot")
- self.add_cmd_output('ls -lanR /srv/tftp')
-
+ self.add_dir_listing(['/tftpboot', '/sr/tftp'], recursive=True)
Also removing -n option, again no idea if it matters or not. I am ok with
removal, if somebody will miss it, we can add it back.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.<
…--
Renaud
Out of working hours
Sent from my phone, sorry for the typos...
|
This commit adds a new `add_dir_listing()` wrapper method to standardize the collection of directory content listings across plugins. By default this will use the `ls` command, and will use `tree` if the `tree` parameter is set to `True`. This wrapper is not intended to replace directory listing that are handlded by other components with their own `ls` functionality (e.g. `npm ls` in the `npm` plugin). Additionally this does not replace the direct calling of `ls` when used with `Plugin.exec_cmd()` to take some action based on the output of the `ls` command. Signed-off-by: Jake Hunsaker <jacob.r.hunsaker@gmail.com>
c674473
to
c4957b9
Compare
@pmoravec any other remaining concerns? |
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.
ACK, sorry for a delay.
This commit adds a new
add_dir_listing()
wrapper method to standardize the collection of directory content listings across plugins. By default this will use thels
command, and will usetree
if thetree
parameter is set toTrue
.This wrapper is not intended to replace directory listing that are handlded by other components with their own
ls
functionality (e.g.npm ls
in thenpm
plugin). Additionally this does not replace the direct calling ofls
when used withPlugin.exec_cmd()
to take some action based on the output of thels
command.Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines