Skip to content

Commit

Permalink
Merge pull request #5216 from danilo-delbusso/bug/duplicate-messages_…
Browse files Browse the repository at this point in the history
…CA-365059

CA-365059: Clear messages in source pool after migrating VM
  • Loading branch information
robhoes authored Oct 26, 2023
2 parents be36265 + 040599d commit 5341a83
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 7 additions & 5 deletions ocaml/xapi/xapi_message.ml
Original file line number Diff line number Diff line change
Expand Up @@ -817,13 +817,15 @@ let handler (req : Http.Request.t) fd _ =
(ExnHelper.string_of_exn e)
)

(* Export messages and send to another host/pool over http. *)
let send_messages ~__context ~cls ~obj_uuid ~session_id ~remote_address =
let msgs = get ~__context ~cls ~obj_uuid ~since:(Date.of_float 0.0) in
let body = export_xml msgs in
(* Export and send messages stored on the current host to another host/pool over http. *)
let send_messages ~__context ~cls ~obj_uuid ~session_id ~remote_address
~messages =
let body = export_xml messages in
let query =
[
("session_id", Ref.string_of session_id); ("cls", "VM"); ("uuid", obj_uuid)
("session_id", Ref.string_of session_id)
; ("cls", Record_util.class_to_string cls)
; ("uuid", obj_uuid)
]
in
let subtask_of = Context.string_of_task __context in
Expand Down
9 changes: 8 additions & 1 deletion ocaml/xapi/xapi_vm_migrate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1603,8 +1603,15 @@ let migrate_send' ~__context ~vm ~dest ~live:_ ~vdi_map ~vif_map ~vgpu_map
XenAPI.VM.set_ha_always_run ~rpc:remote.rpc ~session_id:remote.session
~self:new_vm ~value:true ;
(* Send non-database metadata *)
Xapi_message.send_messages ~__context ~cls:`VM ~obj_uuid:vm_uuid
let messages =
Xapi_message.get ~__context ~cls:`VM ~obj_uuid:vm_uuid
~since:(Date.of_float 0.0)
in
Xapi_message.send_messages ~__context ~cls:`VM ~obj_uuid:vm_uuid ~messages
~session_id:remote.session ~remote_address:remote.remote_master_ip ;
(* CA-365059: Remove messages since they've already been copied to the destination pool *)
let message_refs = List.rev_map fst messages in
Xapi_message.destroy_many ~__context ~messages:message_refs ;
Xapi_blob.migrate_push ~__context ~rpc:remote.rpc
~remote_address:remote.remote_master_ip ~session_id:remote.session
~old_vm:vm ~new_vm
Expand Down

0 comments on commit 5341a83

Please sign in to comment.