From b8fa679df7c7e5eb3430609e78df68635ac16d0d Mon Sep 17 00:00:00 2001 From: Sahithi Ravindranath Date: Tue, 17 Feb 2026 22:47:21 -0600 Subject: [PATCH] [sos-spyre] run podman commands for non-root sentient group 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 --- sos-plugin/spyre-external.py | 50 ++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/sos-plugin/spyre-external.py b/sos-plugin/spyre-external.py index 2c8632c..963bb2e 100644 --- a/sos-plugin/spyre-external.py +++ b/sos-plugin/spyre-external.py @@ -53,17 +53,26 @@ def setup(self): "lsslot -c phb", ]) - self.add_cmd_output([ - "podman system df", - "podman system df -v", - ]) - self.add_copy_spec([ "/etc/modprobe.d/vfio-pci.conf", "/etc/udev/rules.d/95-vfio-3.rules", "/etc/security/limits.d/memlock.conf", ]) + spyre_users = self.get_spyre_users() + # To always collect data for root user regardless + if 'root' not in spyre_users: + spyre_users.append('root') + for user in spyre_users: + # collects podman disk usage data + command = f"sudo -iu {user} " + if user == 'root': + command = "" + self.add_cmd_output([ + command + "podman system df", + command + "podman system df -v", + ]) + def get_spyre_cards(self): context = pyudev.Context() spyre_cards_bus_ids = [] @@ -81,4 +90,35 @@ def get_spyre_cards(self): return spyre_cards_bus_ids + """ + get_spyre_users(): 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_users(self): + sentient_users = [] + getent_cmd = self.exec_cmd("getent group sentient") + if getent_cmd['status'] == 0 and getent_cmd['output'].strip(): + 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.strip() and user not in sentient_users: + sentient_users.append(user) + + return sentient_users # vim: set et ts=4 sw=4 :