Skip to content

Commit fab947b

Browse files
Update sos to copy kernel config and vmcore (#8857)
Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>
1 parent 2988049 commit fab947b

4 files changed

Lines changed: 189 additions & 1 deletion

File tree

SPECS/sos/copy-kernel-config.patch

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
From f4df6e9abad6601ad1d67821306be0117dbfab24 Mon Sep 17 00:00:00 2001
2+
From: Aadhar Agarwal <aadagarwal@microsoft.com>
3+
Date: Thu, 21 Mar 2024 14:25:09 -0700
4+
Subject: [PATCH] [kernel] Copy the kernel config
5+
6+
Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>
7+
---
8+
sos/report/plugins/kernel.py | 5 +++--
9+
1 file changed, 3 insertions(+), 2 deletions(-)
10+
11+
diff --git a/sos/report/plugins/kernel.py b/sos/report/plugins/kernel.py
12+
index d09d1176e1..1503af2bc9 100644
13+
--- a/sos/report/plugins/kernel.py
14+
+++ b/sos/report/plugins/kernel.py
15+
@@ -111,7 +111,7 @@ def setup(self):
16+
"/proc/buddyinfo",
17+
"/proc/slabinfo",
18+
"/proc/zoneinfo",
19+
- "/lib/modules/%s/modules.dep" % self.policy.kernel_version(),
20+
+ f"/lib/modules/{self.policy.kernel_version()}/modules.dep",
21+
"/etc/conf.modules",
22+
"/etc/modules.conf",
23+
"/etc/modprobe.conf",
24+
@@ -136,7 +136,8 @@ def setup(self):
25+
"/sys/kernel/debug/extfrag/extfrag_index",
26+
clocksource_path + "available_clocksource",
27+
clocksource_path + "current_clocksource",
28+
- "/proc/pressure/"
29+
+ "/proc/pressure/",
30+
+ f"/boot/config-{self.policy.kernel_version()}"
31+
])
32+
33+
if self.get_option("with-timer"):
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
From ab520a3ad3eb891802366616b000288f647b2163 Mon Sep 17 00:00:00 2001
2+
From: Aadhar Agarwal <aadagarwal@microsoft.com>
3+
Date: Mon, 15 Apr 2024 16:32:43 -0700
4+
Subject: [PATCH] [kdump] Create AzureKDump class
5+
6+
This change collects kdump information for Azure Linux.
7+
8+
With this change, we will check the 'path' variable in /etc/kdump.conf
9+
to check where information is being dumped.
10+
11+
If get_vm_core is set to true, collect the latest vm core created
12+
in the last 24 hours that is <= 2GB
13+
14+
Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>
15+
---
16+
sos/report/plugins/kdump.py | 47 ++++++++++++++++++++++++++++++++++++-
17+
1 file changed, 46 insertions(+), 1 deletion(-)
18+
19+
diff --git a/sos/report/plugins/kdump.py b/sos/report/plugins/kdump.py
20+
index e31e9408f0..9440125642 100644
21+
--- a/sos/report/plugins/kdump.py
22+
+++ b/sos/report/plugins/kdump.py
23+
@@ -8,7 +8,7 @@
24+
25+
import platform
26+
from sos.report.plugins import Plugin, PluginOpt, RedHatPlugin, DebianPlugin, \
27+
- UbuntuPlugin, CosPlugin
28+
+ UbuntuPlugin, CosPlugin, AzurePlugin
29+
30+
31+
class KDump(Plugin):
32+
@@ -124,4 +124,49 @@ def setup(self):
33+
if self.get_option("collect-kdumps"):
34+
self.add_copy_spec(["/var/kdump-*"])
35+
36+
+
37+
+class AzureKDump(KDump, AzurePlugin):
38+
+
39+
+ files = ('/etc/kdump.conf',)
40+
+ packages = ('kexec-tools',)
41+
+
42+
+ option_list = [
43+
+ PluginOpt("get_vm_core", default=False, val_type=bool,
44+
+ desc="collect vm core")
45+
+ ]
46+
+
47+
+ def read_kdump_conffile(self):
48+
+ """ Parse /etc/kdump file """
49+
+ path = "/var/crash"
50+
+
51+
+ kdump = '/etc/kdump.conf'
52+
+ with open(kdump, 'r', encoding='UTF-8') as file:
53+
+ for line in file:
54+
+ if line.startswith("path"):
55+
+ path = line.split()[1]
56+
+
57+
+ return path
58+
+
59+
+ def setup(self):
60+
+ super().setup()
61+
+
62+
+ self.add_copy_spec([
63+
+ "/etc/kdump.conf",
64+
+ "/usr/lib/udev/rules.d/*kexec.rules"
65+
+ ])
66+
+
67+
+ try:
68+
+ path = self.read_kdump_conffile()
69+
+ except Exception: # pylint: disable=broad-except
70+
+ # set no filesystem and default path
71+
+ path = "/var/crash"
72+
+
73+
+ self.add_cmd_output(f"ls -alhR {path}")
74+
+ self.add_copy_spec(f"{path}/*/vmcore-dmesg.txt")
75+
+ self.add_copy_spec(f"{path}/*/kexec-dmesg.log")
76+
+
77+
+ # collect the latest vmcore created in the last 24hrs <= 2GB
78+
+ if self.get_option("get_vm_core"):
79+
+ self.add_copy_spec(f"{path}/*/vmcore", sizelimit=2048, maxage=24)
80+
+
81+
# vim: set et ts=4 sw=4 :
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
From 8a7fdf7f3e1194fa4674eea1d5442ca1660c0a67 Mon Sep 17 00:00:00 2001
2+
From: Aadhar Agarwal <aadagarwal@microsoft.com>
3+
Date: Tue, 19 Mar 2024 11:19:38 -0700
4+
Subject: [PATCH] [Plugin,Policy] Make an AzurePlugin class, Update the vendor
5+
url, Update the check function
6+
7+
Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>
8+
---
9+
sos/policies/distros/azure.py | 6 +++++-
10+
sos/report/plugins/__init__.py | 5 +++++
11+
2 files changed, 10 insertions(+), 1 deletion(-)
12+
13+
diff --git a/sos/policies/distros/azure.py b/sos/policies/distros/azure.py
14+
index 950799fa83..b521d1e1be 100644
15+
--- a/sos/policies/distros/azure.py
16+
+++ b/sos/policies/distros/azure.py
17+
@@ -8,6 +8,7 @@
18+
#
19+
# See the LICENSE file in the source distribution for further information.
20+
21+
+from sos.report.plugins import AzurePlugin
22+
from sos.policies.distros.redhat import RedHatPolicy, OS_RELEASE
23+
import os
24+
25+
@@ -17,7 +18,7 @@ class AzurePolicy(RedHatPolicy):
26+
distro = "Azure Linux"
27+
vendor = "Microsoft"
28+
vendor_urls = [
29+
- ('Distribution Website', 'https://github.com/microsoft/CBL-Mariner')
30+
+ ('Distribution Website', 'https://github.com/microsoft/azurelinux')
31+
]
32+
33+
def __init__(self, sysroot=None, init=None, probe_runtime=True,
34+
@@ -25,6 +26,7 @@ def __init__(self, sysroot=None, init=None, probe_runtime=True,
35+
super(AzurePolicy, self).__init__(sysroot=sysroot, init=init,
36+
probe_runtime=probe_runtime,
37+
remote_exec=remote_exec)
38+
+ self.valid_subclasses += [AzurePlugin]
39+
40+
@classmethod
41+
def check(cls, remote=''):
42+
@@ -40,6 +42,8 @@ def check(cls, remote=''):
43+
if line.startswith('NAME'):
44+
if 'Common Base Linux Mariner' in line:
45+
return True
46+
+ if 'Microsoft Azure Linux' in line:
47+
+ return True
48+
return False
49+
50+
# vim: set et ts=4 sw=4 :
51+
diff --git a/sos/report/plugins/__init__.py b/sos/report/plugins/__init__.py
52+
index 94ee50d7fd..fc674be086 100644
53+
--- a/sos/report/plugins/__init__.py
54+
+++ b/sos/report/plugins/__init__.py
55+
@@ -3621,6 +3621,11 @@ class SCLPlugin(RedHatPlugin):
56+
self.add_copy_spec(scl_copyspecs)
57+
58+
59+
+class AzurePlugin(PluginDistroTag):
60+
+ """Tagging class for Azure Linux"""
61+
+ pass
62+
+
63+
+
64+
def import_plugin(name, superclasses=None):
65+
"""Import name as a module and return a list of all classes defined in that
66+
module. superclasses should be a tuple of valid superclasses to import,

SPECS/sos/sos.spec

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Summary: A set of tools to gather troubleshooting information from a system
33
Name: sos
44
Version: 4.6.1
5-
Release: 1%{?dist}
5+
Release: 2%{?dist}
66
License: GPL-2.0-or-later
77
Vendor: Microsoft Corporation
88
Distribution: Mariner
@@ -11,6 +11,9 @@ Source0: https://github.com/sosreport/sos/archive/%{version}.tar.gz#/%{na
1111
# The sos-4.6.1.tar.gz is missing a commit to bump the version to 4.6.1
1212
# https://github.com/orgs/sosreport/discussions/3492
1313
Patch0: bump-version-4-6-1.patch
14+
Patch1: create-azure-plugin.patch
15+
Patch2: copy-kernel-config.patch
16+
Patch3: create-azure-kdump-class.patch
1417
BuildRequires: python3-devel
1518
BuildRequires: python3-setuptools
1619
Requires: bzip2
@@ -73,6 +76,11 @@ rm -rf %{buildroot}%{_prefix}/config/
7376
%config(noreplace) %{_sysconfdir}/sos/sos.conf
7477

7578
%changelog
79+
* Thu Apr 18 2024 Aadhar Agarwal <aadagarwal@microsoft.com> - 4.6.1-2
80+
- Backport a patch that adds an AzurePlugin class
81+
- Backport a patch to copy the kernel config
82+
- Backport a patch that adds an AzureKDump class
83+
7684
* Tue Jan 30 2024 Aadhar Agarwal <aadagarwal@microsoft.com> - 4.6.1-1
7785
- Upgrade to 4.6.1
7886
- Migrated to SPDX license

0 commit comments

Comments
 (0)