Skip to content

Commit 2b735a2

Browse files
authored
CA-417951: Migration and detecting RPU checks (#6698)
While attempting to improve these checks in #6655, this caused the system to detect false positives for detecting RPU. This splits the logic between RPU and migration version checks.
2 parents 1f32e4b + d08b39a commit 2b735a2

17 files changed

+214
-161
lines changed

ocaml/idl/datamodel_host.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,13 @@ let create_params =
13911391
; param_release= numbered_release "25.32.0"
13921392
; param_default= Some (VBool false)
13931393
}
1394+
; {
1395+
param_type= Map (String, String)
1396+
; param_name= "software_version"
1397+
; param_doc= "Information about the software versions on the host"
1398+
; param_release= numbered_release "25.32.0-next"
1399+
; param_default= Some (VMap [])
1400+
}
13941401
]
13951402

13961403
let create =

ocaml/tests/common/test_common.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ let make_host ~__context ?(uuid = make_uuid ()) ?(name_label = "host")
181181
~local_cache_sr ~chipset_info ~ssl_legacy ~last_software_update
182182
~last_update_hash ~ssh_enabled ~ssh_enabled_timeout ~ssh_expiry
183183
~console_idle_timeout ~ssh_auto_mode ~secure_boot
184+
~software_version:(Xapi_globs.software_version ())
184185
in
185186
Db.Host.set_cpu_info ~__context ~self:host ~value:default_cpu_info ;
186187
host

ocaml/tests/test_helpers.ml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ module Version = struct
510510
]
511511
in
512512
let test_version_numbers (description, version_string, expected) =
513-
let actual = Helpers.version_numbers_of_string version_string in
513+
let actual = Helpers.Checks.version_numbers_of_string version_string in
514514
let description =
515515
Printf.sprintf "version_numbers_of_string: %s" description
516516
in
@@ -553,13 +553,15 @@ module Version = struct
553553
]
554554
in
555555
let test_compare (description, key, value_a, value_b, expected) =
556-
let actual = Helpers.compare_versions ~version_key:key value_a value_b in
556+
let actual =
557+
Helpers.Checks.compare_versions ~version_key:key value_a value_b
558+
in
557559
let description = Printf.sprintf "compare_versions: %s" description in
558560
Alcotest.(check int) description expected actual
559561
in
560562
List.iter test_compare test_cases
561563

562-
let test_compare_all_versions () =
564+
let test_compare_all_versions_migration () =
563565
let current =
564566
Xapi_globs.[(_platform_version, "8.1.0"); (_xen_version, "4.13.0-15")]
565567
in
@@ -580,7 +582,8 @@ module Version = struct
580582
in
581583
let test_compare (description, vers_a, vers_b, expected) =
582584
let actual =
583-
Helpers.compare_all_versions ~is_greater_or_equal:vers_a ~than:vers_b
585+
Helpers.Checks.Migration.compare_all_versions
586+
~is_greater_or_equal:vers_a ~than:vers_b
584587
in
585588
let description = Printf.sprintf "compare_all_versions: %s" description in
586589
Alcotest.(check bool) description expected actual
@@ -592,7 +595,10 @@ module Version = struct
592595
("Compare int list", `Quick, test_compare_int_list)
593596
; ("Version numbers from string", `Quick, test_version_numbers_of_string)
594597
; ("Compare versions", `Quick, test_compare_versions)
595-
; ("Compare all versions", `Quick, test_compare_all_versions)
598+
; ( "Compare all versions for migration"
599+
, `Quick
600+
, test_compare_all_versions_migration
601+
)
596602
]
597603

598604
let tests = [("Version compare tests", test)]

ocaml/tests/test_host.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ let add_host __context name =
2626
~last_software_update:Clock.Date.epoch ~last_update_hash:""
2727
~ssh_enabled:true ~ssh_enabled_timeout:0L ~ssh_expiry:Clock.Date.epoch
2828
~console_idle_timeout:0L ~ssh_auto_mode:false ~secure_boot:false
29+
~software_version:(Xapi_globs.software_version ())
2930
)
3031

3132
(* Creates an unlicensed pool with the maximum number of hosts *)

ocaml/xapi/create_misc.ml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,6 @@ let create_root_user ~__context =
434434
if all = [] then
435435
Db.User.create ~__context ~ref ~fullname ~short_name ~uuid ~other_config:[]
436436

437-
let get_xapi_verstring () =
438-
Printf.sprintf "%d.%d" Xapi_version.xapi_version_major
439-
Xapi_version.xapi_version_minor
440-
441437
(** Create assoc list of Supplemental-Pack information.
442438
* The package information is taking from the [XS-REPOSITORY] XML file in the package
443439
* directory.
@@ -531,8 +527,7 @@ let make_software_version ~__context host_info =
531527
Xapi_globs.software_version ()
532528
@ v6_version
533529
@ [
534-
(Xapi_globs._xapi_version, get_xapi_verstring ())
535-
; ("xapi_build", Xapi_version.version)
530+
("xapi_build", Xapi_version.version)
536531
; ("xen", Option.value ~default:"(unknown)" host_info.xen_verstring)
537532
; ("linux", host_info.linux_verstring)
538533
; ("xencenter_min", Xapi_globs.xencenter_min_verstring)

ocaml/xapi/db_gc.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ let detect_rolling_upgrade ~__context =
149149
(* NB: it is critical this code runs once in the master of a pool of one before the dbsync, since this
150150
is the only time at which the master's Version will be out of sync with its database record *)
151151
let actually_in_progress =
152-
Helpers.pool_has_different_host_platform_versions ~__context
152+
Helpers.Checks.RPU.pool_has_different_host_platform_versions ~__context
153153
in
154154
(* Check the current state of the Pool as indicated by the Pool.other_config:rolling_upgrade_in_progress *)
155155
let pools = Db.Pool.get_all ~__context in
@@ -168,9 +168,9 @@ let detect_rolling_upgrade ~__context =
168168
let host_versions =
169169
List.map
170170
(fun host ->
171-
Helpers.get_software_versions ~__context
171+
Helpers.Checks.RPU.get_software_versions ~__context
172172
(Helpers.LocalObject host)
173-
|> Helpers.versions_string_of
173+
|> Helpers.Checks.versions_string_of
174174
)
175175
(Db.Host.get_all ~__context)
176176
in

ocaml/xapi/dbsync_slave.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ let create_localhost ~__context info =
6565
~ssh_expiry:Date.epoch
6666
~console_idle_timeout:Constants.default_console_idle_timeout
6767
~ssh_auto_mode:!Xapi_globs.ssh_auto_mode_default
68-
~secure_boot:false
68+
~secure_boot:false ~software_version:[]
6969
in
7070
()
7171

0 commit comments

Comments
 (0)