From cde2822208d1383597ff6ffa4394ca5b6b39637a Mon Sep 17 00:00:00 2001 From: Rob Hoes Date: Fri, 9 Dec 2022 13:16:05 +0000 Subject: [PATCH 1/2] Update lifecycle for pool.migration_compression Signed-off-by: Rob Hoes --- ocaml/idl/datamodel_lifecycle.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocaml/idl/datamodel_lifecycle.ml b/ocaml/idl/datamodel_lifecycle.ml index 06d3916c762..9d2de8eca13 100644 --- a/ocaml/idl/datamodel_lifecycle.ml +++ b/ocaml/idl/datamodel_lifecycle.ml @@ -20,7 +20,7 @@ let prototyped_of_field = function | "host", "last_software_update" -> Some "22.20.0" | "pool", "migration_compression" -> - Some "22.32.0-next" + Some "22.33.0" | _ -> None From 6568cab7429b1b1ffc583b274c162a4db1bec296 Mon Sep 17 00:00:00 2001 From: Rob Hoes Date: Mon, 12 Dec 2022 13:34:00 +0000 Subject: [PATCH 2/2] CA-373551: register for host events rather than task in events_from_xapi A recent change registered for events on the task that was used by the events_from_xapi thread in xapi_xenops. This is so that the event loop can be woken up by injecting an event into this task, without the need to logout its session (as previously done). The problem is that this introduced a task in the DB that is forever "pending", which has unwanted side-effects. For example, it gets GC'ed after 24 hours, and also gets destroyed if the coordinator is restarted. Switch to registering the host object for the localhost instead, which should be more stable. Signed-off-by: Rob Hoes --- ocaml/xapi/xapi_xenops.ml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ocaml/xapi/xapi_xenops.ml b/ocaml/xapi/xapi_xenops.ml index 54fe4033c83..0f7aa7ff687 100644 --- a/ocaml/xapi/xapi_xenops.ml +++ b/ocaml/xapi/xapi_xenops.ml @@ -3207,10 +3207,9 @@ end (* XXX: PR-1255: we also want to only listen for events on VMs and fields we care about *) let events_from_xapi () = let open Event_types in - Server_helpers.exec_with_new_task ~task_in_database:true "xapi events" - (fun __context -> - let task = Context.get_task_id __context |> Ref.string_of in + Server_helpers.exec_with_new_task "xapi events" (fun __context -> let localhost = Helpers.get_localhost ~__context in + let localhost' = Ref.string_of localhost in let token = ref "" in let stop = ref false in while not !stop do @@ -3223,8 +3222,8 @@ let events_from_xapi () = injection" ; try let _ = - XenAPI.Event.inject ~rpc ~session_id ~_class:"task" - ~_ref:task + XenAPI.Event.inject ~rpc ~session_id ~_class:"host" + ~_ref:localhost' in () with e -> @@ -3252,7 +3251,7 @@ let events_from_xapi () = error "events_from_xapi: extra items in the cache: [ %s ]" (String.concat "; " (StringSet.elements extra_in_cache)) ; let classes = - Printf.sprintf "task/%s" task + Printf.sprintf "host/%s" localhost' :: List.map (fun x -> Printf.sprintf "VM/%s" (Ref.string_of x)) resident_VMs @@ -3310,7 +3309,7 @@ let events_from_xapi () = raise e ) ) - | {ty= "task"; reference= t; _} when t = task -> + | {ty= "host"; reference= t; _} when t = localhost' -> debug "Woken event thread: updating list of event \ subscriptions" ;