Blame SOURCES/sos-bz1658938-docker-podman-containers.patch

fce3c4
From 77c72b415feccd828fd7bc13caebf9841afc40c2 Mon Sep 17 00:00:00 2001
fce3c4
From: "Bryn M. Reeves" <bmr@redhat.com>
fce3c4
Date: Mon, 3 Sep 2018 17:11:06 +0100
fce3c4
Subject: [PATCH] [docker] combine docker 'inspect' and 'logs' loops
fce3c4
fce3c4
We're iterating over all the containers: might as well only do it
fce3c4
one time.
fce3c4
fce3c4
Related: #1406, #1407
fce3c4
fce3c4
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
fce3c4
---
fce3c4
 sos/plugins/docker.py | 4 +---
fce3c4
 1 file changed, 1 insertion(+), 3 deletions(-)
fce3c4
fce3c4
diff --git a/sos/plugins/docker.py b/sos/plugins/docker.py
fce3c4
index a44264a4..5b2acff5 100644
fce3c4
--- a/sos/plugins/docker.py
fce3c4
+++ b/sos/plugins/docker.py
fce3c4
@@ -80,9 +80,7 @@ class Docker(Plugin):
fce3c4
         if insp:
fce3c4
             for container in insp:
fce3c4
                 self.add_cmd_output("docker inspect %s" % container)
fce3c4
-
fce3c4
-            if self.get_option('logs'):
fce3c4
-                for container in insp:
fce3c4
+                if self.get_option('logs'):
fce3c4
                     self.add_cmd_output("docker logs -t %s" % container)
fce3c4
 
fce3c4
 
fce3c4
-- 
fce3c4
2.17.2
fce3c4
fce3c4
From e3cfb1428592390166237e715471bb62d9bd9db6 Mon Sep 17 00:00:00 2001
fce3c4
From: Daniel J Walsh <dwalsh@redhat.com>
fce3c4
Date: Wed, 29 Aug 2018 06:50:10 -0400
fce3c4
Subject: [PATCH] [podman] Add support for gathering information on podman
fce3c4
 containers
fce3c4
fce3c4
Resolves: #1407.
fce3c4
fce3c4
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
fce3c4
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
fce3c4
---
fce3c4
 sos/plugins/podman.py | 79 +++++++++++++++++++++++++++++++++++++++++++
fce3c4
 1 file changed, 79 insertions(+)
fce3c4
 create mode 100644 sos/plugins/podman.py
fce3c4
fce3c4
diff --git a/sos/plugins/podman.py b/sos/plugins/podman.py
fce3c4
new file mode 100644
fce3c4
index 00000000..c43246fc
fce3c4
--- /dev/null
fce3c4
+++ b/sos/plugins/podman.py
fce3c4
@@ -0,0 +1,79 @@
fce3c4
+# Copyright (C) 2018 Red Hat, Inc. Daniel Walsh <dwalsh@redhat.com>
fce3c4
+
fce3c4
+# This file is part of the sos project: https://github.com/sosreport/sos
fce3c4
+#
fce3c4
+# This copyrighted material is made available to anyone wishing to use,
fce3c4
+# modify, copy, or redistribute it subject to the terms and conditions of
fce3c4
+# version 2 of the GNU General Public License.
fce3c4
+#
fce3c4
+# See the LICENSE file in the source distribution for further information.
fce3c4
+
fce3c4
+from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin
fce3c4
+
fce3c4
+
fce3c4
+class Podman(Plugin):
fce3c4
+
fce3c4
+    """Podman containers
fce3c4
+    """
fce3c4
+
fce3c4
+    plugin_name = 'podman'
fce3c4
+    profiles = ('container',)
fce3c4
+    packages = ('podman')
fce3c4
+
fce3c4
+    option_list = [
fce3c4
+        ("all", "enable capture for all containers, even containers "
fce3c4
+            "that have terminated", 'fast', False),
fce3c4
+        ("logs", "capture logs for running containers",
fce3c4
+            'fast', False),
fce3c4
+        ("size", "capture image sizes for podman ps", 'slow', False)
fce3c4
+    ]
fce3c4
+
fce3c4
+    def setup(self):
fce3c4
+        self.add_copy_spec([
fce3c4
+            "/etc/containers/registries.conf",
fce3c4
+            "/etc/containers/storage.conf",
fce3c4
+            "/etc/containers/mounts.conf",
fce3c4
+            "/etc/containers/policy.json",
fce3c4
+        ])
fce3c4
+
fce3c4
+        subcmds = [
fce3c4
+            'info',
fce3c4
+            'images',
fce3c4
+            'pod ps',
fce3c4
+            'pod ps -a',
fce3c4
+            'ps',
fce3c4
+            'ps -a',
fce3c4
+            'stats --no-stream',
fce3c4
+            'version',
fce3c4
+        ]
fce3c4
+
fce3c4
+        self.add_cmd_output(["podman %s" % s for s in subcmds])
fce3c4
+
fce3c4
+        # separately grab ps -s as this can take a *very* long time
fce3c4
+        if self.get_option('size'):
fce3c4
+            self.add_cmd_output('podman ps -as')
fce3c4
+
fce3c4
+        self.add_journal(units="podman")
fce3c4
+        self.add_cmd_output("ls -alhR /etc/cni")
fce3c4
+
fce3c4
+        ps_cmd = 'podman ps -q'
fce3c4
+        if self.get_option('all'):
fce3c4
+            ps_cmd = "%s -a" % ps_cmd
fce3c4
+
fce3c4
+        img_cmd = 'podman images -q'
fce3c4
+        insp = set()
fce3c4
+
fce3c4
+        for icmd in [ps_cmd, img_cmd]:
fce3c4
+            result = self.get_command_output(icmd)
fce3c4
+            if result['status'] == 0:
fce3c4
+                for con in result['output'].splitlines():
fce3c4
+                    insp.add(con)
fce3c4
+
fce3c4
+        if insp:
fce3c4
+            for container in insp:
fce3c4
+                self.add_cmd_output("podman inspect %s" % container)
fce3c4
+                if self.get_option('logs'):
fce3c4
+                    self.add_cmd_output("podman logs -t %s" % container)
fce3c4
+
fce3c4
+
fce3c4
+# vim: set et ts=4 sw=4 :
fce3c4
-- 
fce3c4
2.17.2
fce3c4
fce3c4
From 1401c7153dda9bd0558035ba0692cf05a93ca419 Mon Sep 17 00:00:00 2001
fce3c4
From: Pavel Moravec <pmoravec@redhat.com>
fce3c4
Date: Tue, 6 Nov 2018 08:13:52 +0100
fce3c4
Subject: [PATCH] [podman] allow the plugin for RedHatPlugin and UbuntuPlugin
fce3c4
fce3c4
Until Podman inherits RedHatPlugin and/or UbuntuPlugin, the plugin
fce3c4
can not be executed on underlying distros.
fce3c4
fce3c4
Further, remove one redundant test as "for container in insp" will
fce3c4
work properly also for empty "insp".
fce3c4
fce3c4
Resolves: #1473
fce3c4
fce3c4
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
fce3c4
---
fce3c4
 sos/plugins/podman.py | 11 +++++------
fce3c4
 1 file changed, 5 insertions(+), 6 deletions(-)
fce3c4
fce3c4
diff --git a/sos/plugins/podman.py b/sos/plugins/podman.py
fce3c4
index c43246fc..72e22558 100644
fce3c4
--- a/sos/plugins/podman.py
fce3c4
+++ b/sos/plugins/podman.py
fce3c4
@@ -11,7 +11,7 @@
fce3c4
 from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin
fce3c4
 
fce3c4
 
fce3c4
-class Podman(Plugin):
fce3c4
+class Podman(Plugin, RedHatPlugin, UbuntuPlugin):
fce3c4
 
fce3c4
     """Podman containers
fce3c4
     """
fce3c4
@@ -69,11 +69,10 @@ class Podman(Plugin):
fce3c4
                 for con in result['output'].splitlines():
fce3c4
                     insp.add(con)
fce3c4
 
fce3c4
-        if insp:
fce3c4
-            for container in insp:
fce3c4
-                self.add_cmd_output("podman inspect %s" % container)
fce3c4
-                if self.get_option('logs'):
fce3c4
-                    self.add_cmd_output("podman logs -t %s" % container)
fce3c4
+        for container in insp:
fce3c4
+            self.add_cmd_output("podman inspect %s" % container)
fce3c4
+            if self.get_option('logs'):
fce3c4
+                self.add_cmd_output("podman logs -t %s" % container)
fce3c4
 
fce3c4
 
fce3c4
 # vim: set et ts=4 sw=4 :
fce3c4
-- 
fce3c4
2.17.2
fce3c4