use queue replace tbox_group
Signed-off-by: Xiao Shenwei <xiaoshenwei96(a)163.com>
---
src/lib/sched.cr | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/lib/sched.cr b/src/lib/sched.cr
index 692180f..d4929cd 100644
--- a/src/lib/sched.cr
+++ b/src/lib/sched.cr
@@ -30,12 +30,15 @@ class Sched
mac.gsub(":", "-")
end
- def set_host_mac(mac : String, hostname : String)
+ def set_host_mac(mac : String, hostname : String, queues : String)
+ puts "queues: #{queues}"
@redis.hash_set("sched/mac2host", normalize_mac(mac), hostname)
+ @redis.hash_set("sched/mac2queues", normalize_mac(mac), queues)
end
def del_host_mac(mac : String)
@redis.hash_del("sched/mac2host", normalize_mac(mac))
+ @redis.hash_del("sched/mac2queues", normalize_mac(mac))
end
# return:
@@ -251,24 +254,24 @@ class Sched
# success: [{"job_id" => job_id, "message" => "", job_state => "submit"}]
# failure: [{"job_id" => "0", "message" => err_msg, job_state => "submit"}]
def submit_single_job(job)
- tbox_group = job.tbox_group
+ queue = job.queue
return [{
"job_id" => "0",
- "message" => "get tbox group failed",
+ "message" => "get queue failed",
"job_state" => "submit",
- }] unless tbox_group
+ }] unless queue
# only single job will has "idle job" and "execute rate limiter"
if job["idle_job"].empty?
- tbox_group += "#{job.get_uuid_tag}"
+ queue += "#{job.get_uuid_tag}"
else
- tbox_group = "#{tbox_group}/idle"
+ queue = "#{queue}/idle"
end
- job_id = add_task(tbox_group, job.lab)
+ job_id = add_task(queue, job.lab)
return [{
"job_id" => "0",
- "message" => "add task queue sched/#{tbox_group} failed",
+ "message" => "add task queue sched/#{queue} failed",
"job_state" => "submit",
}] unless job_id
@@ -372,7 +375,7 @@ class Sched
hostname = @redis.hash_get("sched/mac2host", normalize_mac(api_param))
if hostname.nil? # auto name new/unknown machine
hostname = "sut-#{api_param}"
- set_host_mac(api_param, hostname)
+ set_host_mac(api_param, hostname, "")
# auto submit a job to collect the host information
# grub hostname is link with ":", like "00:01:02:03:04:05"
--
2.23.0