[sos-spyre] collect spyre users podman disk free details#38
[sos-spyre] collect spyre users podman disk free details#38sahithiRavindranath wants to merge 1 commit intolinux-ras:spyrefrom
Conversation
sos-plugin/spyre-external.py
Outdated
| for user in users: | ||
| # since root user outputs are collected in podman plugin | ||
| # skipping here | ||
| if not user or user == 'root': |
There was a problem hiding this comment.
User may not have updated podman plugin that collect podman system df [-v]. So the above assumption may not hold true for all user.
So run this for root user always.
There was a problem hiding this comment.
removed root exception.
sos-plugin/spyre-external.py
Outdated
| # get unique list of users | ||
| users = list(set(users)) | ||
|
|
||
| for user in users: |
There was a problem hiding this comment.
Move the code to find non-root users of sentient group to a helper function.
a45ab56 to
42e5002
Compare
sos-plugin/spyre-external.py
Outdated
| return spyre_cards_bus_ids | ||
|
|
||
| def get_spyre_usernames(self): | ||
|
|
There was a problem hiding this comment.
What is this newline for?
There was a problem hiding this comment.
Please use static Linters to find basic issue in the code. I recommend pylint.
sos-plugin/spyre-external.py
Outdated
| groupname = "sentient" | ||
| spyre_users = self.exec_cmd("getent group "+ groupname) | ||
| if spyre_users['status'] == 0 and spyre_users['output'].strip(): | ||
|
|
There was a problem hiding this comment.
Why we have an empty new line just after if condition?
sos-plugin/spyre-external.py
Outdated
|
|
||
| users = [] | ||
| # All spyre users must be part of sentient group | ||
| groupname = "sentient" |
There was a problem hiding this comment.
I don't think we really need groupname variable. It is only used at one place.
sos-plugin/spyre-external.py
Outdated
|
|
||
| def get_spyre_usernames(self): | ||
|
|
||
| users = [] |
There was a problem hiding this comment.
We have two list variables in this function users and spyre_users.
The function scoped list variable should be named as spyre_users and while extracting the users from output lines users name can be used.
sos-plugin/spyre-external.py
Outdated
| if u.strip() | ||
| ] | ||
| # get unique list of users | ||
| users = list(set(users)) |
There was a problem hiding this comment.
You are making this function unnecessarily complicated. It is not only very inefficient but also hard to review.
There was a problem hiding this comment.
How about keeping things simple:
"""
get_spyre_username(): Get the names of users belonging to
the sentient group.
Currently, all users belonging to the sentient group are
considered Spyre card users.
Args:
None
Returns:
List of spyre card users
"""
def get_spyre_username():
spyre_users = []
getent_cmd_output = self.exec_cmd("getent group sentient")
# Multiple lines are not expected but trying to be safe
for line in getent_cmd_output.splitlines():
line = line.strip().split(':')
# Expected line format
# group_name:x:group_id:user1,user2
# No user at this line
if len(line) < 4:
continue
for user in line[3].split(','):
if user not in sentinet_users:
sentient_users.add(user)
return sentient_users
Previously, podman disk usage data was collected only for the root user. This fix collects the podman disk usage for all non root spyre users(part of sentient group) as well. Signed-off-by: Sahithi Ravindranath <Sahithi.Ravindranath@ibm.com>
42e5002 to
3d6143d
Compare
| ]) | ||
|
|
||
| sentient_users = self.get_spyre_users() | ||
| print(sentient_users) |
There was a problem hiding this comment.
Did you forget to remove debug prints?
| "/etc/security/limits.d/memlock.conf", | ||
| ]) | ||
|
|
||
| sentient_users = self.get_spyre_users() |
There was a problem hiding this comment.
This variable name should be spyre_users.
|
|
||
| sentient_users = self.get_spyre_users() | ||
| print(sentient_users) | ||
| for user in sentient_users: |
There was a problem hiding this comment.
What if root is not part of sentient group?
We should always run these commands for root user regardless.
issue:
podman disk free data was not collected for non root users.
solution:
collecting the podman disk free data for all non root spyre users(part of sentient group)