[PATCH compass-ci] scheduler/find_job_boot.cr: fix tbox state if job interruption

tbox state is running when job interruption, this tbox will always rebooting if no new job, so update tbox state when it requests job every time. Signed-off-by: Wei Jihui <weijihuiall@163.com> --- src/lib/sched.cr | 12 ++++++++++++ src/scheduler/find_job_boot.cr | 1 + 2 files changed, 13 insertions(+) diff --git a/src/lib/sched.cr b/src/lib/sched.cr index dfec365..1b2836f 100644 --- a/src/lib/sched.cr +++ b/src/lib/sched.cr @@ -155,6 +155,18 @@ class Sched @es.update_tbox(job["testbox"], hash) end + def initialize_tbox_boot_wtmp(testbox) + testbox = testbox.to_s + time = Time.local.to_s("%Y-%m-%d %H:%M:%S") + + hash = { + "time" => time, + "state" => "rebooting", + } + + @redis.update_wtmp(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/find_job_boot.cr b/src/scheduler/find_job_boot.cr index 8dd22a8..2024843 100644 --- a/src/scheduler/find_job_boot.cr +++ b/src/scheduler/find_job_boot.cr @@ -16,6 +16,7 @@ class Sched host = value end + initialize_tbox_boot_wtmp(host) response = get_job_boot(host, boot_type) job_id = response[/tmpfs\/(.*)\/job\.cgz/, 1]? @log.info(%({"job_id": "#{job_id}", "job_state": "boot"})) if job_id -- 2.23.0
participants (1)
-
Wei Jihui