If no job, the session is suspended until the job is obtained. Therefore, testbox message and job events need to be updated before get job to ensure the timeliness.
Signed-off-by: Wu Zhende wuzhende666@163.com --- src/lib/sched.cr | 11 +++++++++++ src/scheduler/find_job_boot.cr | 16 ++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/src/lib/sched.cr b/src/lib/sched.cr index 2e4fd30..f62f83e 100644 --- a/src/lib/sched.cr +++ b/src/lib/sched.cr @@ -147,6 +147,17 @@ class Sched @log.warn(e) end
+ def send_mq_msg(job_state) + mq_msg = { + "job_id" => @env.get?("job_id").to_s, + "testbox" => @env.get?("testbox").to_s, + "deadline" => @env.get?("deadline").to_s, + "time" => get_time, + "job_state" => job_state + } + spawn mq_publish_confirm(JOB_MQ, mq_msg.to_json) + end + def set_lifecycle(job, testbox, queues) if job deadline = job.get_deadline diff --git a/src/scheduler/find_job_boot.cr b/src/scheduler/find_job_boot.cr index 01b6f1d..2fca531 100644 --- a/src/scheduler/find_job_boot.cr +++ b/src/scheduler/find_job_boot.cr @@ -25,14 +25,7 @@ class Sched rescue e @log.warn(e) ensure - mq_msg = { - "job_id" => @env.get?("job_id").to_s, - "testbox" => @env.get?("testbox").to_s, - "deadline" => @env.get?("deadline").to_s, - "time" => get_time, - "job_state" => "boot" - } - spawn mq_publish_confirm(JOB_MQ, mq_msg.to_json) + send_mq_msg("boot") end
# auto submit a job to collect the host information. @@ -196,6 +189,13 @@ class Sched
def get_job_boot(host, boot_type) queues = get_queues(host) + + # do before get job from etcd + # because if no job will hang + # need to update information in a timely manner + set_lifecycle(nil, host, queues) + send_mq_msg("boot") + job = get_job_from_queues(queues, host) set_lifecycle(job, host, queues)