fix result when process output is None

This commit is contained in:
shixuantong 2024-07-26 16:11:07 +08:00
parent 3dacc5c69c
commit 5108ea55c5
2 changed files with 44 additions and 1 deletions

View File

@ -0,0 +1,36 @@
From e8e4fa5fd9e78508567782e17b7b1cb6ace3ef0d Mon Sep 17 00:00:00 2001
From: shixuantong <shixuantong1@huawei.com>
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

View File

@ -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 <shixuantong1@huawei.com> - 1.0.2-4
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:fix result when process output is None
* Thu Jul 25 2024 shixuantong <shixuantong1@huawei.com> - 1.0.2-3
- Type:bugfix
- CVE:NA