Skip to content

Merge feature/vm-anti-affinity to master #5765

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c0aedf9
CP-47304: [Toolstack] - Add data model for anti-affinity group
BengangY Apr 18, 2024
92d51d8
UT - CP-47655: [Toolstack] - Associate/disassociate VM to/from anti-a…
BengangY Apr 18, 2024
55a5916
Merge pull request #5546 from BengangY/private/bengangy/CP-47304
robhoes Apr 18, 2024
2c920ed
CA-391880: Update related field 'groups' of VM when destroying VM group.
BengangY Apr 19, 2024
81a05a0
Merge pull request #5573 from BengangY/private/bengangy/CA-391880
robhoes Apr 22, 2024
1425790
CP-47302: VM start with anti-affinity
BengangY Apr 25, 2024
0de00ba
CP-47302: UT for VM start with anti-affinity
BengangY Apr 25, 2024
aeac4cc
Merge pull request #5577 from BengangY/private/bengangy/CP-47302
robhoes Apr 25, 2024
a77d149
Merge branch 'master' into feature/vm-anti-affinity
Apr 26, 2024
8a6c4c8
Merge pull request #5594 from gangj/feature/vm-anti-affinity
robhoes Apr 26, 2024
506fb31
CA-392177: Keep current group after reverting from snapshot
BengangY Apr 28, 2024
3bf62b7
Merge pull request #5598 from BengangY/private/bengangy/CA-392177
robhoes Apr 29, 2024
b9ae796
Merge branch 'master' into feature/vm-anti-affinity
May 1, 2024
8505ed1
Merge pull request #5607 from gangj/feature/vm-anti-affinity
robhoes May 1, 2024
69c8aaf
CP-47656 Anti-affinity feature - resolve cycle dependency issue
LunfanZhang Apr 29, 2024
22259d0
CP-47656 Anti-affinity feature generate alert
LunfanZhang Apr 29, 2024
da8ad7f
Merge pull request #5605 from LunfanZhang/private/luzhan_official/CP-…
gangj May 13, 2024
ab19a9c
CP-48570: Add a field 'recommendations' in pool
BengangY May 21, 2024
1f9d39e
CP-48570: Load recommendations from config file when Xapi starts
BengangY May 21, 2024
d03febe
Merge pull request #5637 from BengangY/private/bengangy/CP-48570
minglumlu May 23, 2024
606423e
CP-48011: Xapi Support anti-affinity feature flag
BengangY Apr 30, 2024
6529c0b
Merge pull request #5631 from BengangY/private/bengangy/CP-48011-review
minglumlu May 29, 2024
7fcef06
CA-393421: Special VMs cannot be added to VM groups
BengangY May 28, 2024
5a8614f
Merge branch 'master' into feature/vm-anti-affinity
May 30, 2024
3dc2b9e
Merge pull request #5658 from gangj/private/gangj/merge_from_master
robhoes May 30, 2024
1efaf1f
CP-48625: Code refactoring
May 16, 2024
d1316f1
CP-48625: Code refactoring
May 16, 2024
eaf7945
opam: add psq to xapi dependencies
May 23, 2024
6640b38
Merge pull request #5653 from BengangY/private/bengangy/CA-393421
robhoes May 30, 2024
25fa2eb
CP-49665: Anti-affinity support for host evacuation
May 16, 2024
fcbab2b
CP-48752: Update UT
Apr 2, 2024
c626cdb
CP-48752: Add UT for host evacuation with anti-affinity support
May 29, 2024
d9c6535
Merge pull request #5652 from gangj/private/gangj/CP-48625.Psq
minglumlu Jun 3, 2024
8a9074f
CP-48011: Xapi Support anti-affinity feature flag
BengangY Jun 3, 2024
de580e5
Merge pull request #5666 from BengangY/private/bengangy/CP-48011
robhoes Jun 3, 2024
6078991
Merge master into feature/vm-anti-affinity
BengangY Jun 19, 2024
6cd2d82
Merge pull request #5708 from BengangY/feature/vm-anti-affinity
psafont Jun 19, 2024
813b3b5
Merge branch 'master' into feature/vm-anti-affinity
BengangY Jul 2, 2024
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
3 changes: 3 additions & 0 deletions ocaml/idl/datamodel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7866,6 +7866,7 @@ let all_system =
; Datamodel_diagnostics.t
; Datamodel_repository.t
; Datamodel_observer.t
; Datamodel_vm_group.t
]

(* If the relation is one-to-many, the "many" nodes (one edge each) must come before the "one" node (many edges) *)
Expand Down Expand Up @@ -7946,6 +7947,7 @@ let all_relations =
; ((_network_sriov, "physical_PIF"), (_pif, "sriov_physical_PIF_of"))
; ((_network_sriov, "logical_PIF"), (_pif, "sriov_logical_PIF_of"))
; ((_certificate, "host"), (_host, "certificates"))
; ((_vm, "groups"), (_vm_group, "VMs"))
]

let update_lifecycles =
Expand Down Expand Up @@ -8077,6 +8079,7 @@ let expose_get_all_messages_for =
; _vmpp
; _vmss
; _vm_appliance
; _vm_group
; _pci
; _pgpu
; _gpu_group
Expand Down
2 changes: 2 additions & 0 deletions ocaml/idl/datamodel_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ let _vm_guest_metrics = "VM_guest_metrics"

let _vm_appliance = "VM_appliance"

let _vm_group = "VM_group"

let _dr_task = "DR_task"

let _vmpp = "VMPP"
Expand Down
2 changes: 2 additions & 0 deletions ocaml/idl/datamodel_errors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,8 @@ let _ =
error Api_errors.host_evacuation_is_required ["host"]
~doc:"Host evacuation is required before applying updates." () ;

error Api_errors.too_many_groups [] ~doc:"VM can only belong to one group." () ;

message
(fst Api_messages.ha_pool_overcommitted)
~doc:
Expand Down
5 changes: 5 additions & 0 deletions ocaml/idl/datamodel_pool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,11 @@ let t =
; field ~qualifier:DynamicRO ~lifecycle:[] ~ty:Bool
~default_value:(Some (VBool false)) "update_sync_enabled"
"Whether periodic update synchronization is enabled or not"
; field ~qualifier:DynamicRO ~lifecycle:[]
~ty:(Map (String, String))
~default_value:(Some (VMap [])) "recommendations"
"The recommended pool properties for clients to respect for \
optimal performance. e.g. max-vm-group=5"
]
)
()
13 changes: 13 additions & 0 deletions ocaml/idl/datamodel_vm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,16 @@ let set_appliance =
]
~allowed_roles:_R_POOL_OP ()

let set_groups =
call ~name:"set_groups" ~lifecycle:[] ~doc:"Associate this VM with VM groups."
~params:
[
(Ref _vm, "self", "The VM")
; (Set (Ref _vm_group), "value", "The VM groups to set")
]
~errs:[Api_errors.operation_not_allowed]
~allowed_roles:_R_VM_ADMIN ()

let call_plugin =
call ~name:"call_plugin" ~in_product_since:rel_cream
~doc:"Call an API plugin on this vm"
Expand Down Expand Up @@ -1887,6 +1897,7 @@ let t =
; recover
; import_convert
; set_appliance
; set_groups
; query_services
; call_plugin
; set_has_vendor_device
Expand Down Expand Up @@ -2218,6 +2229,8 @@ let t =
user should follow to make some updates, e.g. specific hardware \
drivers or CPU features, fully effective, but the 'average user' \
doesn't need to"
; field ~qualifier:DynamicRO ~lifecycle:[] ~ty:(Set (Ref _vm_group))
"groups" "VM groups associated with the VM"
]
)
()
43 changes: 43 additions & 0 deletions ocaml/idl/datamodel_vm_group.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
(*
* Copyright (c) Cloud Software Group, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; version 2.1 only. with the special
* exception on linking described in file LICENSE.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*)

open Datamodel_types
open Datamodel_common
open Datamodel_roles

let placement_policy =
Enum
( "placement_policy"
, [
("anti_affinity", "Anti-affinity placement policy")
; ("normal", "Default placement policy")
]
)

let t =
create_obj ~name:_vm_group ~descr:"A VM group" ~doccomments:[]
~gen_constructor_destructor:true ~gen_events:true ~in_db:true ~lifecycle:[]
~persist:PersistEverything ~in_oss_since:None
~messages_default_allowed_roles:_R_VM_ADMIN ~messages:[]
~contents:
[
uid _vm_group
; namespace ~name:"name" ~contents:(names None RW) ()
; field ~qualifier:StaticRO ~lifecycle:[] ~ty:placement_policy "placement"
~default_value:(Some (VEnum "normal"))
"The placement policy of the VM group"
; field ~qualifier:DynamicRO ~lifecycle:[] ~ty:(Set (Ref _vm)) "VMs"
"The list of VMs associated with the group"
]
()
2 changes: 1 addition & 1 deletion ocaml/idl/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
datamodel_pool datamodel_cluster datamodel_cluster_host dm_api escaping
datamodel_values datamodel_schema datamodel_certificate
datamodel_diagnostics datamodel_repository datamodel_lifecycle
datamodel_vtpm datamodel_observer)
datamodel_vtpm datamodel_observer datamodel_vm_group)
(libraries
ppx_sexp_conv.runtime-lib
rpclib.core
Expand Down
2 changes: 1 addition & 1 deletion ocaml/idl/schematest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let hash x = Digest.string x |> Digest.to_hex
(* BEWARE: if this changes, check that schema has been bumped accordingly in
ocaml/idl/datamodel_common.ml, usually schema_minor_vsn *)

let last_known_schema_hash = "e34cd0d32cdcec7805c2d3ed4e4a0c25"
let last_known_schema_hash = "efdb1c7e536362523741ccdb7f33f797"

let current_schema_hash : string =
let open Datamodel_types in
Expand Down
12 changes: 10 additions & 2 deletions ocaml/tests/common/test_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ let make_pool ~__context ~master ?(name_label = "") ?(name_description = "")
?(telemetry_uuid = Ref.null) ?(telemetry_frequency = `weekly)
?(telemetry_next_collection = API.Date.never)
?(last_update_sync = API.Date.epoch) ?(update_sync_frequency = `daily)
?(update_sync_day = 0L) ?(update_sync_enabled = false) () =
?(update_sync_day = 0L) ?(update_sync_enabled = false)
?(recommendations = []) () =
let pool_ref = Ref.make () in
Db.Pool.create ~__context ~ref:pool_ref ~uuid:(make_uuid ()) ~name_label
~name_description ~master ~default_SR ~suspend_image_SR ~crash_dump_SR
Expand All @@ -316,7 +317,7 @@ let make_pool ~__context ~master ?(name_label = "") ?(name_description = "")
~migration_compression ~coordinator_bias ~telemetry_uuid
~telemetry_frequency ~telemetry_next_collection ~last_update_sync
~local_auth_max_threads:8L ~ext_auth_max_threads:8L ~update_sync_frequency
~update_sync_day ~update_sync_enabled ;
~update_sync_day ~update_sync_enabled ~recommendations ;
pool_ref

let default_sm_features =
Expand Down Expand Up @@ -675,3 +676,10 @@ let make_observer ~__context ?(ref = Ref.make ()) ?(uuid = make_uuid ())
Db.Observer.create ~__context ~ref ~uuid ~name_label ~name_description ~hosts
~attributes ~endpoints ~components ~enabled ;
ref

let make_vm_group ~__context ?(ref = Ref.make ()) ?(uuid = make_uuid ())
?(name_label = "vm_group") ?(name_description = "") ?(placement = `normal)
() =
Db.VM_group.create ~__context ~ref ~uuid ~name_label ~name_description
~placement ;
ref
1 change: 1 addition & 0 deletions ocaml/tests/suite_alcotest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ let () =
; ("Test_storage_migrate_state", Test_storage_migrate_state.test)
; ("Test_bios_strings", Test_bios_strings.test)
; ("Test_certificates", Test_certificates.test)
; ("Test_vm_group", Test_vm_group.test)
]
@ Test_guest_agent.tests
@ Test_nm.tests
Expand Down
Loading
Loading