Blame SOURCES/sos-bz1706060-vdsm-plugin.patch

d8dc0d
From 1b4f8dfb8ac85708441faa3b2c2b9c2624dfa155 Mon Sep 17 00:00:00 2001
d8dc0d
From: "irit.go" <igoihman@redhat.com>
d8dc0d
Date: Tue, 24 Jul 2018 11:01:55 +0300
d8dc0d
Subject: [PATCH 1/2] [Plugin] add get_process_pids() to return PIDs by process
d8dc0d
 name
d8dc0d
d8dc0d
Signed-off-by: Irit Goihman igoihman@redhat.com
d8dc0d
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
d8dc0d
---
d8dc0d
 sos/plugins/__init__.py | 16 ++++++++++++++++
d8dc0d
 1 file changed, 16 insertions(+)
d8dc0d
d8dc0d
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
d8dc0d
index 4c8822b7..cdeda77a 100644
d8dc0d
--- a/sos/plugins/__init__.py
d8dc0d
+++ b/sos/plugins/__init__.py
d8dc0d
@@ -1389,6 +1389,22 @@ class Plugin(object):
d8dc0d
             return False
d8dc0d
         return status
d8dc0d
 
d8dc0d
+    def get_process_pids(self, process):
d8dc0d
+        """Returns PIDs of all processes with process name.
d8dc0d
+        If the process doesn't exist, returns an empty list"""
d8dc0d
+        pids = []
d8dc0d
+        cmd_line_glob = "/proc/[0-9]*/cmdline"
d8dc0d
+        cmd_line_paths = glob.glob(cmd_line_glob)
d8dc0d
+        for path in cmd_line_paths:
d8dc0d
+            try:
d8dc0d
+                with open(path, 'r') as f:
d8dc0d
+                    cmd_line = f.read().strip()
d8dc0d
+                    if process in cmd_line:
d8dc0d
+                        pids.append(path.split("/")[2])
d8dc0d
+            except IOError as e:
d8dc0d
+                continue
d8dc0d
+        return pids
d8dc0d
+
d8dc0d
 
d8dc0d
 class RedHatPlugin(object):
d8dc0d
     """Tagging class for Red Hat's Linux distributions"""
d8dc0d
-- 
d8dc0d
2.17.2
d8dc0d
d8dc0d
d8dc0d
From 0618db904dadb05fde70c181a5940989ac127fe2 Mon Sep 17 00:00:00 2001
d8dc0d
From: Irit Goihman <igoihman@redhat.com>
d8dc0d
Date: Thu, 1 Feb 2018 16:44:32 +0200
d8dc0d
Subject: [PATCH 2/2] [plugins] add vdsm plugin
d8dc0d
d8dc0d
Add a plugin for vdsm
d8dc0d
d8dc0d
Resolves: #1205
d8dc0d
d8dc0d
Signed-off-by: Irit Goihman <igoihman@redhat.com>
d8dc0d
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
d8dc0d
---
d8dc0d
 sos/plugins/vdsm.py | 146 ++++++++++++++++++++++++++++++++++++++++++++
d8dc0d
 1 file changed, 146 insertions(+)
d8dc0d
 create mode 100644 sos/plugins/vdsm.py
d8dc0d
d8dc0d
diff --git a/sos/plugins/vdsm.py b/sos/plugins/vdsm.py
d8dc0d
new file mode 100644
d8dc0d
index 00000000..c648abbf
d8dc0d
--- /dev/null
d8dc0d
+++ b/sos/plugins/vdsm.py
d8dc0d
@@ -0,0 +1,146 @@
d8dc0d
+# Copyright (C) 2018 Red Hat, Inc.
d8dc0d
+
d8dc0d
+# This file is part of the sos project: https://github.com/sosreport/sos
d8dc0d
+#
d8dc0d
+# This copyrighted material is made available to anyone wishing to use,
d8dc0d
+# modify, copy, or redistribute it subject to the terms and conditions of
d8dc0d
+# version 2 of the GNU General Public License.
d8dc0d
+#
d8dc0d
+# See the LICENSE file in the source distribution for further information.
d8dc0d
+
d8dc0d
+from sos.plugins import Plugin, RedHatPlugin
d8dc0d
+
d8dc0d
+import glob
d8dc0d
+import json
d8dc0d
+import re
d8dc0d
+
d8dc0d
+
d8dc0d
+# This configuration is based on vdsm.storage.lvm.LVM_CONF_TEMPLATE.
d8dc0d
+#
d8dc0d
+# locking_type is set to 0 in order to match lvm sos commands. With this
d8dc0d
+# configuration we don't take any locks, so we will never block because
d8dc0d
+# there is a stuck lvm command.
d8dc0d
+# locking_type=0
d8dc0d
+#
d8dc0d
+# use_lvmetad is set to 0 in order not to show cached, old lvm metadata.
d8dc0d
+# use_lvmetad=0
d8dc0d
+#
d8dc0d
+# preferred_names and filter config values are set to capture Vdsm devices.
d8dc0d
+# preferred_names=[ '^/dev/mapper/' ]
d8dc0d
+# filter=[ 'a|^/dev/mapper/.*|', 'r|.*|' ]
d8dc0d
+LVM_CONFIG = """
d8dc0d
+global {
d8dc0d
+    locking_type=0
d8dc0d
+    use_lvmetad=0
d8dc0d
+}
d8dc0d
+devices {
d8dc0d
+    preferred_names=["^/dev/mapper/"]
d8dc0d
+    ignore_suspended_devices=1
d8dc0d
+    write_cache_state=0
d8dc0d
+    disable_after_error_count=3
d8dc0d
+    filter=["a|^/dev/mapper/.*|", "r|.*|"]
d8dc0d
+}
d8dc0d
+"""
d8dc0d
+LVM_CONFIG = re.sub(r"\s+", " ", LVM_CONFIG).strip()
d8dc0d
+
d8dc0d
+
d8dc0d
+class Vdsm(Plugin, RedHatPlugin):
d8dc0d
+    """vdsm Plugin"""
d8dc0d
+
d8dc0d
+    packages = (
d8dc0d
+        'vdsm',
d8dc0d
+        'vdsm-client',
d8dc0d
+    )
d8dc0d
+
d8dc0d
+    plugin_name = 'vdsm'
d8dc0d
+
d8dc0d
+    def setup(self):
d8dc0d
+        self.add_forbidden_path('/etc/pki/vdsm/keys/*')
d8dc0d
+        self.add_forbidden_path('/etc/pki/vdsm/libvirt-spice/*-key.*')
d8dc0d
+        self.add_forbidden_path('/etc/pki/libvirt/private/*')
d8dc0d
+
d8dc0d
+        self.add_cmd_output('service vdsmd status')
d8dc0d
+
d8dc0d
+        self.add_copy_spec([
d8dc0d
+            '/tmp/vds_installer*',
d8dc0d
+            '/tmp/vds_bootstrap*',
d8dc0d
+            '/etc/vdsm/*'
d8dc0d
+        ])
d8dc0d
+
d8dc0d
+        limit = self.get_option('log_size')
d8dc0d
+
d8dc0d
+        self.add_copy_spec('/var/log/vdsm/*', sizelimit=limit)
d8dc0d
+
d8dc0d
+        self._add_vdsm_forbidden_paths()
d8dc0d
+        self.add_copy_spec([
d8dc0d
+            '/var/run/vdsm/*',
d8dc0d
+            '/usr/libexec/vdsm/hooks',
d8dc0d
+            '/var/lib/vdsm'
d8dc0d
+        ])
d8dc0d
+
d8dc0d
+        qemu_pids = self.get_process_pids('qemu-kvm')
d8dc0d
+        if qemu_pids:
d8dc0d
+            files = ["cmdline", "status", "mountstats"]
d8dc0d
+            self.add_copy_spec([
d8dc0d
+                "/proc/%s/%s" % (pid, name)
d8dc0d
+                for pid in qemu_pids
d8dc0d
+                for name in files
d8dc0d
+            ])
d8dc0d
+        self.add_cmd_output([
d8dc0d
+            "ls -ldZ /etc/vdsm",
d8dc0d
+            "su vdsm -s sh -c 'tree -l /rhev/data-center'",
d8dc0d
+            "su vdsm -s sh -c 'ls -lR /rhev/data-center'"
d8dc0d
+        ])
d8dc0d
+        self.add_cmd_output([
d8dc0d
+            "lvm vgs -v -o +tags --config \'%s\'" % LVM_CONFIG,
d8dc0d
+            "lvm lvs -v -o +tags --config \'%s\'" % LVM_CONFIG,
d8dc0d
+            "lvm pvs -v -o +all --config \'%s\'" % LVM_CONFIG
d8dc0d
+        ])
d8dc0d
+
d8dc0d
+        self.add_cmd_output([
d8dc0d
+            'vdsm-client Host getCapabilities',
d8dc0d
+            'vdsm-client Host getStats',
d8dc0d
+            'vdsm-client Host getAllVmStats',
d8dc0d
+            'vdsm-client Host getVMFullList',
d8dc0d
+            'vdsm-client Host getDeviceList',
d8dc0d
+            'vdsm-client Host hostdevListByCaps',
d8dc0d
+            'vdsm-client Host getAllTasksInfo',
d8dc0d
+            'vdsm-client Host getAllTasksStatuses'
d8dc0d
+        ])
d8dc0d
+
d8dc0d
+        try:
d8dc0d
+            res = self.call_ext_prog(
d8dc0d
+                'vdsm-client Host getConnectedStoragePools'
d8dc0d
+            )
d8dc0d
+            if res['status'] == 0:
d8dc0d
+                pools = json.loads(res['output'])
d8dc0d
+                for pool in pools:
d8dc0d
+                    self.add_cmd_output(
d8dc0d
+                        'vdsm-client StoragePool getSpmStatus'
d8dc0d
+                        ' storagepoolID={}'.format(pool)
d8dc0d
+                    )
d8dc0d
+        except ValueError as e:
d8dc0d
+            self._log_error(
d8dc0d
+                'vdsm-client Host getConnectedStoragePools: %s' % (e)
d8dc0d
+            )
d8dc0d
+
d8dc0d
+        try:
d8dc0d
+            res = self.call_ext_prog('vdsm-client Host getStorageDomains')
d8dc0d
+            if res['status'] == 0:
d8dc0d
+                sd_uuids = json.loads(res['output'])
d8dc0d
+                dump_volume_chains_cmd = 'vdsm-tool dump-volume-chains %s'
d8dc0d
+                self.add_cmd_output([
d8dc0d
+                    dump_volume_chains_cmd % uuid for uuid in sd_uuids
d8dc0d
+                ])
d8dc0d
+        except ValueError as e:
d8dc0d
+            self._log_error(
d8dc0d
+                'vdsm-client Host getStorageDomains: %s' % (e)
d8dc0d
+            )
d8dc0d
+
d8dc0d
+    def _add_vdsm_forbidden_paths(self):
d8dc0d
+        """Add confidential sysprep vfds under /var/run/vdsm to
d8dc0d
+         forbidden paths """
d8dc0d
+
d8dc0d
+        for file_path in glob.glob("/var/run/vdsm/*"):
d8dc0d
+            if file_path.endswith(('.vfd', '/isoUploader', '/storage')):
d8dc0d
+                self.add_forbidden_path(file_path)
d8dc0d
-- 
d8dc0d
2.17.2
d8dc0d
d8dc0d
From 7141ebf3b2071c84286ced29154c33502c4da934 Mon Sep 17 00:00:00 2001
d8dc0d
From: Irit goihman <igoihman@redhat.com>
d8dc0d
Date: Sun, 7 Apr 2019 14:03:55 +0300
d8dc0d
Subject: [PATCH] [vdsm] fix plugin docstring capitalisation
d8dc0d
d8dc0d
---
d8dc0d
 sos/plugins/vdsm.py | 2 +-
d8dc0d
 1 file changed, 1 insertion(+), 1 deletion(-)
d8dc0d
d8dc0d
diff --git a/sos/plugins/vdsm.py b/sos/plugins/vdsm.py
d8dc0d
index c648abbf9..4549c372e 100644
d8dc0d
--- a/sos/plugins/vdsm.py
d8dc0d
+++ b/sos/plugins/vdsm.py
d8dc0d
@@ -45,7 +45,7 @@
d8dc0d
 
d8dc0d
 
d8dc0d
 class Vdsm(Plugin, RedHatPlugin):
d8dc0d
-    """vdsm Plugin"""
d8dc0d
+    """vdsm plugin"""
d8dc0d
 
d8dc0d
     packages = (
d8dc0d
         'vdsm',
d8dc0d
From 208a1d9622dfa13d923882793cd19e9e6cf1e488 Mon Sep 17 00:00:00 2001
d8dc0d
From: Irit goihman <igoihman@redhat.com>
d8dc0d
Date: Sun, 7 Apr 2019 14:04:48 +0300
d8dc0d
Subject: [PATCH] [vdsm] use metadata_read_only=1 for LVM2 commands
d8dc0d
d8dc0d
---
d8dc0d
 sos/plugins/vdsm.py | 5 +++++
d8dc0d
 1 file changed, 5 insertions(+)
d8dc0d
d8dc0d
diff --git a/sos/plugins/vdsm.py b/sos/plugins/vdsm.py
d8dc0d
index 4549c372e..913d49a53 100644
d8dc0d
--- a/sos/plugins/vdsm.py
d8dc0d
+++ b/sos/plugins/vdsm.py
d8dc0d
@@ -22,6 +22,10 @@
d8dc0d
 # there is a stuck lvm command.
d8dc0d
 # locking_type=0
d8dc0d
 #
d8dc0d
+# To prevent modifications to volume group metadata (for e.g. due to a
d8dc0d
+# automatically detected inconsistency), metadata_read_only is set to 1.
d8dc0d
+# metadata_read_only=1
d8dc0d
+#
d8dc0d
 # use_lvmetad is set to 0 in order not to show cached, old lvm metadata.
d8dc0d
 # use_lvmetad=0
d8dc0d
 #
d8dc0d
@@ -31,6 +35,7 @@
d8dc0d
 LVM_CONFIG = """
d8dc0d
 global {
d8dc0d
     locking_type=0
d8dc0d
+    metadata_read_only=1
d8dc0d
     use_lvmetad=0
d8dc0d
 }
d8dc0d
 devices {
d8dc0d
From 97c21901ddb6f7d5e3169d1777983f784b103bc4 Mon Sep 17 00:00:00 2001
d8dc0d
From: Irit goihman <igoihman@redhat.com>
d8dc0d
Date: Sun, 7 Apr 2019 14:05:30 +0300
d8dc0d
Subject: [PATCH] [vdsm] drop explicit size limiting
d8dc0d
d8dc0d
---
d8dc0d
 sos/plugins/vdsm.py | 4 +---
d8dc0d
 1 file changed, 1 insertion(+), 3 deletions(-)
d8dc0d
d8dc0d
diff --git a/sos/plugins/vdsm.py b/sos/plugins/vdsm.py
d8dc0d
index 913d49a53..2dc4b6bea 100644
d8dc0d
--- a/sos/plugins/vdsm.py
d8dc0d
+++ b/sos/plugins/vdsm.py
d8dc0d
@@ -72,9 +72,7 @@ def setup(self):
d8dc0d
             '/etc/vdsm/*'
d8dc0d
         ])
d8dc0d
 
d8dc0d
-        limit = self.get_option('log_size')
d8dc0d
-
d8dc0d
-        self.add_copy_spec('/var/log/vdsm/*', sizelimit=limit)
d8dc0d
+        self.add_copy_spec('/var/log/vdsm/*')
d8dc0d
 
d8dc0d
         self._add_vdsm_forbidden_paths()
d8dc0d
         self.add_copy_spec([
d8dc0d
From cfaf930e58f4996919d0da6c356135cfce26dacb Mon Sep 17 00:00:00 2001
d8dc0d
From: Irit goihman <igoihman@redhat.com>
d8dc0d
Date: Sun, 7 Apr 2019 14:13:59 +0300
d8dc0d
Subject: [PATCH] [vdsm] change filter
d8dc0d
d8dc0d
---
d8dc0d
 sos/plugins/vdsm.py | 2 +-
d8dc0d
 1 file changed, 1 insertion(+), 1 deletion(-)
d8dc0d
d8dc0d
diff --git a/sos/plugins/vdsm.py b/sos/plugins/vdsm.py
d8dc0d
index 2dc4b6bea..ab5c6130b 100644
d8dc0d
--- a/sos/plugins/vdsm.py
d8dc0d
+++ b/sos/plugins/vdsm.py
d8dc0d
@@ -43,7 +43,7 @@
d8dc0d
     ignore_suspended_devices=1
d8dc0d
     write_cache_state=0
d8dc0d
     disable_after_error_count=3
d8dc0d
-    filter=["a|^/dev/mapper/.*|", "r|.*|"]
d8dc0d
+    filter=["a|^/dev/disk/by-id/dm-uuid-mpath-|", "r|.+|"]
d8dc0d
 }
d8dc0d
 """
d8dc0d
 LVM_CONFIG = re.sub(r"\s+", " ", LVM_CONFIG).strip()
d8dc0d
From 2ebc04da53dc871c8dd5243567afa4f8592dca29 Mon Sep 17 00:00:00 2001
d8dc0d
From: Irit goihman <igoihman@redhat.com>
d8dc0d
Date: Sun, 7 Apr 2019 14:14:32 +0300
d8dc0d
Subject: [PATCH] [vdsm] capture supervdsmd status
d8dc0d
d8dc0d
---
d8dc0d
 sos/plugins/vdsm.py | 1 +
d8dc0d
 1 file changed, 1 insertion(+)
d8dc0d
d8dc0d
diff --git a/sos/plugins/vdsm.py b/sos/plugins/vdsm.py
d8dc0d
index ab5c6130b..ae9c17c96 100644
d8dc0d
--- a/sos/plugins/vdsm.py
d8dc0d
+++ b/sos/plugins/vdsm.py
d8dc0d
@@ -65,6 +65,7 @@ def setup(self):
d8dc0d
         self.add_forbidden_path('/etc/pki/libvirt/private/*')
d8dc0d
 
d8dc0d
         self.add_cmd_output('service vdsmd status')
d8dc0d
+        self.add_cmd_output('service supervdsmd status')
d8dc0d
 
d8dc0d
         self.add_copy_spec([
d8dc0d
             '/tmp/vds_installer*',