Blame SOURCES/sos-bz1723734-crio-plugin.patch

833739
From 64d7cccf48aee9a07e2e4c5237034638cae30391 Mon Sep 17 00:00:00 2001
833739
From: Daniel J Walsh <dwalsh@redhat.com>
833739
Date: Wed, 29 Aug 2018 06:51:21 -0400
833739
Subject: [PATCH] [crio] Add support for gathering information on cri-o
833739
 containers
833739
833739
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
833739
---
833739
 sos/plugins/crio.py | 74 +++++++++++++++++++++++++++++++++++++++++++++
833739
 1 file changed, 74 insertions(+)
833739
 create mode 100644 sos/plugins/crio.py
833739
833739
diff --git a/sos/plugins/crio.py b/sos/plugins/crio.py
833739
new file mode 100644
833739
index 000000000..f3e9d8428
833739
--- /dev/null
833739
+++ b/sos/plugins/crio.py
833739
@@ -0,0 +1,74 @@
833739
+# Copyright (C) 2018 Red Hat, Inc. Daniel Walsh <dwalsh@redhat.com>
833739
+
833739
+# This file is part of the sos project: https://github.com/sosreport/sos
833739
+#
833739
+# This copyrighted material is made available to anyone wishing to use,
833739
+# modify, copy, or redistribute it subject to the terms and conditions of
833739
+# version 2 of the GNU General Public License.
833739
+#
833739
+# See the LICENSE file in the source distribution for further information.
833739
+
833739
+from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin
833739
+
833739
+
833739
+class CRIO(Plugin):
833739
+
833739
+    """CRI-O containers
833739
+    """
833739
+
833739
+    plugin_name = 'crio'
833739
+    profiles = ('container',)
833739
+    packages = ('cri-o', "cri-tools")
833739
+
833739
+    option_list = [
833739
+        ("all", "enable capture for all containers, even containers "
833739
+            "that have terminated", 'fast', False),
833739
+        ("logs", "capture logs for running containers",
833739
+            'fast', False),
833739
+    ]
833739
+
833739
+    def setup(self):
833739
+        self.add_copy_spec([
833739
+            "/etc/containers/registries.conf",
833739
+            "/etc/containers/storage.conf",
833739
+            "/etc/containers/mounts.conf",
833739
+            "/etc/containers/policy.json",
833739
+            "/etc/crio/crio.conf",
833739
+            "/etc/crio/seccomp.json",
833739
+            "/etc/systemd/system/cri-o.service",
833739
+        ])
833739
+
833739
+        subcmds = [
833739
+            'info',
833739
+            'images',
833739
+            'pods',
833739
+            'ps',
833739
+            'ps -a',
833739
+            'stats',
833739
+            'version',
833739
+        ]
833739
+
833739
+        self.add_cmd_output(["crictl %s" % s for s in subcmds])
833739
+        self.add_journal(units="cri-o")
833739
+        self.add_cmd_output("ls -alhR /etc/cni")
833739
+
833739
+        ps_cmd = 'crictl ps --quiet'
833739
+        if self.get_option('all'):
833739
+            ps_cmd = "%s -a" % ps_cmd
833739
+
833739
+        img_cmd = 'cri-o images --quiet'
833739
+        insp = set()
833739
+
833739
+        for icmd in [ps_cmd, img_cmd]:
833739
+            result = self.get_command_output(icmd)
833739
+            if result['status'] == 0:
833739
+                for con in result['output'].splitlines():
833739
+                    insp.add(con)
833739
+
833739
+        if insp:
833739
+            for container in insp:
833739
+                self.add_cmd_output("crictl inspect %s" % container)
833739
+                if self.get_option('logs'):
833739
+                    self.add_cmd_output("crictl logs -t %s" % container)
833739
+
833739
+# vim: set et ts=4 sw=4 :
833739
From 36a82723dfc2734b18eede4b75708595345c9d7a Mon Sep 17 00:00:00 2001
833739
From: Jake Hunsaker <jhunsake@redhat.com>
833739
Date: Mon, 25 Feb 2019 11:50:50 -0500
833739
Subject: [PATCH] [crio] Add tagging classes
833739
833739
Adds tagging classes so plugin will run on Red Hat and Ubuntu based
833739
systems.
833739
833739
Resolves: #1578
833739
833739
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
833739
---
833739
 sos/plugins/crio.py | 2 +-
833739
 1 file changed, 1 insertion(+), 1 deletion(-)
833739
833739
diff --git a/sos/plugins/crio.py b/sos/plugins/crio.py
833739
index f3e9d8428..7afdf0476 100644
833739
--- a/sos/plugins/crio.py
833739
+++ b/sos/plugins/crio.py
833739
@@ -11,7 +11,7 @@
833739
 from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin
833739
 
833739
 
833739
-class CRIO(Plugin):
833739
+class CRIO(Plugin, RedHatPlugin, UbuntuPlugin):
833739
 
833739
     """CRI-O containers
833739
     """
833739
From 0695dc41c4320e6ecc29f576b7394485d4d35b52 Mon Sep 17 00:00:00 2001
833739
From: Pavel Moravec <pmoravec@redhat.com>
833739
Date: Thu, 7 Feb 2019 10:09:28 +0100
833739
Subject: [PATCH] [general] remove unused module imports
833739
833739
Relevant to: #1559
833739
833739
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
833739
---
833739
 sos/plugins/crio.py                | 2 +-
833739
 1 file changed, 1 insertion(+), 1 deletion(-)
833739
833739
diff --git a/sos/plugins/crio.py b/sos/plugins/crio.py
833739
index 7afdf0476..279ea1fee 100644
833739
--- a/sos/plugins/crio.py
833739
+++ b/sos/plugins/crio.py
833739
@@ -8,7 +8,7 @@
833739
 #
833739
 # See the LICENSE file in the source distribution for further information.
833739
 
833739
-from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin
833739
+from sos.plugins import Plugin
833739
 
833739
 
833739
 class CRIO(Plugin, RedHatPlugin, UbuntuPlugin):
833739
From a608afef3bcb15cb4cc3fb12a14e73f2f30ee015 Mon Sep 17 00:00:00 2001
833739
From: Pavel Moravec <pmoravec@redhat.com>
833739
Date: Thu, 21 Mar 2019 09:57:51 +0100
833739
Subject: [PATCH] [crio] import all plugins referred by CRIO class
833739
833739
Resolves: #1606
833739
833739
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
833739
---
833739
 sos/plugins/crio.py | 2 +-
833739
 1 file changed, 1 insertion(+), 1 deletion(-)
833739
833739
diff --git a/sos/plugins/crio.py b/sos/plugins/crio.py
833739
index 279ea1fee..7afdf0476 100644
833739
--- a/sos/plugins/crio.py
833739
+++ b/sos/plugins/crio.py
833739
@@ -8,7 +8,7 @@
833739
 #
833739
 # See the LICENSE file in the source distribution for further information.
833739
 
833739
-from sos.plugins import Plugin
833739
+from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin
833739
 
833739
 
833739
 class CRIO(Plugin, RedHatPlugin, UbuntuPlugin):
833739
From 48d7bedc1a1035674a9eddfaca2387b7ee83a2c3 Mon Sep 17 00:00:00 2001
833739
From: Jake Hunsaker <jhunsake@redhat.com>
833739
Date: Wed, 27 Feb 2019 14:50:13 -0500
833739
Subject: [PATCH] [crio] Update plugin to use inspeecti/p commands
833739
833739
Updates the crio plugin to use the 'inspecti' and 'inspectp' subcommands
833739
for images and pods respectively. Additionally filter out the socket
833739
deprecation warning from being iterated over.
833739
833739
Adds collection of 'ps -v' and updates the journal unit to 'crio'
833739
instead of 'cri-o'.
833739
833739
Now collects all of /etc/containers, and adds collection of crio files
833739
under /etc/sysconfig.
833739
833739
Resolves: #1588
833739
833739
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
833739
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
833739
---
833739
 sos/plugins/crio.py | 48 +++++++++++++++++++++++++++++----------------
833739
 1 file changed, 31 insertions(+), 17 deletions(-)
833739
833739
diff --git a/sos/plugins/crio.py b/sos/plugins/crio.py
833739
index 7afdf0476..f025d6db9 100644
833739
--- a/sos/plugins/crio.py
833739
+++ b/sos/plugins/crio.py
833739
@@ -29,13 +29,12 @@ class CRIO(Plugin, RedHatPlugin, UbuntuPlugin):
833739
 
833739
     def setup(self):
833739
         self.add_copy_spec([
833739
-            "/etc/containers/registries.conf",
833739
-            "/etc/containers/storage.conf",
833739
-            "/etc/containers/mounts.conf",
833739
-            "/etc/containers/policy.json",
833739
+            "/etc/containers",
833739
+            "/etc/crictl.yaml",
833739
             "/etc/crio/crio.conf",
833739
             "/etc/crio/seccomp.json",
833739
             "/etc/systemd/system/cri-o.service",
833739
+            "/etc/sysconfig/crio-*"
833739
         ])
833739
 
833739
         subcmds = [
833739
@@ -44,31 +43,46 @@ def setup(self):
833739
             'pods',
833739
             'ps',
833739
             'ps -a',
833739
+            'ps -v',
833739
             'stats',
833739
             'version',
833739
         ]
833739
 
833739
         self.add_cmd_output(["crictl %s" % s for s in subcmds])
833739
-        self.add_journal(units="cri-o")
833739
+        self.add_journal(units="crio")
833739
         self.add_cmd_output("ls -alhR /etc/cni")
833739
 
833739
         ps_cmd = 'crictl ps --quiet'
833739
         if self.get_option('all'):
833739
             ps_cmd = "%s -a" % ps_cmd
833739
 
833739
-        img_cmd = 'cri-o images --quiet'
833739
-        insp = set()
833739
+        img_cmd = 'crictl images --quiet'
833739
+        pod_cmd = 'crictl pods --quiet'
833739
 
833739
-        for icmd in [ps_cmd, img_cmd]:
833739
-            result = self.get_command_output(icmd)
833739
-            if result['status'] == 0:
833739
-                for con in result['output'].splitlines():
833739
-                    insp.add(con)
833739
+        containers = self._get_crio_list(ps_cmd)
833739
+        images = self._get_crio_list(img_cmd)
833739
+        pods = self._get_crio_list(pod_cmd)
833739
 
833739
-        if insp:
833739
-            for container in insp:
833739
-                self.add_cmd_output("crictl inspect %s" % container)
833739
-                if self.get_option('logs'):
833739
-                    self.add_cmd_output("crictl logs -t %s" % container)
833739
+        for container in containers:
833739
+            self.add_cmd_output("crictl inspect %s" % container)
833739
+            if self.get_option('logs'):
833739
+                self.add_cmd_output("crictl logs -t %s" % container)
833739
+
833739
+        for image in images:
833739
+            self.add_cmd_output("crictl inspecti %s" % image)
833739
+
833739
+        for pod in pods:
833739
+            self.add_cmd_output("crictl inspectp %s" % pod)
833739
+
833739
+    def _get_crio_list(self, cmd):
833739
+        ret = []
833739
+        result = self.get_command_output(cmd)
833739
+        if result['status'] == 0:
833739
+            for ent in result['output'].splitlines():
833739
+                ret.append(ent)
833739
+            # Prevent the socket deprecation warning from being iterated over
833739
+            if 'deprecated' in ret[0]:
833739
+                ret.pop(0)
833739
+        return ret
833739
 
833739
 # vim: set et ts=4 sw=4 :