Skip to content

Commit dcfe7c3

Browse files
committed
Cleanup trusted on ejected host
Signed-off-by: Ming Lu <ming.lu@cloud.com>
1 parent d834cf4 commit dcfe7c3

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

ocaml/xapi/certificates.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,3 +571,11 @@ let name_of_uuid uuid = Printf.sprintf "%s.pem" uuid
571571
572572
let db_type_of_category category =
573573
match category with `Root -> `ca | `Pinned -> `pinned
574+
575+
let cleanup_all_trusted () =
576+
let ( let* ) l f = List.iter f l in
577+
let* kind = all_trusted_kinds in
578+
let* store = trusted_store_locations kind in
579+
Unixext.rm_rec ~rm_top:false store.cert_dir ;
580+
Unixext.unlink_safe (store.bundle_dir // store.bundle_name) ;
581+
()

ocaml/xapi/certificates.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ val sync_all_hosts : __context:Context.t -> API.ref_host list -> unit
7070

7171
val db_type_of_category : [`Root | `Pinned] -> [`ca | `pinned]
7272

73+
val cleanup_all_trusted : unit -> unit
74+
7375
(* Database manipulation *)
7476

7577
module Db_util : sig

ocaml/xapi/xapi_pool.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,6 +2385,7 @@ let eject_self ~__context ~host =
23852385
Unixext.unlink_safe Xapi_globs.db_temporary_restore_path ;
23862386
Unixext.unlink_safe Db_globs.ha_metadata_db ;
23872387
Unixext.unlink_safe Db_globs.gen_metadata_db ;
2388+
Certificates.cleanup_all_trusted () ;
23882389
(* If we've got local storage, remove it *)
23892390
if Helpers.local_storage_exists () then (
23902391
ignore

0 commit comments

Comments
 (0)