example:
"submit_time": "2021-03-31T16:01:07+0800"
"boot_time": "2021-03-31T16:01:33+0800"
"close_time": "2021-03-31T16:02:47+0800"
Signed-off-by: Wu Zhende <wuzhende666(a)163.com>
---
src/lib/job.cr | 5 +++++
src/scheduler/close_job.cr | 5 ++++-
src/scheduler/find_job_boot.cr | 1 +
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr
index 5767f61..2d15aae 100644
--- a/src/lib/job.cr
+++ b/src/lib/job.cr
@@ -170,6 +170,11 @@ class Job
set_sshr_info()
set_queue()
set_subqueue()
+ set_time("submit_time")
+ end
+
+ def set_time(key)
+ self[key] = Time.local.to_s("%Y-%m-%dT%H:%M:%S+0800")
end
private def set_docker_os
diff --git a/src/scheduler/close_job.cr b/src/scheduler/close_job.cr
index 746f70a..a112a38 100644
--- a/src/scheduler/close_job.cr
+++ b/src/scheduler/close_job.cr
@@ -15,6 +15,9 @@ class Sched
job["job_state"] = job_state if job_state
job["job_state"] = "complete" if job["job_state"] == "boot"
+ job.set_time("close_time")
+ @env.set "close_time", job["close_time"]
+
response = @es.set_job_content(job)
if response["_id"] == nil
# es update fail, raise exception
@@ -34,7 +37,7 @@ class Sched
mq_msg = {
"job_id" => @env.get?("job_id").to_s,
"job_state" => "close",
- "time" => get_time
+ "time" => @env.get?("close_time").to_s
}
spawn mq_publish_confirm(JOB_MQ, mq_msg.to_json)
end
diff --git a/src/scheduler/find_job_boot.cr b/src/scheduler/find_job_boot.cr
index 2596f83..6e8d5d1 100644
--- a/src/scheduler/find_job_boot.cr
+++ b/src/scheduler/find_job_boot.cr
@@ -92,6 +92,7 @@ class Sched
if job
job.update({"testbox" => testbox})
job.set_result_root
+ job.set_time("boot_time")
@log.info(%({"job_id": "#{job_id}", "result_root": "/srv#{job.result_root}", "job_state"
: "set result root"}))
set_id2job(job)
--
2.23.0