Skip to content

Commit 30f97ff

Browse files
committed
CA-229331: evacuate: Don't report memory issues for unmigratable VMs.
Also, don't report more than one error per VM in Host.compute_evacuation_plan Signed-off-by: Jon Ludlam <[email protected]> (cherry picked from commit 64c1c9c)
1 parent 7c4fc42 commit 30f97ff

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ocaml/xapi/xapi_host.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ let compute_evacuation_plan_no_wlb ~__context ~host =
225225
then
226226
begin
227227
List.iter (fun (vm, _) ->
228-
Hashtbl.add plans vm (Error (Api_errors.no_hosts_available, [ Ref.string_of vm ])))
228+
Hashtbl.replace plans vm (Error (Api_errors.no_hosts_available, [ Ref.string_of vm ])))
229229
all_user_vms ;
230230
plans
231231
end
@@ -269,8 +269,8 @@ let compute_evacuation_plan_no_wlb ~__context ~host =
269269
let plan = Xapi_ha_vm_failover.compute_evacuation_plan ~__context (List.length all_hosts) target_hosts migratable_vms in
270270
(* Check if the plan was actually complete: if some VMs are missing it means there wasn't enough memory *)
271271
let vms_handled = List.map fst plan in
272-
let vms_missing = List.filter (fun x -> not(List.mem x vms_handled)) (List.map fst protected_vms) in
273-
List.iter (fun vm -> Hashtbl.add plans vm (Error (Api_errors.host_not_enough_free_memory, [ Ref.string_of vm ]))) vms_missing;
272+
let vms_missing = List.filter (fun x -> not(List.mem x vms_handled)) (List.map fst migratable_vms) in
273+
List.iter (fun vm -> Hashtbl.replace plans vm (Error (Api_errors.host_not_enough_free_memory, [ Ref.string_of vm ]))) vms_missing;
274274

275275
(* Now for each VM we did place, verify storage and network visibility. *)
276276
List.iter (fun (vm, host) ->
@@ -279,7 +279,7 @@ let compute_evacuation_plan_no_wlb ~__context ~host =
279279
try Xapi_vm_helpers.assert_can_boot_here ~__context ~self:vm ~host ~snapshot ~do_memory_check:false ()
280280
with (Api_errors.Server_error (code, params)) -> Hashtbl.replace plans vm (Error (code, params))
281281
end;
282-
if not(Hashtbl.mem plans vm) then Hashtbl.add plans vm (Migrate host)
282+
if not(Hashtbl.mem plans vm) then Hashtbl.replace plans vm (Migrate host)
283283
) plan;
284284
plans
285285
end

0 commit comments

Comments
 (0)