!5 Fix the problem that function cpu_report_result() is called more than once and fix error handling
From: @tong_1001 Reviewed-by: @gaoruoshu Signed-off-by: @gaoruoshu
This commit is contained in:
commit
3dacc5c69c
35
Fix-the-problem-that-function-cpu_report_result-is-c.patch
Normal file
35
Fix-the-problem-that-function-cpu_report_result-is-c.patch
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
From 3e2721852ad1f8047ad219a5ab6c68fd4c9d6f5c Mon Sep 17 00:00:00 2001
|
||||||
|
From: shixuantong <shixuantong1@huawei.com>
|
||||||
|
Date: Wed, 24 Jul 2024 16:17:54 +0800
|
||||||
|
Subject: [PATCH] Fix the problem that function cpu_report_result() is called
|
||||||
|
more than once
|
||||||
|
|
||||||
|
when task is running, user to exec "sentryctl stop cpu_sentry", cpu_report_result() will be called twice. This will cause the log to be printed twice
|
||||||
|
---
|
||||||
|
src/python/syssentry/cpu_sentry.py | 5 +++--
|
||||||
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/python/syssentry/cpu_sentry.py b/src/python/syssentry/cpu_sentry.py
|
||||||
|
index 7e77654..3c4d58d 100644
|
||||||
|
--- a/src/python/syssentry/cpu_sentry.py
|
||||||
|
+++ b/src/python/syssentry/cpu_sentry.py
|
||||||
|
@@ -133,6 +133,7 @@ class CpuSentry:
|
||||||
|
|
||||||
|
result_level = self.send_result.get("result", ResultLevel.FAIL)
|
||||||
|
report_result(task_name, result_level, details)
|
||||||
|
+ self.init_send_result()
|
||||||
|
|
||||||
|
def kill_process(signum, _f, cpu_sentry_obj):
|
||||||
|
"""kill process by 'pkill -9'"""
|
||||||
|
@@ -179,6 +180,6 @@ def main():
|
||||||
|
cpu_sentry_task.send_result["result"] = ResultLevel.FAIL
|
||||||
|
cpu_sentry_task.send_result["details"]["code"] = 1004
|
||||||
|
cpu_sentry_task.send_result["details"]["msg"] = "run cmd [%s] raise Error" % cpu_sentry_task_cmd
|
||||||
|
- finally:
|
||||||
|
cpu_sentry_task.cpu_report_result()
|
||||||
|
- cpu_sentry_task.init_send_result()
|
||||||
|
+ else:
|
||||||
|
+ cpu_sentry_task.cpu_report_result()
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
25
fix-error-handling.patch
Normal file
25
fix-error-handling.patch
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
From 370b22b032dce9290eebca1cf8d48bd155164b6a Mon Sep 17 00:00:00 2001
|
||||||
|
From: shixuantong <shixuantong1@huawei.com>
|
||||||
|
Date: Wed, 24 Jul 2024 17:53:58 +0800
|
||||||
|
Subject: [PATCH] fix error handling
|
||||||
|
|
||||||
|
---
|
||||||
|
src/python/syssentry/cpu_sentry.py | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/python/syssentry/cpu_sentry.py b/src/python/syssentry/cpu_sentry.py
|
||||||
|
index 3c4d58d..d0bafa8 100644
|
||||||
|
--- a/src/python/syssentry/cpu_sentry.py
|
||||||
|
+++ b/src/python/syssentry/cpu_sentry.py
|
||||||
|
@@ -87,7 +87,7 @@ class CpuSentry:
|
||||||
|
}
|
||||||
|
|
||||||
|
def handle_cpu_output(self, stdout: str):
|
||||||
|
- if "<ERROR>" in stdout:
|
||||||
|
+ 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]
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -4,13 +4,15 @@
|
|||||||
Summary: System Inspection Framework
|
Summary: System Inspection Framework
|
||||||
Name: sysSentry
|
Name: sysSentry
|
||||||
Version: 1.0.2
|
Version: 1.0.2
|
||||||
Release: 2
|
Release: 3
|
||||||
License: Mulan PSL v2
|
License: Mulan PSL v2
|
||||||
Group: System Environment/Daemons
|
Group: System Environment/Daemons
|
||||||
Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz
|
Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz
|
||||||
BuildRoot: %{_builddir}/%{name}-root
|
BuildRoot: %{_builddir}/%{name}-root
|
||||||
|
|
||||||
Patch1: fix-version-in-setup.py.patch
|
Patch1: fix-version-in-setup.py.patch
|
||||||
|
Patch2: Fix-the-problem-that-function-cpu_report_result-is-c.patch
|
||||||
|
Patch3: fix-error-handling.patch
|
||||||
|
|
||||||
BuildRequires: cmake gcc-c++
|
BuildRequires: cmake gcc-c++
|
||||||
BuildRequires: python3 python3-setuptools
|
BuildRequires: python3 python3-setuptools
|
||||||
@ -167,6 +169,13 @@ rm -rf %{buildroot}
|
|||||||
%attr(0550,root,root) %{python3_sitelib}/syssentry/cpu_*
|
%attr(0550,root,root) %{python3_sitelib}/syssentry/cpu_*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Jul 25 2024 shixuantong <shixuantong1@huawei.com> - 1.0.2-3
|
||||||
|
- Type:bugfix
|
||||||
|
- CVE:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:Fix the problem that function cpu_report_result() is called more than once
|
||||||
|
fix error handling
|
||||||
|
|
||||||
* Tue Jun 18 2024 shixuantong <shixuantong1@huawei.com> - 1.0.2-2
|
* Tue Jun 18 2024 shixuantong <shixuantong1@huawei.com> - 1.0.2-2
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- CVE:NA
|
- CVE:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user