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-41279: add migration_compression pool option #4864

Merged
merged 1 commit into from
Dec 7, 2022
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
2 changes: 1 addition & 1 deletion ocaml/idl/datamodel_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ open Datamodel_roles
to leave a gap for potential hotfixes needing to increment the schema version.*)
let schema_major_vsn = 5

let schema_minor_vsn = 756
let schema_minor_vsn = 757

(* Historical schema versions just in case this is useful later *)
let rio_schema_major_vsn = 5
Expand Down
2 changes: 2 additions & 0 deletions ocaml/idl/datamodel_lifecycle.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ let prototyped_of_field = function
Some "22.27.0"
| "host", "last_software_update" ->
Some "22.20.0"
| "pool", "migration_compression" ->
Some "22.32.0-next"
| _ ->
None

Expand Down
4 changes: 4 additions & 0 deletions ocaml/idl/datamodel_pool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,10 @@ let t =
~default_value:(Some (VRef null_ref)) "repository_proxy_password"
"Password for the authentication of the proxy used in syncing with \
the enabled repositories"
; field ~qualifier:RW ~lifecycle:[] ~ty:Bool
~default_value:(Some (VBool false)) "migration_compression"
"Default behaviour during migration, True if stream compression \
should be used"
]
)
()
2 changes: 1 addition & 1 deletion ocaml/idl/schematest.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
let hash x = Digest.string x |> Digest.to_hex

(* BEWARE: if this changes, check that schema has been bumped accordingly *)
let last_known_schema_hash = "39db2a6a38076fdb59070df945072b81"
let last_known_schema_hash = "6d806eaf5515ca87daf909d3407a228f"

let current_schema_hash : string =
let open Datamodel_types in
Expand Down
7 changes: 4 additions & 3 deletions ocaml/tests/common/test_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ let make_pool ~__context ~master ?(name_label = "") ?(name_description = "")
?(uefi_certificates = "") ?(repositories = [])
?(client_certificate_auth_enabled = false)
?(client_certificate_auth_name = "") ?(repository_proxy_url = "")
?(repository_proxy_username = "") ?(repository_proxy_password = Ref.null) ()
=
?(repository_proxy_username = "") ?(repository_proxy_password = Ref.null)
?(migration_compression = false) () =
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 @@ -299,7 +299,8 @@ let make_pool ~__context ~master ?(name_label = "") ?(name_description = "")
~live_patching_disabled ~uefi_certificates ~is_psr_pending:false
~tls_verification_enabled:false ~repositories
~client_certificate_auth_enabled ~client_certificate_auth_name
~repository_proxy_url ~repository_proxy_username ~repository_proxy_password ;
~repository_proxy_url ~repository_proxy_username ~repository_proxy_password
~migration_compression ;
pool_ref

let default_sm_features =
Expand Down
9 changes: 9 additions & 0 deletions ocaml/xapi-cli-server/records.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,15 @@ let pool_record rpc session_id pool =
~value:(Stdlib.bool_of_string s)
)
()
; make_field ~name:"migration-compression"
~get:(fun () ->
(x ()).API.pool_migration_compression |> string_of_bool
)
~set:(fun x ->
Client.Pool.set_migration_compression ~rpc ~session_id ~self:pool
~value:(bool_of_string x)
)
()
]
}

Expand Down
2 changes: 1 addition & 1 deletion ocaml/xapi/dbsync_master.ml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ let create_pool_record ~__context =
~tls_verification_enabled:false ~repositories:[]
~client_certificate_auth_enabled:false ~client_certificate_auth_name:""
~repository_proxy_url:"" ~repository_proxy_username:""
~repository_proxy_password:Ref.null
~repository_proxy_password:Ref.null ~migration_compression:false

let set_master_ip ~__context =
let ip =
Expand Down
7 changes: 0 additions & 7 deletions ocaml/xapi/xapi_globs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -924,8 +924,6 @@ let repository_gpgkey_name = ref ""

let repository_gpgcheck = ref true

let migration_compression = ref false

let ignore_vtpm_unimplemented = ref false

let evacuation_batch_size = ref 10
Expand Down Expand Up @@ -1380,11 +1378,6 @@ let other_options =
, (fun () -> string_of_int !message_limit)
, "Maximum number of messages kept before deleting oldest ones."
)
; ( "migration-compression"
, Arg.Set migration_compression
, (fun () -> string_of_bool !migration_compression)
, "Use compression during VM migration when no API option provided."
)
; ( "evacuation-batch-size"
, Arg.Set_int evacuation_batch_size
, (fun () -> string_of_int !evacuation_batch_size)
Expand Down
11 changes: 7 additions & 4 deletions ocaml/xapi/xapi_vm_migrate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ let get_bool_option key values =

(** Decide whether to use stream compression during migration based on
options passed to the API, localhost, and destination *)
let use_compression options src dst =
let use_compression ~__context options src dst =
debug "%s: options=%s" __FUNCTION__
(String.concat ", "
(List.map (fun (k, v) -> Printf.sprintf "%s:%s" k v) options)
Expand All @@ -91,7 +91,8 @@ let use_compression options src dst =
| None, true ->
false (* don't use for local migration *)
| None, _ ->
!Xapi_globs.migration_compression
let pool = Helpers.get_pool ~__context in
Db.Pool.get_migration_compression ~__context ~self:pool

let remote_of_dest ~__context dest =
let maybe_set_https url =
Expand Down Expand Up @@ -391,7 +392,7 @@ let pool_migrate ~__context ~vm ~host ~options =
~self:network ~host
in
let compress =
use_compression options (Helpers.get_localhost ~__context) host
use_compression ~__context options (Helpers.get_localhost ~__context) host
in
debug "%s using stream compression=%b" __FUNCTION__ compress ;
let ip = Http.Url.maybe_wrap_IPv6_literal address in
Expand Down Expand Up @@ -1160,7 +1161,9 @@ let migrate_send' ~__context ~vm ~dest ~live:_ ~vdi_map ~vif_map ~vgpu_map
(* Copy mode means we don't destroy the VM on the source host. We also don't
copy over the RRDs/messages *)
let copy = try bool_of_string (List.assoc "copy" options) with _ -> false in
let compress = use_compression options localhost remote.dest_host in
let compress =
use_compression ~__context options localhost remote.dest_host
in
debug "%s using stream compression=%b" __FUNCTION__ compress ;

(* The first thing to do is to create mirrors of all the disks on the remote.
Expand Down
3 changes: 0 additions & 3 deletions scripts/xapi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,6 @@ sm-plugins=ext nfs iscsi lvmoiscsi dummy file hba rawhba udev iso lvm lvmohba lv
# Path for the firewall-port-config script
# firewall_port_config_script = /etc/xapi.d/plugins/firewall-port

# migration-compression = true
# if not requested otherwise, use stream compression during migration of a VM

# evacuation-batch-size = 10
# number of VMs migrated in parallel in Host.evacuate

Expand Down