Blame SOURCES/sos-bz1776549-podman-buildah-rootless.patch

bceef4
From 1875213788f4472cc11ce8e732cd4780e99ca477 Mon Sep 17 00:00:00 2001
bceef4
From: Pavel Moravec <pmoravec@redhat.com>
bceef4
Date: Fri, 8 May 2020 15:38:36 +0200
bceef4
Subject: [PATCH] [containers_common] collect rootless containers info
bceef4
bceef4
Add the ability to collect data/info about rootless podman/buildah
bceef4
containers, in particular:
bceef4
bceef4
- containers_common plugopt 'rootlessusers' as a list of users to inspect
bceef4
- for each user, collect:
bceef4
  - its containers config
bceef4
  - [podman|buildah] info and [UID|GID] map
bceef4
- collect user-status and few user-related config files
bceef4
bceef4
Resolves: #2055
bceef4
bceef4
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
bceef4
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
bceef4
---
bceef4
 sos/plugins/containers_common.py | 29 +++++++++++++++++++++++++
bceef4
 1 file changed, 29 insertions(+)
bceef4
bceef4
diff --git a/sos/plugins/containers_common.py b/sos/plugins/containers_common.py
bceef4
index 99ae88fe..9a878849 100644
bceef4
--- a/sos/plugins/containers_common.py
bceef4
+++ b/sos/plugins/containers_common.py
bceef4
@@ -9,6 +9,7 @@
bceef4
 # See the LICENSE file in the source distribution for further information.
bceef4
 
bceef4
 from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin
bceef4
+import os
bceef4
 
bceef4
 
bceef4
 class ContainersCommon(Plugin, RedHatPlugin, UbuntuPlugin):
bceef4
@@ -17,11 +18,39 @@ class ContainersCommon(Plugin, RedHatPlugin, UbuntuPlugin):
bceef4
     plugin_name = 'containers_common'
bceef4
     profiles = ('container', )
bceef4
     packages = ('containers-common', )
bceef4
+    option_list = [
bceef4
+        ('rootlessusers', 'colon-separated list of users\' containers info',
bceef4
+         '', ''),
bceef4
+    ]
bceef4
 
bceef4
     def setup(self):
bceef4
         self.add_copy_spec([
bceef4
             '/etc/containers/*',
bceef4
             '/usr/share/containers/*',
bceef4
+            '/etc/subuid',
bceef4
+            '/etc/subgid',
bceef4
         ])
bceef4
+        self.add_cmd_output(['loginctl user-status'])
bceef4
+
bceef4
+        users_opt = self.get_option('rootlessusers')
bceef4
+        users_list = []
bceef4
+        if users_opt:
bceef4
+            users_list = [x for x in users_opt.split(':') if x]
bceef4
+
bceef4
+        user_subcmds = [
bceef4
+            'info',
bceef4
+            'unshare cat /proc/self/uid_map',
bceef4
+            'unshare cat /proc/self/gid_map'
bceef4
+        ]
bceef4
+        for user in users_list:
bceef4
+            # collect user's containers' config
bceef4
+            self.add_copy_spec(
bceef4
+                '%s/.config/containers/' % (os.path.expanduser('~%s') % user))
bceef4
+            # collect the user's podman/buildah info and uid/guid maps
bceef4
+            for binary in ['/usr/bin/podman', '/usr/bin/buildah']:
bceef4
+                for cmd in user_subcmds:
bceef4
+                    self.add_cmd_output([
bceef4
+                        'machinectl -q shell %s@ %s %s' % (user, binary, cmd)
bceef4
+                    ])
bceef4
 
bceef4
 # vim: set et ts=4 sw=4 :
bceef4
-- 
bceef4
2.21.3
bceef4
bceef4
From c2d4c7d1f3ecf6ac59c665cb5138cb2ddda71b3d Mon Sep 17 00:00:00 2001
bceef4
From: Pavel Moravec <pmoravec@redhat.com>
bceef4
Date: Fri, 22 May 2020 08:17:30 +0200
bceef4
Subject: [PATCH] [containers_common] fix user's home expansion
bceef4
bceef4
Apply os.path.expanduser on ~[user], not ~%s .
bceef4
bceef4
Relates to: #2082
bceef4
bceef4
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
bceef4
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
bceef4
---
bceef4
 sos/plugins/containers_common.py | 2 +-
bceef4
 1 file changed, 1 insertion(+), 1 deletion(-)
bceef4
bceef4
diff --git a/sos/plugins/containers_common.py b/sos/plugins/containers_common.py
bceef4
index 9a878849..da360c7e 100644
bceef4
--- a/sos/plugins/containers_common.py
bceef4
+++ b/sos/plugins/containers_common.py
bceef4
@@ -45,7 +45,7 @@ class ContainersCommon(Plugin, RedHatPlugin, UbuntuPlugin):
bceef4
         for user in users_list:
bceef4
             # collect user's containers' config
bceef4
             self.add_copy_spec(
bceef4
-                '%s/.config/containers/' % (os.path.expanduser('~%s') % user))
bceef4
+                '%s/.config/containers/' % (os.path.expanduser('~%s' % user)))
bceef4
             # collect the user's podman/buildah info and uid/guid maps
bceef4
             for binary in ['/usr/bin/podman', '/usr/bin/buildah']:
bceef4
                 for cmd in user_subcmds:
bceef4
-- 
bceef4
2.21.3
bceef4
bceef4
From 569f261801d3a4da2852c0b40be78b701056edaa Mon Sep 17 00:00:00 2001
bceef4
From: Pavel Moravec <pmoravec@redhat.com>
bceef4
Date: Fri, 22 May 2020 08:20:11 +0200
bceef4
Subject: [PATCH] [containers_common] Call machinectl on foreground
bceef4
bceef4
Commands like:
bceef4
bceef4
machinectl -q shell user1@ ..
bceef4
bceef4
hang if not called on foreground / with terminal.
bceef4
bceef4
Resolves: #2082
bceef4
bceef4
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
bceef4
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
bceef4
---
bceef4
 sos/plugins/containers_common.py | 2 +-
bceef4
 1 file changed, 1 insertion(+), 1 deletion(-)
bceef4
bceef4
diff --git a/sos/plugins/containers_common.py b/sos/plugins/containers_common.py
bceef4
index da360c7e..92c2e9e8 100644
bceef4
--- a/sos/plugins/containers_common.py
bceef4
+++ b/sos/plugins/containers_common.py
bceef4
@@ -51,6 +51,6 @@ class ContainersCommon(Plugin, RedHatPlugin, UbuntuPlugin):
bceef4
                 for cmd in user_subcmds:
bceef4
                     self.add_cmd_output([
bceef4
                         'machinectl -q shell %s@ %s %s' % (user, binary, cmd)
bceef4
-                    ])
bceef4
+                    ], foreground=True)
bceef4
 
bceef4
 # vim: set et ts=4 sw=4 :
bceef4
-- 
bceef4
2.21.3
bceef4
bceef4
From 2b158a5c2a963c52cf5a96b27cc07c73b5829d59 Mon Sep 17 00:00:00 2001
bceef4
From: Pavel Moravec <pmoravec@redhat.com>
bceef4
Date: Thu, 9 Jul 2020 15:38:47 +0200
bceef4
Subject: [PATCH] [containers_common] collect user-related commands outputs
bceef4
bceef4
podman and buildah commands should be collected on per-user basis,
bceef4
as declared by rootlessusers plugin option.
bceef4
bceef4
Resolves: #2145
bceef4
bceef4
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
bceef4
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
bceef4
---
bceef4
 sos/plugins/containers_common.py | 36 ++++++++++++++++++-------
bceef4
 1 file changed, 26 insertions(+), 10 deletions(-)
bceef4
bceef4
diff --git a/sos/plugins/containers_common.py b/sos/plugins/containers_common.py
bceef4
index 92c2e9e8..08962a94 100644
bceef4
--- a/sos/plugins/containers_common.py
bceef4
+++ b/sos/plugins/containers_common.py
bceef4
@@ -30,7 +30,6 @@ class ContainersCommon(Plugin, RedHatPlugin, UbuntuPlugin):
bceef4
             '/etc/subuid',
bceef4
             '/etc/subgid',
bceef4
         ])
bceef4
-        self.add_cmd_output(['loginctl user-status'])
bceef4
 
bceef4
         users_opt = self.get_option('rootlessusers')
bceef4
         users_list = []
bceef4
@@ -38,19 +37,36 @@ class ContainersCommon(Plugin, RedHatPlugin, UbuntuPlugin):
bceef4
             users_list = [x for x in users_opt.split(':') if x]
bceef4
 
bceef4
         user_subcmds = [
bceef4
-            'info',
bceef4
-            'unshare cat /proc/self/uid_map',
bceef4
-            'unshare cat /proc/self/gid_map'
bceef4
+            'podman info',
bceef4
+            'podman unshare cat /proc/self/uid_map',
bceef4
+            'podman unshare cat /proc/self/gid_map',
bceef4
+            'podman images',
bceef4
+            'podman pod ps',
bceef4
+            'podman port --all',
bceef4
+            'podman ps',
bceef4
+            'podman ps -a',
bceef4
+            'podman stats --no-stream --all',
bceef4
+            'podman version',
bceef4
+            'podman volume ls',
bceef4
+            'buildah info',
bceef4
+            'buildah unshare cat /proc/self/uid_map',
bceef4
+            'buildah unshare cat /proc/self/gid_map',
bceef4
+            'buildah containers',
bceef4
+            'buildah containers --all',
bceef4
+            'buildah images',
bceef4
+            'buildah images --all',
bceef4
+            'buildah version',
bceef4
         ]
bceef4
         for user in users_list:
bceef4
             # collect user's containers' config
bceef4
             self.add_copy_spec(
bceef4
                 '%s/.config/containers/' % (os.path.expanduser('~%s' % user)))
bceef4
-            # collect the user's podman/buildah info and uid/guid maps
bceef4
-            for binary in ['/usr/bin/podman', '/usr/bin/buildah']:
bceef4
-                for cmd in user_subcmds:
bceef4
-                    self.add_cmd_output([
bceef4
-                        'machinectl -q shell %s@ %s %s' % (user, binary, cmd)
bceef4
-                    ], foreground=True)
bceef4
+            # collect user-status
bceef4
+            self.add_cmd_output('loginctl user-status %s' % user)
bceef4
+            # collect the user's related commands
bceef4
+            self.add_cmd_output([
bceef4
+                'machinectl -q shell %s@ /usr/bin/%s' % (user, cmd)
bceef4
+                for cmd in user_subcmds
bceef4
+            ], foreground=True)
bceef4
 
bceef4
 # vim: set et ts=4 sw=4 :
bceef4
-- 
bceef4
2.26.2
bceef4