According os_mount to add initrds full path
and add initrds file name in root append.
Signed-off-by: Cao Xueliang <caoxl78320(a)163.com>
---
src/lib/job.cr | 89 +++++++++++++++++++++++++++++++++-----
src/lib/sched.cr | 54 ++++-------------------
src/scheduler/constants.cr | 4 ++
3 files changed, 89 insertions(+), 58 deletions(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr
index 53a560c..bedfec0 100644
--- a/src/lib/job.cr
+++ b/src/lib/job.cr
@@ -72,10 +72,12 @@ class Job
lab
initrd_pkg
initrd_deps
+ initrds
result_root
access_key
access_key_file
lkp_initrd_user
+ kernel
kernel_append_root
docker_image
)
@@ -123,8 +125,10 @@ class Job
set_result_root()
set_result_service()
set_os_mount()
- set_kernel_append_root()
set_pp_initrd()
+ set_initrds()
+ set_kernel()
+ set_kernel_append_root()
set_lkp_server()
end
@@ -228,23 +232,83 @@ class Job
end
end
- private def set_kernel_append_root
- os_real_path = JobHelper.service_path("#{SRV_OS}/#{os_dir}")
- lkp_real_path = JobHelper.service_path("#{SRV_OS}/#{os_dir}/initrd.lkp")
- lkp_basename = File.basename(lkp_real_path)
+ private def vmlinuz
+ if os_mount == "initramfs"
+ return "#{INITRD_HTTP_PREFIX}" +
+ "#{JobHelper.service_path("#{SRV_INITRD}/osimage/#{os_dir}/vmlinuz")}"
+ else
+ return "#{OS_HTTP_PREFIX}" +
+ "#{JobHelper.service_path("#{SRV_OS}/#{os_dir}/vmlinuz")}"
+ end
+ end
+
+ private def set_kernel
+ self["kernel"] = "kernel #{vmlinuz()}"
+ end
+
+ private def common_initrds
+ temp_initrds = [] of String
+ temp_initrds << "#{INITRD_HTTP_PREFIX}" +
+ "#{JobHelper.service_path("#{SRV_INITRD}/lkp/#{lkp_initrd_user}/lkp-#{os_arch}.cgz")}"
+ temp_initrds << "#{SCHED_HTTP_PREFIX}/job_initrd_tmpfs/#{id}/job.cgz"
+
+ return temp_initrds
+ end
+
+ private def initramfs_initrds
+ temp_initrds = [] of String
+ temp_initrds << "#{INITRD_HTTP_PREFIX}" +
+ "#{JobHelper.service_path("#{SRV_INITRD}/osimage/#{os_dir}/current")}"
+ temp_initrds << "#{INITRD_HTTP_PREFIX}" +
+ "#{JobHelper.service_path("#{SRV_INITRD}/osimage/#{os_dir}/run-ipconfig.cgz")}"
+
+ temp_initrds.concat(initrd_deps.split(/ /)) unless initrd_deps.empty?
+ temp_initrds.concat(initrd_pkg.split(/ /)) unless initrd_pkg.empty?
+
+ return temp_initrds
+ end
+
+ private def nfs_cifs_initrds
+ temp_initrds = [] of String
+ temp_initrds << "#{OS_HTTP_PREFIX}" +
+ "#{JobHelper.service_path("#{SRV_OS}/#{os_dir}/initrd.lkp")}"
+
+ return temp_initrds
+ end
+
+ private def set_initrds
+ temp_initrds = [] of String
- current_basename = ""
if "#{os_mount}" == "initramfs"
- current_real_path = JobHelper.service_path("#{SRV_INITRD}/osimage/#{os_dir}/current")
- current_basename = File.basename(current_real_path)
+ temp_initrds.concat(initramfs_initrds())
+ else
+ temp_initrds.concat(nfs_cifs_initrds())
+ end
+
+ temp_initrds.concat(common_initrds())
+
+ self["initrds"] = temp_initrds.join(" ")
+ end
+
+ private def initrd_basename
+ basenames = ""
+
+ initrds.split(/ /).each do |initrd|
+ basenames += "initrd=#{File.basename(initrd)} "
end
+ return basenames
+ end
+
+ private def set_kernel_append_root
+ os_real_path = JobHelper.service_path("#{SRV_OS}/#{os_dir}")
+
fs2root = {
- "nfs" => "root=#{OS_HTTP_HOST}:#{os_real_path} initrd=#{lkp_basename}",
+ "nfs" => "root=#{OS_HTTP_HOST}:#{os_real_path} #{initrd_basename()}",
"cifs" => "root=cifs://#{OS_HTTP_HOST}#{os_real_path}" +
- ",guest,ro,hard,vers=1.0,noacl,nouser_xattr initrd=#{lkp_basename}",
- "initramfs" => "rdinit=/sbin/init prompt_ramdisk=0 initrd=#{current_basename}",
- "container" => ""
+ ",guest,ro,hard,vers=1.0,noacl,nouser_xattr #{initrd_basename()}",
+ "initramfs" => "rdinit=/sbin/init prompt_ramdisk=0 #{initrd_basename()}",
+ "container" => "",
}
self["kernel_append_root"] = fs2root[os_mount]
end
@@ -270,6 +334,7 @@ class Job
end
end
end
+
self["initrd_deps"] = initrd_deps_arr.join(" ")
self["initrd_pkg"] = initrd_pkg_arr.join(" ")
end
diff --git a/src/lib/sched.cr b/src/lib/sched.cr
index 309df04..990641c 100644
--- a/src/lib/sched.cr
+++ b/src/lib/sched.cr
@@ -488,61 +488,23 @@ class Sched
return returned
end
- private def get_pp_initrd(job : Job)
- initrd_deps = ""
- initrd_pkg = ""
- if job.os_mount == "initramfs"
- initrd_deps += job.initrd_deps.split.join() { |item| "initrd #{item}\n" }
- initrd_pkg += job.initrd_pkg.split.join() { |item| "initrd #{item}\n" }
+ private def get_initrds(job_initrds)
+ initrds = ""
+ job_initrds.each do |initrd|
+ initrds += "initrd #{initrd}\n"
end
- return initrd_deps, initrd_pkg
+ return initrds
end
private def get_boot_ipxe(job : Job)
- initrd_lkp_cgz = "lkp-#{job.os_arch}.cgz"
-
- initrd_deps, initrd_pkg = get_pp_initrd(job)
-
- initrd_http_prefix = "http://#{INITRD_HTTP_HOST}:#{INITRD_HTTP_PORT}"
- sched_http_prefix = "http://#{SCHED_HOST}:#{SCHED_PORT}"
- os_http_prefix = "http://#{OS_HTTP_HOST}:#{OS_HTTP_PORT}"
-
response = "#!ipxe\n\n"
- if job.os_mount == "initramfs"
- response += "initrd #{initrd_http_prefix}" +
- "#{JobHelper.service_path("#{SRV_INITRD}/osimage/#{job.os_dir}/current")}\n"
- response += "initrd #{initrd_http_prefix}" +
- "#{JobHelper.service_path("#{SRV_INITRD}/osimage/#{job.os_dir}/run-ipconfig.cgz")}\n"
- else
- response += "initrd #{os_http_prefix}" +
- "#{JobHelper.service_path("#{SRV_OS}/#{job.os_dir}/initrd.lkp")}\n"
- end
- response += "initrd #{initrd_http_prefix}" +
- "#{JobHelper.service_path("#{SRV_INITRD}/lkp/#{job.lkp_initrd_user}/#{initrd_lkp_cgz}")}\n"
- response += "initrd #{sched_http_prefix}/job_initrd_tmpfs/#{job.id}/job.cgz\n"
- response += initrd_deps
- response += initrd_pkg
- if job.os_mount == "initramfs"
- response += "kernel #{initrd_http_prefix}" +
- "#{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")}"
- end
+ response += get_initrds(job.initrds.split(/ /))
+ response += job.kernel
response += " user=lkp"
response += " job=/lkp/scheduled/job.yaml RESULT_ROOT=/result/job rootovl ip=dhcp ro"
response += " #{job.kernel_append_root}"
response += add_kernel_console_param(job.os_arch)
- if job.os_mount == "initramfs"
- response += " initrd=#{initrd_lkp_cgz} initrd=job.cgz"
- job.initrd_deps.split.each do |initrd_dep|
- response += " initrd=#{File.basename(initrd_dep)}"
- end
- response += " initrd=#{File.basename(JobHelper.service_path("#{SRV_INITRD}/osimage/#{job.os_dir}/run-ipconfig.cgz"))}\n"
- else
- response += " initrd=#{initrd_lkp_cgz} initrd=job.cgz\n"
- end
- response += "boot\n"
+ response += "\nboot\n"
puts %({"job_id": "#{job.id}", "job_state": "boot"})
return response
diff --git a/src/scheduler/constants.cr b/src/scheduler/constants.cr
index 7ce49a1..839c241 100644
--- a/src/scheduler/constants.cr
+++ b/src/scheduler/constants.cr
@@ -24,4 +24,8 @@ OS_HTTP_PORT = (ENV.has_key?("OS_HTTP_PORT") ? ENV["OS_HTTP_PORT"] : 8000).to_i3
SRV_OS = "/srv/os"
SRV_INITRD = "/srv/initrd"
+INITRD_HTTP_PREFIX = "http://#{INITRD_HTTP_HOST}:#{INITRD_HTTP_PORT}"
+OS_HTTP_PREFIX = "http://#{OS_HTTP_HOST}:#{OS_HTTP_PORT}"
+SCHED_HTTP_PREFIX = "http://#{SCHED_HOST}:#{SCHED_PORT}"
+
DEMO_JOB = %({"suite":"pixz","testcase":"pixz","category":"benchmark","nr_threads":1,"pixz":null,"job_origin":"jobs/pixz.yaml","testbox":"wfg-e595","arch":"x86_64","tbox_group":"wfg-e595","id":"100","kmsg":null,"boot-time":null,"uptime":null,"iostat":null,"heartbeat":null,"vmstat":null,"numa-numastat":null,"numa-vmstat":null,"numa-meminfo":null,"proc-vmstat":null,"proc-stat":null,"meminfo":null,"slabinfo":null,"interrupts":null,"kconfig":"x86_64-rhel-7.6","compiler":"gcc-7"})
--
2.23.0