Skip to content

Commit

Permalink
update logging (xapi_ha_vm_failover.ml)
Browse files Browse the repository at this point in the history
Signed-off-by: Gang Ji <gang.ji@citrix.com>
  • Loading branch information
Gang Ji committed May 7, 2024
1 parent 4d51a2d commit daa9db6
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions ocaml/xapi/xapi_ha_vm_failover.ml
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ let rec vm_anti_affinity_spread_evenly_plan ~__context hosts_increasing
match Xapi_vm_helpers.vm_has_anti_affinity ~__context ~vm with
| Some (`AntiAffinity group) -> (
debug
"Spread evenly plan: try to plan for the anti-affinity VM (%s, %s)"
"Spread evenly plan: try to plan for the anti-affinity VM (%s %s)."
(Ref.string_of vm)
(Db.VM.get_name_label ~__context ~self:vm) ;
try
Expand All @@ -353,16 +353,15 @@ let rec vm_anti_affinity_spread_evenly_plan ~__context hosts_increasing
|> List.map snd
)
in
debug "Spread evenly plan: find h: (%s %s)" (Ref.string_of h)
(Db.Host.get_name_label ~__context ~self:h) ;
let h_size =
Int64.sub
(List.assoc h hosts_increasing)
(List.assoc vm vms_increasing)
in
debug
"Spread evenly plan: choose the host with the least free memory \
which can run the vm: %s"
which can run the vm: (%s %s)."
(Ref.string_of h)
(Db.Host.get_name_label ~__context ~self:h) ;

let hosts_increasing =
Expand Down Expand Up @@ -406,13 +405,13 @@ let rec vm_anti_affinity_no_breach_plan ~__context hosts_increasing
| (vm, vm_size) :: remaining_vms -> (
match Xapi_vm_helpers.vm_has_anti_affinity ~__context ~vm with
| Some (`AntiAffinity group) ->
debug "No breach plan: try to plan for VM (%s, %s)" (Ref.string_of vm)
debug "No breach plan: try to plan for VM (%s %s)." (Ref.string_of vm)
(Db.VM.get_name_label ~__context ~self:vm) ;
let no_resident_hosts =
let ranked_hosts =
try VMGroupMap.find group grp_ranked_hosts
with Not_found ->
error "Failed to find ranked_hosts in grp_ranked_hosts for group" ;
error "Failed to find ranked_hosts in grp_ranked_hosts for group." ;
raise Not_found
in
ranked_hosts |> IntMap.find_opt 0 |> Option.value ~default:[]
Expand Down Expand Up @@ -443,8 +442,8 @@ let rec vm_anti_affinity_no_breach_plan ~__context hosts_increasing
(List.assoc vm vms_increasing)
in
debug
"No breach plan: choose the host with the least free memory \
which can run the vm: %s"
"No breach plan: choose the no resident host with the least free \
memory which can run the vm: (%s)."
(Db.Host.get_name_label ~__context ~self:h) ;
let hosts_increasing =
Binpack.insert bigger_than (h, h_size)
Expand All @@ -457,12 +456,12 @@ let rec vm_anti_affinity_no_breach_plan ~__context hosts_increasing
((vm, h) :: mapping)
with _ ->
info
"No breach plan: failed to select host on any of [ %s ], \
continue for the next VM"
"No breach plan: failed to select host on any of the no resident \
hosts: [ %s ], continue for the next VM."
(String.concat ";"
(List.map
(fun (host, size) ->
"(" ^ Ref.string_of host ^ " " ^ Int64.to_string size
(fun (host, _) ->
Db.Host.get_name_label ~__context ~self:host
)
available_hosts_increasing
)
Expand Down

0 comments on commit daa9db6

Please sign in to comment.