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