[Why] nodes need communicate with each other when running cluster jobs. after adding 2 fileds, 'direct_ips' and 'direct_macs', can bind ips to macs.
'macs' get from cluster file ('$LKP_SRC/cluster/*'), 'ips' set by scheduler default: 192.168.222.<1..250>
Now use 192.168.222.<1..250> to test, In future, use DHCP sever interface to get direct_ips.
Signed-off-by: Ren Wen 15991987063@163.com --- src/lib/sched.cr | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/src/lib/sched.cr b/src/lib/sched.cr index 7215df5..d669c50 100644 --- a/src/lib/sched.cr +++ b/src/lib/sched.cr @@ -147,6 +147,25 @@ class Sched return YAML.parse(File.read(cluster_file_path)).as_h end
+ # a private-ip pools, each return 10 ips + private def get_private_ips + # ip = net_id + host_id + # host_id : 1..250 + # will divide into 10 groups used by maximum 10 cluster jobs + host_ids = [] of Int32 + 25.times do |i| + host_ids << i * 10 + 1 + end # [1, 11, ..., 241] + net_id = "192.168.222" + index = @redis.get_seqno % 25 + host_id = host_ids[index] + ips = [] of String + 10.times do |i| + ips << "#{net_id}.#{host_id + i}" + end + ips + end + def get_commit_date(job) if (job["upstream_repo"] != "") && (job["upstream_commit"] != "") data = JSON.parse(%({"git_repo": "#{job["upstream_repo"]}.git", @@ -198,6 +217,9 @@ class Sched # collect all job ids job_ids = [] of String
+ # an array consists of 10 ips + ips = get_private_ips + # steps for each host cluster_config.each do |host, config| tbox_group = host.to_s @@ -219,7 +241,13 @@ class Sched job["testbox"] = tbox_group job.update_tbox_group(tbox_group) job["node_roles"] = config["roles"].as_a.join(" ") - job["node_macs"] = config["macs"].as_a.join(" ") + direct_macs = config["macs"].as_a + direct_ips = [] of String + direct_macs.size.times do + direct_ips << ips.pop {raise "more than 10 macs"} + end + job["direct_macs"] = direct_macs.join(" ") + job["direct_ips"] = direct_ips.join(" ")
response = add_job(job, job_id) message = (response["error"]? ? response["error"]["root_cause"] : "")
需要这么复杂吗
- # a private-ip pools, each return 10 ips
- private def get_private_ips
- # ip = net_id + host_id
- # host_id : 1..250
- # will divide into 10 groups used by maximum 10 cluster jobs
- host_ids = [] of Int32
- 25.times do |i|
host_ids << i * 10 + 1
- end # [1, 11, ..., 241]
- net_id = "192.168.222"
- index = @redis.get_seqno % 25
- host_id = host_ids[index]
- ips = [] of String
- 10.times do |i|
ips << "#{net_id}.#{host_id + i}"
- end
- ips
- end
- def get_commit_date(job) if (job["upstream_repo"] != "") && (job["upstream_commit"] != "") data = JSON.parse(%({"git_repo": "#{job["upstream_repo"]}.git",
@@ -198,6 +217,9 @@ class Sched # collect all job ids job_ids = [] of String
- # an array consists of 10 ips
- ips = get_private_ips
- # steps for each host cluster_config.each do |host, config| tbox_group = host.to_s
@@ -219,7 +241,13 @@ class Sched job["testbox"] = tbox_group job.update_tbox_group(tbox_group) job["node_roles"] = config["roles"].as_a.join(" ")
job["node_macs"] = config["macs"].as_a.join(" ")
direct_macs = config["macs"].as_a
direct_ips = [] of String
direct_macs.size.times do
direct_ips << ips.pop {raise "more than 10 macs"}
end
job["direct_macs"] = direct_macs.join(" ")
job["direct_ips"] = direct_ips.join(" ") response = add_job(job, job_id) message = (response["error"]? ? response["error"]["root_cause"] : "")
-- 2.23.0
Please ignore this mail.
On Wed, Oct 21, 2020 at 04:32:29PM +0800, Ren Wen wrote:
[Why] nodes need communicate with each other when running cluster jobs. after adding 2 fileds, 'direct_ips' and 'direct_macs', can bind ips to macs.
'macs' get from cluster file ('$LKP_SRC/cluster/*'), 'ips' set by scheduler default: 192.168.222.<1..250>
Now use 192.168.222.<1..250> to test, In future, use DHCP sever interface to get direct_ips.
Signed-off-by: Ren Wen 15991987063@163.com
src/lib/sched.cr | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/src/lib/sched.cr b/src/lib/sched.cr index 7215df5..d669c50 100644 --- a/src/lib/sched.cr +++ b/src/lib/sched.cr @@ -147,6 +147,25 @@ class Sched return YAML.parse(File.read(cluster_file_path)).as_h end
- # a private-ip pools, each return 10 ips
- private def get_private_ips
- # ip = net_id + host_id
- # host_id : 1..250
- # will divide into 10 groups used by maximum 10 cluster jobs
- host_ids = [] of Int32
- 25.times do |i|
host_ids << i * 10 + 1
- end # [1, 11, ..., 241]
- net_id = "192.168.222"
- index = @redis.get_seqno % 25
- host_id = host_ids[index]
- ips = [] of String
- 10.times do |i|
ips << "#{net_id}.#{host_id + i}"
- end
- ips
- end
- def get_commit_date(job) if (job["upstream_repo"] != "") && (job["upstream_commit"] != "") data = JSON.parse(%({"git_repo": "#{job["upstream_repo"]}.git",
@@ -198,6 +217,9 @@ class Sched # collect all job ids job_ids = [] of String
- # an array consists of 10 ips
- ips = get_private_ips
- # steps for each host cluster_config.each do |host, config| tbox_group = host.to_s
@@ -219,7 +241,13 @@ class Sched job["testbox"] = tbox_group job.update_tbox_group(tbox_group) job["node_roles"] = config["roles"].as_a.join(" ")
job["node_macs"] = config["macs"].as_a.join(" ")
direct_macs = config["macs"].as_a
direct_ips = [] of String
direct_macs.size.times do
direct_ips << ips.pop {raise "more than 10 macs"}
end
job["direct_macs"] = direct_macs.join(" ")
job["direct_ips"] = direct_ips.join(" ") response = add_job(job, job_id) message = (response["error"]? ? response["error"]["root_cause"] : "")
-- 2.23.0