From ba6bd15cd1ded39ad9336c701d9a0f9e028b64f8 Mon Sep 17 00:00:00 2001 From: shixuantong Date: Fri, 26 Jul 2024 16:11:07 +0800 Subject: [PATCH] fix result when process output is None (cherry picked from commit 5108ea55c5f7451d7210e9c6a5d74a1716e03f1b) --- fix-result-when-process-output-is-None.patch | 36 ++++++++++++++++++++ sysSentry.spec | 9 ++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 fix-result-when-process-output-is-None.patch diff --git a/fix-result-when-process-output-is-None.patch b/fix-result-when-process-output-is-None.patch new file mode 100644 index 0000000..9d22700 --- /dev/null +++ b/fix-result-when-process-output-is-None.patch @@ -0,0 +1,36 @@ +From e8e4fa5fd9e78508567782e17b7b1cb6ace3ef0d Mon Sep 17 00:00:00 2001 +From: shixuantong +Date: Fri, 26 Jul 2024 15:59:42 +0800 +Subject: [PATCH] fix result when process output is None + +--- + src/python/syssentry/cpu_sentry.py | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/src/python/syssentry/cpu_sentry.py b/src/python/syssentry/cpu_sentry.py +index d0bafa8..9287e2f 100644 +--- a/src/python/syssentry/cpu_sentry.py ++++ b/src/python/syssentry/cpu_sentry.py +@@ -87,11 +87,19 @@ class CpuSentry: + } + + def handle_cpu_output(self, stdout: str): ++ if not stdout: ++ logging.error("%s process output is None, it may be killed!", LOW_LEVEL_INSPECT_CMD) ++ self.send_result["result"] = ResultLevel.FAIL ++ self.send_result["details"]["code"] = 1005 ++ self.send_result["details"]["msg"] = "cpu_sentry task is killed!" ++ return ++ + if "ERROR" in stdout: + self.send_result["result"] = ResultLevel.FAIL + self.send_result["details"]["code"] = 1004 + self.send_result["details"]["msg"] = stdout.split("\n")[0] + return ++ + out_split = stdout.split("\n") + isolated_cores_number = 0 + found_fault_cores_list = [] +-- +2.27.0 + diff --git a/sysSentry.spec b/sysSentry.spec index 6bc93aa..3f63cc0 100644 --- a/sysSentry.spec +++ b/sysSentry.spec @@ -4,7 +4,7 @@ Summary: System Inspection Framework Name: sysSentry Version: 1.0.2 -Release: 3 +Release: 4 License: Mulan PSL v2 Group: System Environment/Daemons Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz @@ -13,6 +13,7 @@ BuildRoot: %{_builddir}/%{name}-root Patch1: fix-version-in-setup.py.patch Patch2: Fix-the-problem-that-function-cpu_report_result-is-c.patch Patch3: fix-error-handling.patch +Patch4: fix-result-when-process-output-is-None.patch BuildRequires: cmake gcc-c++ BuildRequires: python3 python3-setuptools @@ -169,6 +170,12 @@ rm -rf %{buildroot} %attr(0550,root,root) %{python3_sitelib}/syssentry/cpu_* %changelog +* Fri Jul 26 2024 shixuantong - 1.0.2-4 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:fix result when process output is None + * Thu Jul 25 2024 shixuantong - 1.0.2-3 - Type:bugfix - CVE:NA -- Gitee