[PATCH v3 compass-ci] scheduler: libvirt: a new boot type of libvirt

Requested by: curl -X GET 'http://<host>:<port>/boot.libvirt/mac/<mac_value>' Response :: some job fields in json format: - jod_id - kernel_uri - initrds_uri - kernel_params - result - LKP_SERVER - templates : this field is for libvirt Signed-off-by: Ren Wen <15991987063@163.com> --- src/scheduler/find_job_boot.cr | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/scheduler/find_job_boot.cr b/src/scheduler/find_job_boot.cr index b2f0802..50ebe97 100644 --- a/src/scheduler/find_job_boot.cr +++ b/src/scheduler/find_job_boot.cr @@ -7,7 +7,7 @@ class Sched boot_type = @env.params.url["boot_type"] case boot_type - when "ipxe" + when "ipxe", "libvirt" host = @redis.hash_get("sched/mac2host", normalize_mac(value)) when "grub" host = @redis.hash_get("sched/mac2host", normalize_mac(value)) @@ -135,6 +135,28 @@ class Sched return response.to_json end + private def get_boot_libvirt(job : Job) + response = {} of String => String | Nil | Array(String) | JSON::Any + + response["job_id"] = job.id + response["kernel_uri"] = job.kernel_uri.lchop("kernel ") + + initrds_uri = job["initrds_uri"]? + initrds_uri = initrds_uri.as_a.map(&.as_s.lchop("initrd ")) if initrds_uri + response["initrds_uri"] = initrds_uri + + kernel_params = job["kernel_params"]? + kernel_params = kernel_params.as_a.map(&.to_s).reject(&.starts_with?("initrd=")).join(" ") if kernel_params + response["kernel_params"] = kernel_params + + response["result_root"] = job.result_root + response["LKP_SERVER"] = job["LKP_SERVER"]? + # *templates* is used by libvirt + response["templates"] = job["templates"]? + + return response.to_json + end + private def get_boot_grub(job : Job) initrd_lkp_cgz = "lkp-#{job.os_arch}.cgz" @@ -176,6 +198,8 @@ class Sched case boot_type when "ipxe" return job ? get_boot_ipxe(job) : ipxe_msg("No job now") + when "libvirt" + return job ? get_boot_libvirt(job) : {"job_id" => ""}.to_json when "grub" return job ? get_boot_grub(job) : grub_msg("No job now") when "container" -- 2.23.0

+ initrds_uri = initrds_uri.as_a.map(&.as_s.lchop("initrd ")) if initrds_uri
+ kernel_params = kernel_params.as_a.map(&.to_s).reject(&.starts_with?("initrd=")).join(" ") if kernel_params
Looks some scheduler logic can be made more straight. initrd=xxx kernel params are only necessary for ipxe boot? So should only be set there. Instead of setting everywhere, only to unset here. Thanks, Fengguang

On Thu, Jan 07, 2021 at 04:59:20PM +0800, Wu Fengguang wrote:
+ initrds_uri = initrds_uri.as_a.map(&.as_s.lchop("initrd ")) if initrds_uri
+ kernel_params = kernel_params.as_a.map(&.to_s).reject(&.starts_with?("initrd=")).join(" ") if kernel_params
Looks some scheduler logic can be made more straight.
initrd=xxx kernel params are only necessary for ipxe boot?
Yes.
So should only be set there. Instead of setting everywhere, only to unset here.
Got it. Thanks, RenWen
Thanks, Fengguang

On Thu, Jan 07, 2021 at 02:21:48PM +0800, Ren Wen wrote:
Requested by: curl -X GET 'http://<host>:<port>/boot.libvirt/mac/<mac_value>'
Response :: some job fields in json format: - jod_id - kernel_uri - initrds_uri - kernel_params - result
result_root not result Thanks, Shenwei
- LKP_SERVER - templates : this field is for libvirt
Signed-off-by: Ren Wen <15991987063@163.com> --- src/scheduler/find_job_boot.cr | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/src/scheduler/find_job_boot.cr b/src/scheduler/find_job_boot.cr index b2f0802..50ebe97 100644 --- a/src/scheduler/find_job_boot.cr +++ b/src/scheduler/find_job_boot.cr @@ -7,7 +7,7 @@ class Sched boot_type = @env.params.url["boot_type"]
case boot_type - when "ipxe" + when "ipxe", "libvirt" host = @redis.hash_get("sched/mac2host", normalize_mac(value)) when "grub" host = @redis.hash_get("sched/mac2host", normalize_mac(value)) @@ -135,6 +135,28 @@ class Sched return response.to_json end
+ private def get_boot_libvirt(job : Job) + response = {} of String => String | Nil | Array(String) | JSON::Any + + response["job_id"] = job.id + response["kernel_uri"] = job.kernel_uri.lchop("kernel ") + + initrds_uri = job["initrds_uri"]? + initrds_uri = initrds_uri.as_a.map(&.as_s.lchop("initrd ")) if initrds_uri + response["initrds_uri"] = initrds_uri + + kernel_params = job["kernel_params"]? + kernel_params = kernel_params.as_a.map(&.to_s).reject(&.starts_with?("initrd=")).join(" ") if kernel_params + response["kernel_params"] = kernel_params + + response["result_root"] = job.result_root + response["LKP_SERVER"] = job["LKP_SERVER"]? + # *templates* is used by libvirt + response["templates"] = job["templates"]? + + return response.to_json + end + private def get_boot_grub(job : Job) initrd_lkp_cgz = "lkp-#{job.os_arch}.cgz"
@@ -176,6 +198,8 @@ class Sched case boot_type when "ipxe" return job ? get_boot_ipxe(job) : ipxe_msg("No job now") + when "libvirt" + return job ? get_boot_libvirt(job) : {"job_id" => ""}.to_json when "grub" return job ? get_boot_grub(job) : grub_msg("No job now") when "container" -- 2.23.0

On Fri, Jan 08, 2021 at 09:05:23AM +0800, Xiao Shenwei wrote:
On Thu, Jan 07, 2021 at 02:21:48PM +0800, Ren Wen wrote:
Requested by: curl -X GET 'http://<host>:<port>/boot.libvirt/mac/<mac_value>'
Response :: some job fields in json format: - jod_id - kernel_uri - initrds_uri - kernel_params - result
result_root not result
got it. Thanks, RenWen
Thanks, Shenwei
- LKP_SERVER - templates : this field is for libvirt
Signed-off-by: Ren Wen <15991987063@163.com> --- src/scheduler/find_job_boot.cr | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/src/scheduler/find_job_boot.cr b/src/scheduler/find_job_boot.cr index b2f0802..50ebe97 100644 --- a/src/scheduler/find_job_boot.cr +++ b/src/scheduler/find_job_boot.cr @@ -7,7 +7,7 @@ class Sched boot_type = @env.params.url["boot_type"]
case boot_type - when "ipxe" + when "ipxe", "libvirt" host = @redis.hash_get("sched/mac2host", normalize_mac(value)) when "grub" host = @redis.hash_get("sched/mac2host", normalize_mac(value)) @@ -135,6 +135,28 @@ class Sched return response.to_json end
+ private def get_boot_libvirt(job : Job) + response = {} of String => String | Nil | Array(String) | JSON::Any + + response["job_id"] = job.id + response["kernel_uri"] = job.kernel_uri.lchop("kernel ") + + initrds_uri = job["initrds_uri"]? + initrds_uri = initrds_uri.as_a.map(&.as_s.lchop("initrd ")) if initrds_uri + response["initrds_uri"] = initrds_uri + + kernel_params = job["kernel_params"]? + kernel_params = kernel_params.as_a.map(&.to_s).reject(&.starts_with?("initrd=")).join(" ") if kernel_params + response["kernel_params"] = kernel_params + + response["result_root"] = job.result_root + response["LKP_SERVER"] = job["LKP_SERVER"]? + # *templates* is used by libvirt + response["templates"] = job["templates"]? + + return response.to_json + end + private def get_boot_grub(job : Job) initrd_lkp_cgz = "lkp-#{job.os_arch}.cgz"
@@ -176,6 +198,8 @@ class Sched case boot_type when "ipxe" return job ? get_boot_ipxe(job) : ipxe_msg("No job now") + when "libvirt" + return job ? get_boot_libvirt(job) : {"job_id" => ""}.to_json when "grub" return job ? get_boot_grub(job) : grub_msg("No job now") when "container" -- 2.23.0
participants (3)
-
Ren Wen
-
Wu Fengguang
-
Xiao Shenwei