From 281347b25842c961d856129e13d6b2287a1d5ffb Mon Sep 17 00:00:00 2001 From: Christian Lindig Date: Mon, 29 Apr 2024 13:46:28 +0100 Subject: [PATCH] CA-392163 clear scheduled assignments on startup Clear all (stale) scheduled assignments for: VM, PCI, VGPU objects on startup. We were missing the latter two. Signed-off-by: Christian Lindig --- ocaml/xapi/dbsync_master.ml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ocaml/xapi/dbsync_master.ml b/ocaml/xapi/dbsync_master.ml index 5d657d2cb09..5cdc4b9106e 100644 --- a/ocaml/xapi/dbsync_master.ml +++ b/ocaml/xapi/dbsync_master.ml @@ -156,12 +156,20 @@ let release_locks ~__context = Xapi_vm_lifecycle.force_state_reset ~__context ~self ~value:`Halted ) vms ; - (* All VMs should have their scheduled_to_be_resident_on field cleared *) - List.iter - (fun self -> - Db.VM.set_scheduled_to_be_resident_on ~__context ~self ~value:Ref.null - ) - (Db.VM.get_all ~__context) + (* Clear all assignments that are only scheduled *) + let value = Ref.null in + Db.VM.get_all ~__context + |> List.iter (fun self -> + Db.VM.set_scheduled_to_be_resident_on ~__context ~self ~value + ) ; + Db.PCI.get_all ~__context + |> List.iter (fun self -> + Db.PCI.set_scheduled_to_be_attached_to ~__context ~self ~value + ) ; + Db.VGPU.get_all ~__context + |> List.iter (fun self -> + Db.VGPU.set_scheduled_to_be_resident_on ~__context ~self ~value + ) let create_tools_sr __context name_label name_description sr_introduce maybe_create_pbd =