Move `auto_submit_idle_job` from `sched.cr` to `find_job_boot.cr`,
this is a step for finding job when there's no job in conventional
queues.
When submitting idle job, queue is: tbox_group/idle
Signed-off-by: Ren Wen <15991987063(a)163.com>
---
src/lib/sched.cr | 14 --------------
src/scheduler/constants.cr | 2 ++
src/scheduler/find_job_boot.cr | 23 +++++++++++++++++++++++
3 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/src/lib/sched.cr b/src/lib/sched.cr
index 26ddd92..46ded9c 100644
--- a/src/lib/sched.cr
+++ b/src/lib/sched.cr
@@ -54,20 +54,6 @@ class Sched
@redis.hash_del("sched/host2queues", hostname)
end
- def auto_submit_idle_job(tbox_group)
- full_path_patterns = "#{ENV["CCI_REPOS"]}/lab-#{ENV["lab"]}/allot/idle/#{tbox_group}/*.yaml"
- extra_job_fields = [
- "idle_job=true",
- "MASTER_FLUENTD_HOST=#{ENV["MASTER_FLUENTD_HOST"]}",
- "MASTER_FLUENTD_PORT=#{ENV["MASTER_FLUENTD_PORT"]}",
- ]
-
- Jobfile::Operate.auto_submit_job(
- full_path_patterns,
- "testbox: #{tbox_group}",
- extra_job_fields) if Dir.glob(full_path_patterns).size > 0
- end
-
def update_tbox_wtmp
testbox = ""
hash = Hash(String, String).new
diff --git a/src/scheduler/constants.cr b/src/scheduler/constants.cr
index 1b37333..5e6d0ab 100644
--- a/src/scheduler/constants.cr
+++ b/src/scheduler/constants.cr
@@ -29,3 +29,5 @@ OS_HTTP_PREFIX = "http://#{OS_HTTP_HOST}:#{OS_HTTP_PORT}"
SCHED_HTTP_PREFIX = "http://#{SCHED_HOST}:#{SCHED_PORT}"
DEMO_JOB = %({"suite":"pixz","testcase":"pixz","category":"benchmark","nr_threads":1,"pixz":null,"job_origin":"jobs/pixz.yaml","testbox":"wfg-e595","arch":"x86_64","tbox_group":"wfg-e595","id":"100","kmsg":null,"boot-time":null,"uptime":null,"iostat":null,"heartbeat":null,"vmstat":null,"numa-numastat":null,"numa-vmstat":null,"numa-meminfo":null,"proc-vmstat":null,"proc-stat":null,"meminfo":null,"slabinfo":null,"interrupts":null,"kconfig":"x86_64-rhel-7.6","compiler":"gcc-7"})
+
+TEAM_ACCOUNT = "team(a)crystal.ci"
diff --git a/src/scheduler/find_job_boot.cr b/src/scheduler/find_job_boot.cr
index 9805464..772e82f 100644
--- a/src/scheduler/find_job_boot.cr
+++ b/src/scheduler/find_job_boot.cr
@@ -217,4 +217,27 @@ class Sched
return job
end
+
+ def auto_submit_idle_job(tbox_group)
+ account_info = @es.get_account(TEAM_ACCOUNT).as_h
+ raise "Failed to verify the account: #{TEAM_ACCOUNT}" unless account_info["found"].as_bool?
+ my_email = account_info["my_email"]
+ my_name = account_info["my_name"]
+ my_uuid = account_info["my_uuid"]
+
+ full_path_patterns = "#{ENV["CCI_REPOS"]}/lab-#{ENV["lab"]}/allot/idle/#{tbox_group}/*.yaml"
+ extra_job_fields = [
+ "queue=#{tbox_group}/idle",
+ "my_email=#{my_email}",
+ "my_name=#{my_name}",
+ "my_uuid=#{my_uuid}",
+ "MASTER_FLUENTD_HOST=#{ENV["MASTER_FLUENTD_HOST"]}",
+ "MASTER_FLUENTD_PORT=#{ENV["MASTER_FLUENTD_PORT"]}",
+ ]
+
+ Jobfile::Operate.auto_submit_job(
+ full_path_patterns,
+ "testbox: #{tbox_group}",
+ extra_job_fields) if Dir.glob(full_path_patterns).size > 0
+ end
end
--
2.23.0