
On Wed, Oct 21, 2020 at 12:03:54PM +0800, Wu Fengguang wrote:
On Wed, Oct 21, 2020 at 11:52:06AM +0800, Cao Xueliang wrote:
[why] It may add monitors field in job yaml, sched will parse the monitors field and add depends to the initrd string.
Signed-off-by: Cao Xueliang <caoxl78320@163.com> --- src/lib/job.cr | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 12d3980..00b5e68 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -396,12 +396,42 @@ class Job initrd_pkg_arr = Array(String).new initrd_http_prefix = "http://#{INITRD_HTTP_HOST}:#{INITRD_HTTP_PORT}" mount_type = os_mount == "cifs" ? "nfs" : os_mount.dup + + get_monitors_initrd(mount_type, initrd_http_prefix, initrd_deps_arr, initrd_pkg_arr) + get_pp_initrd(mount_type, initrd_http_prefix, initrd_deps_arr, initrd_pkg_arr) + + self["initrd_deps"] = initrd_deps_arr.uniq.join(" ") + self["initrd_pkg"] = initrd_pkg_arr.uniq.join(" ") + end + + private def get_monitors_initrd(mount_type, initrd_http_prefix, initrd_deps_arr, initrd_pkg_arr) + if @hash["monitors"]?
return unless ...
ok.
to save one indent.
add a blank line after return.
+ program_params = @hash["monitors"].as_h + program_params.keys.each do |program|
Is it possible to reuse code for the below chunk? monitors are not so different than other test programs.
The pp will File.exists? "distro/depends" and "pkg" program dir, but monitors will File.exists? "monitors" program dir. If sched don't need to judge whether the program exists, we just judge the program cgz exists, then we can reuse code. Thanks, Xueliang
+ deps_dest_file = "#{SRV_INITRD}/deps/#{mount_type}/#{os_dir}/#{program}.cgz" + pkg_dest_file = "#{SRV_INITRD}/pkg/#{mount_type}/#{os_dir}/#{program}.cgz" + + if File.exists?("#{user_lkp_src}/monitors/#{program}") + if File.exists?(deps_dest_file) + initrd_deps_arr << "#{initrd_http_prefix}" + JobHelper.service_path(deps_dest_file) + end + + if File.exists?(pkg_dest_file) + initrd_pkg_arr << "#{initrd_http_prefix}" + JobHelper.service_path(pkg_dest_file) + end + end + end + end + end
Thanks, Fengguang