[PATCH compass-ci] fix: sched: submit idle jobs

1) submit all idles jobs once use '*' -> submit each idle job once until all done. 2) add two fields into job if job's name is multi-qemu. job's name 'multi-qemu' is case-insensitive matching now. 3) `.yaml` and `.yml` can both match. Two extra fields are used for: monitoring logs of virtual machines started by physical machine. Signed-off-by: Ren Wen <15991987063@163.com> --- src/lib/sched.cr | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/lib/sched.cr b/src/lib/sched.cr index 15f5c9e..c27dd99 100644 --- a/src/lib/sched.cr +++ b/src/lib/sched.cr @@ -467,10 +467,20 @@ class Sched end def auto_submit_idle_job(tbox_group) - full_path_patterns = "#{ENV["CCI_REPOS"]}/lab-#{ENV["lab"]}/allot/idle/#{tbox_group}/*.yaml" - Jobfile::Operate.auto_submit_job( - full_path_patterns, - "testbox: #{tbox_group}") if Dir.glob(full_path_patterns).size > 0 + idle_job_path = "#{ENV["CCI_REPOS"]}/lab-#{ENV["lab"]}/allot/idle/#{tbox_group}/" + + if Dir.exists?(idle_job_path) + jobs = Dir[idle_job_path + "*.y{a,}ml"] + extra_job_fields = ["FLUENTD_SERVER_HOST=#{ENV["FLUENTD_SERVER_HOST"]}", + "FLUENTD_SERVER_PORT=#{ENV["FLUENTD_SERVER_PORT"]}"] + + jobs.each do |job| + if Path[job].basename =~ /^multi-qemu\.ya?ml/i + Jobfile::Operate.auto_submit_job(job, "testbox: #{tbox_group}", extra_job_fields) + end + Jobfile::Operate.auto_submit_job(job, "testbox: #{tbox_group}") + end + end end private def add_kernel_console_param(arch_tmp) @@ -520,7 +530,7 @@ class Sched "#{JobHelper.service_path("#{SRV_INITRD}/osimage/#{job.os_dir}/vmlinuz")}" else response += "kernel #{os_http_prefix}" + - "#{JobHelper.service_path("#{SRV_OS}/#{job.os_dir}/vmlinuz")}" + "#{JobHelper.service_path("#{SRV_OS}/#{job.os_dir}/vmlinuz")}" end response += " user=lkp" response += " job=/lkp/scheduled/job.yaml RESULT_ROOT=/result/job rootovl ip=dhcp ro" -- 2.23.0

On Mon, Sep 28, 2020 at 01:23:53PM +0800, Ren Wen wrote:
1) submit all idles jobs once use '*' -> submit each idle job once until all done. 2) add two fields into job if job's name is multi-qemu. job's name 'multi-qemu' is case-insensitive matching now. 3) `.yaml` and `.yml` can both match.
Two extra fields are used for: monitoring logs of virtual machines started by physical machine.
Signed-off-by: Ren Wen <15991987063@163.com> --- src/lib/sched.cr | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/lib/sched.cr b/src/lib/sched.cr index 15f5c9e..c27dd99 100644 --- a/src/lib/sched.cr +++ b/src/lib/sched.cr @@ -467,10 +467,20 @@ class Sched end
def auto_submit_idle_job(tbox_group) - full_path_patterns = "#{ENV["CCI_REPOS"]}/lab-#{ENV["lab"]}/allot/idle/#{tbox_group}/*.yaml" - Jobfile::Operate.auto_submit_job( - full_path_patterns, - "testbox: #{tbox_group}") if Dir.glob(full_path_patterns).size > 0 + idle_job_path = "#{ENV["CCI_REPOS"]}/lab-#{ENV["lab"]}/allot/idle/#{tbox_group}/" + + if Dir.exists?(idle_job_path) + jobs = Dir[idle_job_path + "*.y{a,}ml"] + extra_job_fields = ["FLUENTD_SERVER_HOST=#{ENV["FLUENTD_SERVER_HOST"]}", + "FLUENTD_SERVER_PORT=#{ENV["FLUENTD_SERVER_PORT"]}"] + + jobs.each do |job| + if Path[job].basename =~ /^multi-qemu\.ya?ml/i + Jobfile::Operate.auto_submit_job(job, "testbox: #{tbox_group}", extra_job_fields) + end + Jobfile::Operate.auto_submit_job(job, "testbox: #{tbox_group}") + end + end end
private def add_kernel_console_param(arch_tmp) @@ -520,7 +530,7 @@ class Sched "#{JobHelper.service_path("#{SRV_INITRD}/osimage/#{job.os_dir}/vmlinuz")}" else response += "kernel #{os_http_prefix}" + - "#{JobHelper.service_path("#{SRV_OS}/#{job.os_dir}/vmlinuz")}" + "#{JobHelper.service_path("#{SRV_OS}/#{job.os_dir}/vmlinuz")}"
For style format. Thanks, RenWen
end response += " user=lkp" response += " job=/lkp/scheduled/job.yaml RESULT_ROOT=/result/job rootovl ip=dhcp ro" -- 2.23.0

On Mon, Sep 28, 2020 at 01:23:53PM +0800, Ren Wen wrote:
1) submit all idles jobs once use '*' -> submit each idle job once until all done. 2) add two fields into job if job's name is multi-qemu. job's name 'multi-qemu' is case-insensitive matching now. 3) `.yaml` and `.yml` can both match.
Two extra fields are used for: monitoring logs of virtual machines started by physical machine.
Signed-off-by: Ren Wen <15991987063@163.com> --- src/lib/sched.cr | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/lib/sched.cr b/src/lib/sched.cr index 15f5c9e..c27dd99 100644 --- a/src/lib/sched.cr +++ b/src/lib/sched.cr @@ -467,10 +467,20 @@ class Sched end
def auto_submit_idle_job(tbox_group) - full_path_patterns = "#{ENV["CCI_REPOS"]}/lab-#{ENV["lab"]}/allot/idle/#{tbox_group}/*.yaml" - Jobfile::Operate.auto_submit_job( - full_path_patterns, - "testbox: #{tbox_group}") if Dir.glob(full_path_patterns).size > 0 + idle_job_path = "#{ENV["CCI_REPOS"]}/lab-#{ENV["lab"]}/allot/idle/#{tbox_group}/" +
+ if Dir.exists?(idle_job_path)
1) just exit when not fit. 2) seems lkp submit can handle with *.yaml? really need this code?
+ jobs = Dir[idle_job_path + "*.y{a,}ml"] + extra_job_fields = ["FLUENTD_SERVER_HOST=#{ENV["FLUENTD_SERVER_HOST"]}", + "FLUENTD_SERVER_PORT=#{ENV["FLUENTD_SERVER_PORT"]}"] + + jobs.each do |job| + if Path[job].basename =~ /^multi-qemu\.ya?ml/i + Jobfile::Operate.auto_submit_job(job, "testbox: #{tbox_group}", extra_job_fields) + end + Jobfile::Operate.auto_submit_job(job, "testbox: #{tbox_group}") + end + end end
private def add_kernel_console_param(arch_tmp) @@ -520,7 +530,7 @@ class Sched "#{JobHelper.service_path("#{SRV_INITRD}/osimage/#{job.os_dir}/vmlinuz")}" else response += "kernel #{os_http_prefix}" + - "#{JobHelper.service_path("#{SRV_OS}/#{job.os_dir}/vmlinuz")}" + "#{JobHelper.service_path("#{SRV_OS}/#{job.os_dir}/vmlinuz")}" end response += " user=lkp" response += " job=/lkp/scheduled/job.yaml RESULT_ROOT=/result/job rootovl ip=dhcp ro" -- 2.23.0
-- Thanks. chief <tongqunfeng@huawei.com>

On Mon, Sep 28, 2020 at 04:48:01PM +0800, Tong Qunfeng wrote:
On Mon, Sep 28, 2020 at 01:23:53PM +0800, Ren Wen wrote:
1) submit all idles jobs once use '*' -> submit each idle job once until all done. 2) add two fields into job if job's name is multi-qemu. job's name 'multi-qemu' is case-insensitive matching now. 3) `.yaml` and `.yml` can both match.
Two extra fields are used for: monitoring logs of virtual machines started by physical machine.
Signed-off-by: Ren Wen <15991987063@163.com> --- src/lib/sched.cr | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/lib/sched.cr b/src/lib/sched.cr index 15f5c9e..c27dd99 100644 --- a/src/lib/sched.cr +++ b/src/lib/sched.cr @@ -467,10 +467,20 @@ class Sched end
def auto_submit_idle_job(tbox_group) - full_path_patterns = "#{ENV["CCI_REPOS"]}/lab-#{ENV["lab"]}/allot/idle/#{tbox_group}/*.yaml" - Jobfile::Operate.auto_submit_job( - full_path_patterns, - "testbox: #{tbox_group}") if Dir.glob(full_path_patterns).size > 0 + idle_job_path = "#{ENV["CCI_REPOS"]}/lab-#{ENV["lab"]}/allot/idle/#{tbox_group}/" +
+ if Dir.exists?(idle_job_path)
1) just exit when not fit.
'exit' will not response 'no job now'.
2) seems lkp submit can handle with *.yaml? really need this code?
'job: multi-qemu' needs special fields. Thanks, RenWen
+ jobs = Dir[idle_job_path + "*.y{a,}ml"] + extra_job_fields = ["FLUENTD_SERVER_HOST=#{ENV["FLUENTD_SERVER_HOST"]}", + "FLUENTD_SERVER_PORT=#{ENV["FLUENTD_SERVER_PORT"]}"] + + jobs.each do |job| + if Path[job].basename =~ /^multi-qemu\.ya?ml/i + Jobfile::Operate.auto_submit_job(job, "testbox: #{tbox_group}", extra_job_fields) + end + Jobfile::Operate.auto_submit_job(job, "testbox: #{tbox_group}") + end + end end
private def add_kernel_console_param(arch_tmp) @@ -520,7 +530,7 @@ class Sched "#{JobHelper.service_path("#{SRV_INITRD}/osimage/#{job.os_dir}/vmlinuz")}" else response += "kernel #{os_http_prefix}" + - "#{JobHelper.service_path("#{SRV_OS}/#{job.os_dir}/vmlinuz")}" + "#{JobHelper.service_path("#{SRV_OS}/#{job.os_dir}/vmlinuz")}" end response += " user=lkp" response += " job=/lkp/scheduled/job.yaml RESULT_ROOT=/result/job rootovl ip=dhcp ro" -- 2.23.0
-- Thanks. chief <tongqunfeng@huawei.com>

On Mon, Sep 28, 2020 at 10:37:35PM +0800, Ren Wen wrote:
On Mon, Sep 28, 2020 at 04:48:01PM +0800, Tong Qunfeng wrote:
On Mon, Sep 28, 2020 at 01:23:53PM +0800, Ren Wen wrote:
1) submit all idles jobs once use '*' -> submit each idle job once until all done. 2) add two fields into job if job's name is multi-qemu. job's name 'multi-qemu' is case-insensitive matching now. 3) `.yaml` and `.yml` can both match.
Two extra fields are used for: monitoring logs of virtual machines started by physical machine.
Signed-off-by: Ren Wen <15991987063@163.com> --- src/lib/sched.cr | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/lib/sched.cr b/src/lib/sched.cr index 15f5c9e..c27dd99 100644 --- a/src/lib/sched.cr +++ b/src/lib/sched.cr @@ -467,10 +467,20 @@ class Sched end
def auto_submit_idle_job(tbox_group) - full_path_patterns = "#{ENV["CCI_REPOS"]}/lab-#{ENV["lab"]}/allot/idle/#{tbox_group}/*.yaml" - Jobfile::Operate.auto_submit_job( - full_path_patterns, - "testbox: #{tbox_group}") if Dir.glob(full_path_patterns).size > 0 + idle_job_path = "#{ENV["CCI_REPOS"]}/lab-#{ENV["lab"]}/allot/idle/#{tbox_group}/" +
+ if Dir.exists?(idle_job_path)
1) just exit when not fit.
'exit' will not response 'no job now'.
I mean do "error handle at first", then code can be more clear.
2) seems lkp submit can handle with *.yaml? really need this code?
'job: multi-qemu' needs special fields.
Thanks, RenWen
+ jobs = Dir[idle_job_path + "*.y{a,}ml"] + extra_job_fields = ["FLUENTD_SERVER_HOST=#{ENV["FLUENTD_SERVER_HOST"]}", + "FLUENTD_SERVER_PORT=#{ENV["FLUENTD_SERVER_PORT"]}"] + + jobs.each do |job| + if Path[job].basename =~ /^multi-qemu\.ya?ml/i + Jobfile::Operate.auto_submit_job(job, "testbox: #{tbox_group}", extra_job_fields) + end + Jobfile::Operate.auto_submit_job(job, "testbox: #{tbox_group}") + end + end end
private def add_kernel_console_param(arch_tmp) @@ -520,7 +530,7 @@ class Sched "#{JobHelper.service_path("#{SRV_INITRD}/osimage/#{job.os_dir}/vmlinuz")}" else response += "kernel #{os_http_prefix}" + - "#{JobHelper.service_path("#{SRV_OS}/#{job.os_dir}/vmlinuz")}" + "#{JobHelper.service_path("#{SRV_OS}/#{job.os_dir}/vmlinuz")}" end response += " user=lkp" response += " job=/lkp/scheduled/job.yaml RESULT_ROOT=/result/job rootovl ip=dhcp ro" -- 2.23.0
-- Thanks. chief <tongqunfeng@huawei.com>
-- Thanks. chief <tongqunfeng@huawei.com>

On Mon, Sep 28, 2020 at 07:31:28PM +0800, Wu Fengguang wrote:
3) `.yaml` and `.yml` can both match.
+ jobs = Dir[idle_job_path + "*.y{a,}ml"] + if Path[job].basename =~ /^multi-qemu\.ya?ml/i
Better match only yaml. That code is not gg friendly. It can be more clean to keep consistent rule in one project.
Got it. Thanks, RenWen
Thanks, Fengguang

Well I wonder if it's asking for trouble in future while costing more code complexity now. What if some more jobs need this environment? What's the problem exposing the variables unconditionally? Thanks, Fengguang On Mon, Sep 28, 2020 at 01:23:53PM +0800, Ren Wen wrote:
1) submit all idles jobs once use '*' -> submit each idle job once until all done. 2) add two fields into job if job's name is multi-qemu. job's name 'multi-qemu' is case-insensitive matching now. 3) `.yaml` and `.yml` can both match.
Two extra fields are used for: monitoring logs of virtual machines started by physical machine.
Signed-off-by: Ren Wen <15991987063@163.com> --- src/lib/sched.cr | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/lib/sched.cr b/src/lib/sched.cr index 15f5c9e..c27dd99 100644 --- a/src/lib/sched.cr +++ b/src/lib/sched.cr @@ -467,10 +467,20 @@ class Sched end
def auto_submit_idle_job(tbox_group) - full_path_patterns = "#{ENV["CCI_REPOS"]}/lab-#{ENV["lab"]}/allot/idle/#{tbox_group}/*.yaml" - Jobfile::Operate.auto_submit_job( - full_path_patterns, - "testbox: #{tbox_group}") if Dir.glob(full_path_patterns).size > 0 + idle_job_path = "#{ENV["CCI_REPOS"]}/lab-#{ENV["lab"]}/allot/idle/#{tbox_group}/" + + if Dir.exists?(idle_job_path) + jobs = Dir[idle_job_path + "*.y{a,}ml"] + extra_job_fields = ["FLUENTD_SERVER_HOST=#{ENV["FLUENTD_SERVER_HOST"]}", + "FLUENTD_SERVER_PORT=#{ENV["FLUENTD_SERVER_PORT"]}"] + + jobs.each do |job| + if Path[job].basename =~ /^multi-qemu\.ya?ml/i + Jobfile::Operate.auto_submit_job(job, "testbox: #{tbox_group}", extra_job_fields) + end + Jobfile::Operate.auto_submit_job(job, "testbox: #{tbox_group}") + end + end end
private def add_kernel_console_param(arch_tmp) @@ -520,7 +530,7 @@ class Sched "#{JobHelper.service_path("#{SRV_INITRD}/osimage/#{job.os_dir}/vmlinuz")}" else response += "kernel #{os_http_prefix}" + - "#{JobHelper.service_path("#{SRV_OS}/#{job.os_dir}/vmlinuz")}" + "#{JobHelper.service_path("#{SRV_OS}/#{job.os_dir}/vmlinuz")}" end response += " user=lkp" response += " job=/lkp/scheduled/job.yaml RESULT_ROOT=/result/job rootovl ip=dhcp ro" -- 2.23.0

On Mon, Sep 28, 2020 at 07:34:51PM +0800, Wu Fengguang wrote:
Well I wonder if it's asking for trouble in future while costing more code complexity now.
What if some more jobs need this environment? What's the problem exposing the variables unconditionally?
Add the extra fields whether other idle jobs need or not? Thanks, RenWen
Thanks, Fengguang
On Mon, Sep 28, 2020 at 01:23:53PM +0800, Ren Wen wrote:
1) submit all idles jobs once use '*' -> submit each idle job once until all done. 2) add two fields into job if job's name is multi-qemu. job's name 'multi-qemu' is case-insensitive matching now. 3) `.yaml` and `.yml` can both match.
Two extra fields are used for: monitoring logs of virtual machines started by physical machine.
Signed-off-by: Ren Wen <15991987063@163.com> --- src/lib/sched.cr | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/lib/sched.cr b/src/lib/sched.cr index 15f5c9e..c27dd99 100644 --- a/src/lib/sched.cr +++ b/src/lib/sched.cr @@ -467,10 +467,20 @@ class Sched end
def auto_submit_idle_job(tbox_group) - full_path_patterns = "#{ENV["CCI_REPOS"]}/lab-#{ENV["lab"]}/allot/idle/#{tbox_group}/*.yaml" - Jobfile::Operate.auto_submit_job( - full_path_patterns, - "testbox: #{tbox_group}") if Dir.glob(full_path_patterns).size > 0 + idle_job_path = "#{ENV["CCI_REPOS"]}/lab-#{ENV["lab"]}/allot/idle/#{tbox_group}/" + + if Dir.exists?(idle_job_path) + jobs = Dir[idle_job_path + "*.y{a,}ml"] + extra_job_fields = ["FLUENTD_SERVER_HOST=#{ENV["FLUENTD_SERVER_HOST"]}", + "FLUENTD_SERVER_PORT=#{ENV["FLUENTD_SERVER_PORT"]}"] + + jobs.each do |job| + if Path[job].basename =~ /^multi-qemu\.ya?ml/i + Jobfile::Operate.auto_submit_job(job, "testbox: #{tbox_group}", extra_job_fields) + end + Jobfile::Operate.auto_submit_job(job, "testbox: #{tbox_group}") + end + end end
private def add_kernel_console_param(arch_tmp) @@ -520,7 +530,7 @@ class Sched "#{JobHelper.service_path("#{SRV_INITRD}/osimage/#{job.os_dir}/vmlinuz")}" else response += "kernel #{os_http_prefix}" + - "#{JobHelper.service_path("#{SRV_OS}/#{job.os_dir}/vmlinuz")}" + "#{JobHelper.service_path("#{SRV_OS}/#{job.os_dir}/vmlinuz")}" end response += " user=lkp" response += " job=/lkp/scheduled/job.yaml RESULT_ROOT=/result/job rootovl ip=dhcp ro" -- 2.23.0

On Mon, Sep 28, 2020 at 10:30:57PM +0800, Ren Wen wrote:
On Mon, Sep 28, 2020 at 07:34:51PM +0800, Wu Fengguang wrote:
Well I wonder if it's asking for trouble in future while costing more code complexity now.
What if some more jobs need this environment? What's the problem exposing the variables unconditionally?
Add the extra fields whether other idle jobs need or not?
Let's keep it simple by exporting env to all jobs. TO ALL: selective action based on job name is BAD idea. Thanks, Fengguang

On Tue, Sep 29, 2020 at 10:42:07AM +0800, Wu Fengguang wrote:
On Mon, Sep 28, 2020 at 10:30:57PM +0800, Ren Wen wrote:
On Mon, Sep 28, 2020 at 07:34:51PM +0800, Wu Fengguang wrote:
Well I wonder if it's asking for trouble in future while costing more code complexity now.
What if some more jobs need this environment? What's the problem exposing the variables unconditionally?
Add the extra fields whether other idle jobs need or not?
Let's keep it simple by exporting env to all jobs.
Got it.
TO ALL: selective action based on job name is BAD idea.
Thanks, Fengguang
participants (3)
-
Ren Wen
-
Tong Qunfeng
-
Wu Fengguang