Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CP-48011: Xapi Support anti-affinity feature flag #5666

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ocaml/xapi-types/features.ml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type feature =
| Updates
| Internal_repo_access
| VTPM
| VM_group
| VM_groups
[@@deriving rpc]

type orientation = Positive | Negative
Expand Down Expand Up @@ -133,7 +133,7 @@ let keys_of_features =
, ("restrict_internal_repo_access", Negative, "Internal_repo_access")
)
; (VTPM, ("restrict_vtpm", Negative, "VTPM"))
; (VM_group, ("restrict_vm_group", Negative, "VM_group"))
; (VM_groups, ("restrict_vm_groups", Negative, "VM_groups"))
]

(* A list of features that must be considered "enabled" by `of_assoc_list`
Expand Down
2 changes: 1 addition & 1 deletion ocaml/xapi-types/features.mli
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type feature =
| Internal_repo_access
(** Enable restriction on repository access to pool members only *)
| VTPM (** Support VTPM device required by Win11 guests *)
| VM_group (** Enable use of VM group *)
| VM_groups (** Enable use of VM groups *)

val feature_of_rpc : Rpc.t -> feature
(** Convert RPC into {!feature}s *)
Expand Down
13 changes: 10 additions & 3 deletions ocaml/xapi/xapi_ha_vm_failover.ml
Original file line number Diff line number Diff line change
Expand Up @@ -548,13 +548,20 @@ let compute_anti_aff_evac_plan ~__context total_hosts hosts vms =
)
in

match total_hosts with
| h when h < 3 ->
match
(Pool_features.is_enabled ~__context Features.VM_groups, total_hosts)
with
| _, h when h < 3 ->
debug
"There are less than 2 available hosts to migrate VMs to, \
anti-affinity evacuation plan is not needed." ;
binpack_plan ~__context config vms
| _ ->
| false, _ ->
debug
"VM groups feature is disabled, ignore VM anti-affinity during host \
evacuation" ;
binpack_plan ~__context config vms
| true, _ ->
let anti_aff_vms, non_anti_aff_vms = vms |> vms_partition ~__context in
let spread_evenly_plan_pool_state =
init_spread_evenly_plan_pool_state ~__context anti_aff_vms hosts
Expand Down
2 changes: 1 addition & 1 deletion ocaml/xapi/xapi_vm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ let set_appliance ~__context ~self ~value =
update_allowed_operations ~__context ~self

let set_groups ~__context ~self ~value =
Pool_features.assert_enabled ~__context ~f:Features.VM_group ;
Pool_features.assert_enabled ~__context ~f:Features.VM_groups ;
if
Db.VM.get_is_control_domain ~__context ~self
|| Db.VM.get_is_a_template ~__context ~self
Expand Down
2 changes: 1 addition & 1 deletion ocaml/xapi/xapi_vm_group.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
module D = Debug.Make (struct let name = "xapi_vm_group" end)

let create ~__context ~name_label ~name_description ~placement =
Pool_features.assert_enabled ~__context ~f:Features.VM_group ;
Pool_features.assert_enabled ~__context ~f:Features.VM_groups ;
let uuid = Uuidx.make () in
let ref = Ref.make () in
Db.VM_group.create ~__context ~ref ~uuid:(Uuidx.to_string uuid) ~name_label
Expand Down
6 changes: 3 additions & 3 deletions ocaml/xapi/xapi_vm_group_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ let update_vm_anti_affinity_alert_for_group ~__context ~group ~alerts =
()

let maybe_update_vm_anti_affinity_alert_for_vm ~__context ~vm =
if Pool_features.is_enabled ~__context Features.VM_group then
if Pool_features.is_enabled ~__context Features.VM_groups then
try
Db.VM.get_groups ~__context ~self:vm
|> List.filter (fun g ->
Expand Down Expand Up @@ -186,7 +186,7 @@ let update_alert ~__context ~groups ~action =
with e -> error "%s" (Printexc.to_string e)

let update_vm_anti_affinity_alert ~__context ~groups =
if Pool_features.is_enabled ~__context Features.VM_group then
if Pool_features.is_enabled ~__context Features.VM_groups then
update_alert ~__context ~groups
~action:update_vm_anti_affinity_alert_for_group
else
Expand All @@ -200,7 +200,7 @@ let maybe_update_alerts_on_feature_change ~__context ~old_restrictions
~new_restrictions =
try
let is_enabled restrictions =
List.mem Features.VM_group (Features.of_assoc_list restrictions)
List.mem Features.VM_groups (Features.of_assoc_list restrictions)
in
let groups = Db.VM_group.get_all ~__context in
match (is_enabled old_restrictions, is_enabled new_restrictions) with
Expand Down
2 changes: 1 addition & 1 deletion ocaml/xapi/xapi_vm_group_helpers.mli
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ val maybe_update_alerts_on_feature_change :
-> old_restrictions:(string * string) list
-> new_restrictions:(string * string) list
-> unit
(** Updates the VM anti-affinity alert only when Features.VM_group changes.
(** Updates the VM anti-affinity alert only when Features.VM_groups changes.

@param __context The context information.
@param old_restrictions The old feature restrictions represented as an association list.
Expand Down
2 changes: 1 addition & 1 deletion ocaml/xapi/xapi_vm_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ let vm_can_run_on_host ~__context ~vm ~snapshot ~do_memory_check host =
with _ -> false

let vm_has_anti_affinity ~__context ~vm =
if Pool_features.is_enabled ~__context Features.VM_group then
if Pool_features.is_enabled ~__context Features.VM_groups then
List.find_opt
(fun g -> Db.VM_group.get_placement ~__context ~self:g = `anti_affinity)
(Db.VM.get_groups ~__context ~self:vm)
Expand Down
Loading