Skip to content

Commit

Permalink
CP-47012: change pending guidance in old xapi to recommended ones in …
Browse files Browse the repository at this point in the history
…new xapi

Add livepatch guidance DB upgrade rule: except
reboot_host_on_livepatch_failure, move any guidance in
"host.pending_guidances" into "host.pending_guidances_recommended".

Signed-off-by: Gang Ji <gang.ji@citrix.com>
  • Loading branch information
gangj authored Feb 6, 2024
1 parent 6942a4b commit c0c3c75
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
6 changes: 5 additions & 1 deletion ocaml/idl/datamodel_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,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 = 774
let schema_minor_vsn = 775

(* Historical schema versions just in case this is useful later *)
let rio_schema_major_vsn = 5
Expand Down Expand Up @@ -134,6 +134,10 @@ let yangtze_release_schema_major_vsn = 5

let yangtze_release_schema_minor_vsn = 602

let nile_release_schema_major_vsn = 5

let nile_release_schema_minor_vsn = 775

(* List of tech-preview releases. Fields in these releases are not guaranteed to be retained when
* upgrading to a full release. *)
let tech_preview_releases =
Expand Down
34 changes: 26 additions & 8 deletions ocaml/xapi/xapi_db_upgrade.ml
Original file line number Diff line number Diff line change
Expand Up @@ -859,14 +859,25 @@ let empty_pool_uefi_certificates =
)
}

let update_livepatch_guidance =
(* 1. Replace reboot_host_on_livepatch_failure in host.pending_guidances \
* with reboot_host_on_kernel_livepatch_failure and \
* reboot_host_on_xen_livepatch_failure in \
* host.pending_guidances_recommended.
* 2. Move the rest guidances in \
* host.pending_guidances into host.pending_guidances_recommended *)
let upgrade_update_guidance =
{
description=
"Replace reboot_host_on_livepatch_failure in host.pending_guidances with \
reboot_host_on_kernel_livepatch_failure and \
reboot_host_on_xen_livepatch_failure in \
host.pending_guidances_recommended"
; version= (fun _ -> true)
"Upgrade pending update gudiances"
(* TODO: update below schema version to which the feature branch got merged with *)
; version=
(fun x ->
x
< ( Datamodel_common.nile_release_schema_major_vsn
, Datamodel_common.nile_release_schema_minor_vsn
)
)
(* the version where update guidance improvement is made *)
; fn=
(fun ~__context ->
Db.Host.get_all ~__context
Expand All @@ -881,7 +892,14 @@ let update_livepatch_guidance =
~value:`reboot_host_on_xen_livepatch_failure ;
Db.Host.remove_pending_guidances ~__context ~self
~value:`reboot_host_on_livepatch_failure
)
) ;
List.iter
(fun g ->
Db.Host.add_pending_guidances_recommended ~__context ~self
~value:g
)
(Db.Host.get_pending_guidances ~__context ~self) ;
Db.Host.set_pending_guidances ~__context ~self ~value:[]
)
)
}
Expand Down Expand Up @@ -914,7 +932,7 @@ let rules =
; upgrade_secrets
; remove_legacy_ssl_support
; empty_pool_uefi_certificates
; update_livepatch_guidance
; upgrade_update_guidance
]

(* Maybe upgrade most recent db *)
Expand Down

0 comments on commit c0c3c75

Please sign in to comment.