When the machine accesses the API of the scheduler to update the job
status,
the machine's active time is also updated.
Signed-off-by: Wu Zhende <wuzhende666(a)163.com>
---
src/lib/sched.cr | 7 +++++++
src/scheduler/update_job_parameter.cr | 4 +++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/lib/sched.cr b/src/lib/sched.cr
index 51f493e..f5aba03 100644
--- a/src/lib/sched.cr
+++ b/src/lib/sched.cr
@@ -163,6 +163,13 @@ class Sched
@es.update_tbox(testbox.to_s, hash)
end
+ def update_testbox_time(job_id)
+ job = @redis.get_job(job_id)
+ testbox = job["testbox"]
+ hash = {"time" => @env.get?("time").to_s}
+ @es.update_tbox(testbox, hash)
+ end
+
def report_ssh_port
testbox = @env.params.query["tbox_name"]
ssh_port = @env.params.query["ssh_port"].to_s
diff --git a/src/scheduler/update_job_parameter.cr b/src/scheduler/update_job_parameter.cr
index cc4cf87..b43aa06 100644
--- a/src/scheduler/update_job_parameter.cr
+++ b/src/scheduler/update_job_parameter.cr
@@ -9,6 +9,7 @@ class Sched
end
@env.set "job_id", job_id
+ @env.set "time", get_time
# try to get report value and then update it
job_content = {} of String => String
@@ -34,13 +35,14 @@ class Sched
@log.info(log.to_json)
@env.set "job_state", job_content["job_state"]?
+ update_testbox_time(job_id)
rescue e
@log.warn(e)
ensure
mq_msg = {
"job_id" => @env.get?("job_id").to_s,
"job_state" => (@env.get?("job_state") || "update").to_s,
- "time" => get_time
+ "time" => @env.get?("time").to_s
}
@mq.pushlish_confirm(JOB_MQ, mq_msg.to_json)
end
--
2.23.0