[PATCH compass-ci] scheduler: alter the major directory to find cluster config file

Cluster config files are placed under lab repo now. Scheduler will find cluster config files from: 1. lab repo (the major, take precedence). e.g. 'lab-z9/cluster/' 2. own lkp repo (for a quick test). e.g. 'lkp-tests/cluster/' Add a constant 'CCI_REPOS' for using. Signed-off-by: Ren Wen <15991987063@163.com> --- src/scheduler/constants.cr | 1 + src/scheduler/submit_job.cr | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/scheduler/constants.cr b/src/scheduler/constants.cr index 41f2c75..db5089d 100644 --- a/src/scheduler/constants.cr +++ b/src/scheduler/constants.cr @@ -11,6 +11,7 @@ JOB_ES_PORT_DEBUG = 9201 JOB_INDEX_TYPE = "jobs/_doc" LAB = ENV["lab"]? || "nolab" +CCI_REPOS = ENV["CCI_REPOS"]? || "/c" SCHED_HOST = (ENV.has_key?("SCHED_HOST") ? ENV["SCHED_HOST"] : "172.17.0.1") SCHED_PORT = (ENV.has_key?("SCHED_PORT") ? ENV["SCHED_PORT"] : 3000).to_i32 diff --git a/src/scheduler/submit_job.cr b/src/scheduler/submit_job.cr index 8871464..34daa3d 100644 --- a/src/scheduler/submit_job.cr +++ b/src/scheduler/submit_job.cr @@ -153,11 +153,19 @@ class Sched @es.set_job_content(job) end - # get cluster config using own lkp_src cluster file, - # a hash type will be returned + # parse cluster config file from lab repo and own lkp repo, + # the prior takes precedence def get_cluster_config(cluster_file, lkp_initrd_user, os_arch) lkp_src = Jobfile::Operate.prepare_lkp_tests(lkp_initrd_user, os_arch) - cluster_file_path = Path.new(lkp_src, "cluster", cluster_file) + lkp_cluster_file_path = Path.new(lkp_src, "cluster", cluster_file) + lab_cluster_file_path = Path.new(CCI_REPOS, "lab-#{LAB}", "cluster", cluster_file) + + if File.file?(lab_cluster_file_path) + cluster_file_path = lab_cluster_file_path + else + cluster_file_path = lkp_cluster_file_path + end + return YAML.parse(File.read(cluster_file_path)) end -- 2.23.0

+ + if File.file?(lab_cluster_file_path) + cluster_file_path = lab_cluster_file_path + else + cluster_file_path = lkp_cluster_file_path + end
You can use cluster_file_path = File.file?(lab_cluster_file_path) ? lab_cluster_file_path : lkp_cluster_file_path here. Thanks, Yuanchao

On Wed, Nov 11, 2020 at 07:37:24PM +0800, Li Yuanchao wrote:
+ + if File.file?(lab_cluster_file_path) + cluster_file_path = lab_cluster_file_path + else + cluster_file_path = lkp_cluster_file_path + end
You can use cluster_file_path = File.file?(lab_cluster_file_path) ? lab_cluster_file_path : lkp_cluster_file_path here.
Got it. Thanks, RenWen
Thanks, Yuanchao

On Thu, Nov 12, 2020 at 09:13:40AM +0800, Ren Wen wrote:
On Wed, Nov 11, 2020 at 07:37:24PM +0800, Li Yuanchao wrote:
+ + if File.file?(lab_cluster_file_path) + cluster_file_path = lab_cluster_file_path + else + cluster_file_path = lkp_cluster_file_path + end
You can use cluster_file_path = File.file?(lab_cluster_file_path) ? lab_cluster_file_path : lkp_cluster_file_path here.
Got it.
I think if-else-end is ok, it's more easy to understand. Thanks, Xueliang
Thanks, RenWen
Thanks, Yuanchao

On Thu, Nov 12, 2020 at 09:28:14AM +0800, Cao Xueliang wrote:
On Thu, Nov 12, 2020 at 09:13:40AM +0800, Ren Wen wrote:
On Wed, Nov 11, 2020 at 07:37:24PM +0800, Li Yuanchao wrote:
+ + if File.file?(lab_cluster_file_path) + cluster_file_path = lab_cluster_file_path + else + cluster_file_path = lkp_cluster_file_path + end
You can use cluster_file_path = File.file?(lab_cluster_file_path) ? lab_cluster_file_path : lkp_cluster_file_path here.
Got it.
I think if-else-end is ok, it's more easy to understand.
Got it. 'ternary if' is clear here, too. Thanks, RenWen
Thanks, Xueliang
Thanks, RenWen
Thanks, Yuanchao
participants (3)
-
Cao Xueliang
-
Li Yuanchao
-
Ren Wen