From c0c3c75828e407a7c09eb6ab8ff459f0e5b9edc8 Mon Sep 17 00:00:00 2001 From: Gang Ji <62988402+gangj@users.noreply.github.com> Date: Tue, 6 Feb 2024 18:10:08 +0800 Subject: [PATCH] CP-47012: change pending guidance in old xapi to recommended ones in 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 --- ocaml/idl/datamodel_common.ml | 6 +++++- ocaml/xapi/xapi_db_upgrade.ml | 34 ++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/ocaml/idl/datamodel_common.ml b/ocaml/idl/datamodel_common.ml index 00392141d76..709cb5eb059 100644 --- a/ocaml/idl/datamodel_common.ml +++ b/ocaml/idl/datamodel_common.ml @@ -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 @@ -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 = diff --git a/ocaml/xapi/xapi_db_upgrade.ml b/ocaml/xapi/xapi_db_upgrade.ml index cf8bc3f4c3b..05f20f083e7 100644 --- a/ocaml/xapi/xapi_db_upgrade.ml +++ b/ocaml/xapi/xapi_db_upgrade.ml @@ -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 @@ -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:[] ) ) } @@ -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 *)