Module: check_mk
Branch: master
Commit: c8d356c424c3d2c0cf5d18e3d3cdb1ffabd6849a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c8d356c424c3d2…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri Apr 5 10:44:39 2019 +0200
added WK7254: Background Jobs: Fixed bug on several job detail pages, stating the job is
stuck in initialized phase
Change-Id: I62012b483611f500ee6d0737eaeb37578e673efd
---
.werks/7254 | 13 +++++++++++++
cmk/gui/background_job.py | 15 +++++++--------
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/.werks/7254 b/.werks/7254
new file mode 100644
index 0000000..b78ab25
--- /dev/null
+++ b/.werks/7254
@@ -0,0 +1,13 @@
+Title: Background Jobs: Fixed bug on several job detail pages, stating the job is stuck
in "initialized" phase
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1554382214
+
+The <tt>Bake agents</tt> or <tt>Download agent output</tt>
background job details pages incorrectly showed the jobstatus as initialized.
+This error solely was a display bug and was caused by invalid parsing of the jobs
statefile.
+The actual background job was running fine.
diff --git a/cmk/gui/background_job.py b/cmk/gui/background_job.py
index 7a6307c..f37140a 100644
--- a/cmk/gui/background_job.py
+++ b/cmk/gui/background_job.py
@@ -310,19 +310,18 @@ class BackgroundJob(object):
]:
return False
+ if job_status["state"] == JobStatus.state_initialized:
+ # The process was created a millisecond ago
+ # The child process however, did not have time to update the statefile with
its PID
+ # We consider this scenario as OK, if the start time was recent enough
+ if time.time() - job_status["started"] < 5: # 5 seconds
+ return True
+
if job_status["pid"] is None:
return False
try:
p = psutil.Process(job_status["pid"])
- if job_status["state"] == JobStatus.state_initialized:
- # The process was just created, but has/may not been renamed yet
- # Additionally it has no open file handle to the status file
- # The _is_correct_process check will fail in this gray area
- # We consider this scenario as OK, if the start time was recent enough
- if time.time() - job_status["started"] < 5: # 5 seconds
- return True
-
if self._is_correct_process(job_status, p):
return True
except (psutil.NoSuchProcess, psutil.AccessDenied):