Skip to content

Commit 1e6f918

Browse files
committed
CP-49147: Reduce size of the pool record (uefi_certificates)
This field is very big and part of every pool.get_all_records() call (done by SM), which is currently >64KiB in size. TODO: the Changed field needs to match the (future!) tag that this will receive. Signed-off-by: Edwin Török <[email protected]>
1 parent 83f4517 commit 1e6f918

File tree

9 files changed

+35
-8
lines changed

9 files changed

+35
-8
lines changed

ocaml/idl/datamodel_common.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ open Datamodel_roles
1010
to leave a gap for potential hotfixes needing to increment the schema version.*)
1111
let schema_major_vsn = 5
1212

13-
let schema_minor_vsn = 785
13+
let schema_minor_vsn = 786
1414

1515
(* Historical schema versions just in case this is useful later *)
1616
let rio_schema_major_vsn = 5

ocaml/idl/datamodel_pool.ml

+18-1
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,18 @@ let disable_repository_proxy =
13771377
~allowed_roles:(_R_POOL_OP ++ _R_CLIENT_CERT)
13781378
()
13791379

1380+
let get_uefi_certificates =
1381+
call ~name:"get_uefi_certificates"
1382+
~result:(String, "The UEFI certificates")
1383+
~lifecycle:
1384+
[
1385+
(Published, "22.16.0", "")
1386+
; (Changed, "24.38.0", "internal type changed to blob")
1387+
]
1388+
~doc:"Get the UEFI certificates for a pool"
1389+
~params:[(Ref _pool, "self", "The pool")]
1390+
~allowed_roles:_R_POOL_ADMIN ()
1391+
13801392
let set_uefi_certificates =
13811393
call ~name:"set_uefi_certificates"
13821394
~lifecycle:
@@ -1620,6 +1632,7 @@ let t =
16201632
; disable_client_certificate_auth
16211633
; configure_repository_proxy
16221634
; disable_repository_proxy
1635+
; get_uefi_certificates
16231636
; set_uefi_certificates
16241637
; set_custom_uefi_certificates
16251638
; set_https_only
@@ -2006,9 +2019,13 @@ let t =
20062019
, "22.16.0"
20072020
, "Became StaticRO to be editable through new method"
20082021
)
2022+
; ( Changed
2023+
, "24.38.0"
2024+
, "Field converted to internal-only and replaced with a digest"
2025+
)
20092026
]
20102027
~default_value:(Some (VString "")) "uefi_certificates"
2011-
"The UEFI certificates allowing Secure Boot"
2028+
~internal_only:true "The UEFI certificates allowing Secure Boot"
20122029
; field ~qualifier:StaticRO ~ty:String ~lifecycle:[]
20132030
~default_value:(Some (VString "")) "custom_uefi_certificates"
20142031
"Custom UEFI certificates allowing Secure Boot"

ocaml/idl/json_backend/gen_json.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,8 @@ module Version = struct
613613
try Scanf.sscanf name "%d.%d.%d%s" of_chunks
614614
with _ ->
615615
failwith
616-
(Printf.sprintf "Version schema changed, please change this code %s"
617-
__LOC__
616+
(Printf.sprintf "Version schema changed, please change this code %s: %s"
617+
name __LOC__
618618
)
619619

620620
let to_name_date (lst, str) =

ocaml/idl/schematest.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ let hash x = Digest.string x |> Digest.to_hex
33
(* BEWARE: if this changes, check that schema has been bumped accordingly in
44
ocaml/idl/datamodel_common.ml, usually schema_minor_vsn *)
55

6-
let last_known_schema_hash = "18df8c33434e3df1982e11ec55d1f3f8"
6+
let last_known_schema_hash = "b868d0553a0f37cede3bc454104d66e1"
77

88
let current_schema_hash : string =
99
let open Datamodel_types in

ocaml/xapi-cli-server/records.ml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,9 @@ let pool_record rpc session_id pool =
13541354
)
13551355
()
13561356
; make_field ~name:"uefi-certificates" ~hidden:true
1357-
~get:(fun () -> (x ()).API.pool_uefi_certificates)
1357+
~get:(fun () ->
1358+
Client.Pool.get_uefi_certificates ~rpc ~session_id ~self:pool
1359+
)
13581360
~set:(fun value ->
13591361
Client.Pool.set_uefi_certificates ~rpc ~session_id ~self:pool ~value
13601362
)

ocaml/xapi/helpers.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,8 @@ let get_active_uefi_certificates ~__context ~self =
21412141
in
21422142
match (!Xapi_globs.allow_custom_uefi_certs, custom_uefi_certs) with
21432143
| false, _ | true, "" ->
2144-
Db.Pool.get_uefi_certificates ~__context ~self
2144+
let master = Db.Pool.get_master ~__context ~self in
2145+
Db.Host.get_uefi_certificates ~__context ~self:master
21452146
| true, _ ->
21462147
custom_uefi_certs
21472148

ocaml/xapi/xapi_host.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2778,7 +2778,7 @@ let write_uefi_certificates_to_disk ~__context ~host =
27782778
if Pool_role.is_master () then
27792779
Db.Pool.set_uefi_certificates ~__context
27802780
~self:(Helpers.get_pool ~__context)
2781-
~value:disk_uefi_certs_tar ;
2781+
~value:(Digest.string disk_uefi_certs_tar |> Digest.to_hex) ;
27822782
let pool_uefi_certs =
27832783
Db.Pool.get_custom_uefi_certificates ~__context
27842784
~self:(Helpers.get_pool ~__context)

ocaml/xapi/xapi_pool.ml

+5
Original file line numberDiff line numberDiff line change
@@ -3722,6 +3722,11 @@ let disable_repository_proxy ~__context ~self =
37223722
Db.Secret.destroy ~__context ~self:old_secret_ref
37233723
)
37243724

3725+
let get_uefi_certificates ~__context ~self =
3726+
(* cyclic dependency with Helpers, do it inline *)
3727+
let master = Db.Pool.get_master ~__context ~self in
3728+
Db.Host.get_uefi_certificates ~__context ~self:master
3729+
37253730
let set_uefi_certificates ~__context ~self:_ ~value:_ =
37263731
let msg =
37273732
"Setting UEFI certificates is deprecated, please use \

ocaml/xapi/xapi_pool.mli

+2
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ val configure_repository_proxy :
386386

387387
val disable_repository_proxy : __context:Context.t -> self:API.ref_pool -> unit
388388

389+
val get_uefi_certificates : __context:Context.t -> self:API.ref_pool -> string
390+
389391
val set_uefi_certificates :
390392
__context:Context.t -> self:API.ref_pool -> value:string -> unit
391393

0 commit comments

Comments
 (0)