[Before]: Every node in cluster config file will be distributed a job when submitting cluster jobs.
[Now]: Job will be distributed according to job content.
For example:
If job has:
if role server: if role client:
then only nodes which roles contains 'server' and 'client' will use.
Signed-off-by: Ren Wen 15991987063@163.com --- src/scheduler/submit_job.cr | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/src/scheduler/submit_job.cr b/src/scheduler/submit_job.cr index c09d145..bcb265f 100644 --- a/src/scheduler/submit_job.cr +++ b/src/scheduler/submit_job.cr @@ -38,6 +38,7 @@ class Sched job_messages = Array(Hash(String, String)).new lab = job.lab subqueue = job.subqueue + roles = get_roles(job)
# collect all job ids job_ids = [] of String @@ -52,6 +53,9 @@ class Sched
# steps for each host cluster_config["nodes"].as_h.each do |host, config| + # continue if role in cluster config matches role in job + next if (config["roles"].as_a.map(&.to_s) & roles).empty? + queue = host.to_s job_id = add_task("#{queue}/#{subqueue}", lab)
@@ -157,6 +161,11 @@ class Sched end end
+ def get_roles(job) + roles = job.hash.keys.map { |key| $1 if key =~ /^if role (.*)/ } + roles.compact.map(&.strip) + end + def get_commit_date(job) if (job["upstream_repo"] != "") && (job["upstream_commit"] != "") data = JSON.parse(%({"git_repo": "#{job["upstream_repo"]}.git",