Blob Blame History Raw
From 64d7cccf48aee9a07e2e4c5237034638cae30391 Mon Sep 17 00:00:00 2001
From: Daniel J Walsh <dwalsh@redhat.com>
Date: Wed, 29 Aug 2018 06:51:21 -0400
Subject: [PATCH] [crio] Add support for gathering information on cri-o
 containers

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
---
 sos/plugins/crio.py | 74 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 sos/plugins/crio.py

diff --git a/sos/plugins/crio.py b/sos/plugins/crio.py
new file mode 100644
index 000000000..f3e9d8428
--- /dev/null
+++ b/sos/plugins/crio.py
@@ -0,0 +1,74 @@
+# Copyright (C) 2018 Red Hat, Inc. Daniel Walsh <dwalsh@redhat.com>
+
+# This file is part of the sos project: https://github.com/sosreport/sos
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# version 2 of the GNU General Public License.
+#
+# See the LICENSE file in the source distribution for further information.
+
+from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin
+
+
+class CRIO(Plugin):
+
+    """CRI-O containers
+    """
+
+    plugin_name = 'crio'
+    profiles = ('container',)
+    packages = ('cri-o', "cri-tools")
+
+    option_list = [
+        ("all", "enable capture for all containers, even containers "
+            "that have terminated", 'fast', False),
+        ("logs", "capture logs for running containers",
+            'fast', False),
+    ]
+
+    def setup(self):
+        self.add_copy_spec([
+            "/etc/containers/registries.conf",
+            "/etc/containers/storage.conf",
+            "/etc/containers/mounts.conf",
+            "/etc/containers/policy.json",
+            "/etc/crio/crio.conf",
+            "/etc/crio/seccomp.json",
+            "/etc/systemd/system/cri-o.service",
+        ])
+
+        subcmds = [
+            'info',
+            'images',
+            'pods',
+            'ps',
+            'ps -a',
+            'stats',
+            'version',
+        ]
+
+        self.add_cmd_output(["crictl %s" % s for s in subcmds])
+        self.add_journal(units="cri-o")
+        self.add_cmd_output("ls -alhR /etc/cni")
+
+        ps_cmd = 'crictl ps --quiet'
+        if self.get_option('all'):
+            ps_cmd = "%s -a" % ps_cmd
+
+        img_cmd = 'cri-o images --quiet'
+        insp = set()
+
+        for icmd in [ps_cmd, img_cmd]:
+            result = self.get_command_output(icmd)
+            if result['status'] == 0:
+                for con in result['output'].splitlines():
+                    insp.add(con)
+
+        if insp:
+            for container in insp:
+                self.add_cmd_output("crictl inspect %s" % container)
+                if self.get_option('logs'):
+                    self.add_cmd_output("crictl logs -t %s" % container)
+
+# vim: set et ts=4 sw=4 :
From 36a82723dfc2734b18eede4b75708595345c9d7a Mon Sep 17 00:00:00 2001
From: Jake Hunsaker <jhunsake@redhat.com>
Date: Mon, 25 Feb 2019 11:50:50 -0500
Subject: [PATCH] [crio] Add tagging classes

Adds tagging classes so plugin will run on Red Hat and Ubuntu based
systems.

Resolves: #1578

Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
---
 sos/plugins/crio.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sos/plugins/crio.py b/sos/plugins/crio.py
index f3e9d8428..7afdf0476 100644
--- a/sos/plugins/crio.py
+++ b/sos/plugins/crio.py
@@ -11,7 +11,7 @@
 from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin
 
 
-class CRIO(Plugin):
+class CRIO(Plugin, RedHatPlugin, UbuntuPlugin):
 
     """CRI-O containers
     """
From 0695dc41c4320e6ecc29f576b7394485d4d35b52 Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Thu, 7 Feb 2019 10:09:28 +0100
Subject: [PATCH] [general] remove unused module imports

Relevant to: #1559

Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
 sos/plugins/crio.py                | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sos/plugins/crio.py b/sos/plugins/crio.py
index 7afdf0476..279ea1fee 100644
--- a/sos/plugins/crio.py
+++ b/sos/plugins/crio.py
@@ -8,7 +8,7 @@
 #
 # See the LICENSE file in the source distribution for further information.
 
-from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin
+from sos.plugins import Plugin
 
 
 class CRIO(Plugin, RedHatPlugin, UbuntuPlugin):
From a608afef3bcb15cb4cc3fb12a14e73f2f30ee015 Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Thu, 21 Mar 2019 09:57:51 +0100
Subject: [PATCH] [crio] import all plugins referred by CRIO class

Resolves: #1606

Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
 sos/plugins/crio.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sos/plugins/crio.py b/sos/plugins/crio.py
index 279ea1fee..7afdf0476 100644
--- a/sos/plugins/crio.py
+++ b/sos/plugins/crio.py
@@ -8,7 +8,7 @@
 #
 # See the LICENSE file in the source distribution for further information.
 
-from sos.plugins import Plugin
+from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin
 
 
 class CRIO(Plugin, RedHatPlugin, UbuntuPlugin):
From 48d7bedc1a1035674a9eddfaca2387b7ee83a2c3 Mon Sep 17 00:00:00 2001
From: Jake Hunsaker <jhunsake@redhat.com>
Date: Wed, 27 Feb 2019 14:50:13 -0500
Subject: [PATCH] [crio] Update plugin to use inspeecti/p commands

Updates the crio plugin to use the 'inspecti' and 'inspectp' subcommands
for images and pods respectively. Additionally filter out the socket
deprecation warning from being iterated over.

Adds collection of 'ps -v' and updates the journal unit to 'crio'
instead of 'cri-o'.

Now collects all of /etc/containers, and adds collection of crio files
under /etc/sysconfig.

Resolves: #1588

Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
 sos/plugins/crio.py | 48 +++++++++++++++++++++++++++++----------------
 1 file changed, 31 insertions(+), 17 deletions(-)

diff --git a/sos/plugins/crio.py b/sos/plugins/crio.py
index 7afdf0476..f025d6db9 100644
--- a/sos/plugins/crio.py
+++ b/sos/plugins/crio.py
@@ -29,13 +29,12 @@ class CRIO(Plugin, RedHatPlugin, UbuntuPlugin):
 
     def setup(self):
         self.add_copy_spec([
-            "/etc/containers/registries.conf",
-            "/etc/containers/storage.conf",
-            "/etc/containers/mounts.conf",
-            "/etc/containers/policy.json",
+            "/etc/containers",
+            "/etc/crictl.yaml",
             "/etc/crio/crio.conf",
             "/etc/crio/seccomp.json",
             "/etc/systemd/system/cri-o.service",
+            "/etc/sysconfig/crio-*"
         ])
 
         subcmds = [
@@ -44,31 +43,46 @@ def setup(self):
             'pods',
             'ps',
             'ps -a',
+            'ps -v',
             'stats',
             'version',
         ]
 
         self.add_cmd_output(["crictl %s" % s for s in subcmds])
-        self.add_journal(units="cri-o")
+        self.add_journal(units="crio")
         self.add_cmd_output("ls -alhR /etc/cni")
 
         ps_cmd = 'crictl ps --quiet'
         if self.get_option('all'):
             ps_cmd = "%s -a" % ps_cmd
 
-        img_cmd = 'cri-o images --quiet'
-        insp = set()
+        img_cmd = 'crictl images --quiet'
+        pod_cmd = 'crictl pods --quiet'
 
-        for icmd in [ps_cmd, img_cmd]:
-            result = self.get_command_output(icmd)
-            if result['status'] == 0:
-                for con in result['output'].splitlines():
-                    insp.add(con)
+        containers = self._get_crio_list(ps_cmd)
+        images = self._get_crio_list(img_cmd)
+        pods = self._get_crio_list(pod_cmd)
 
-        if insp:
-            for container in insp:
-                self.add_cmd_output("crictl inspect %s" % container)
-                if self.get_option('logs'):
-                    self.add_cmd_output("crictl logs -t %s" % container)
+        for container in containers:
+            self.add_cmd_output("crictl inspect %s" % container)
+            if self.get_option('logs'):
+                self.add_cmd_output("crictl logs -t %s" % container)
+
+        for image in images:
+            self.add_cmd_output("crictl inspecti %s" % image)
+
+        for pod in pods:
+            self.add_cmd_output("crictl inspectp %s" % pod)
+
+    def _get_crio_list(self, cmd):
+        ret = []
+        result = self.get_command_output(cmd)
+        if result['status'] == 0:
+            for ent in result['output'].splitlines():
+                ret.append(ent)
+            # Prevent the socket deprecation warning from being iterated over
+            if 'deprecated' in ret[0]:
+                ret.pop(0)
+        return ret
 
 # vim: set et ts=4 sw=4 :