36 lines
1.4 KiB
Diff
36 lines
1.4 KiB
Diff
|
|
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
|
||
|
|
|