Skip to content

Commit 63988de

Browse files
fillzerogaborigloi
authored andcommitted
CA-226000: Old patches are not removed on Host Upgrade
Remove any pool_patch objects that don't have a corresponding pool_update object Signed-off-by: Liang Dai <[email protected]>
1 parent f49f868 commit 63988de

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

ocaml/xapi/xapi_pool_update.ml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,17 @@ let resync_host ~__context ~host =
445445
) update_refs;
446446
Create_misc.create_updates_requiring_reboot_info ~__context ~host
447447
end
448-
else Db.Host.set_updates ~__context ~self:host ~value:[]
448+
else Db.Host.set_updates ~__context ~self:host ~value:[];
449+
450+
(* Remove any pool_patch objects that don't have a corresponding pool_update object *)
451+
Db.Pool_patch.get_all ~__context
452+
|> List.filter (fun self -> Db.Pool_patch.get_pool_update ~__context ~self = Ref.null)
453+
|> List.iter (fun self -> Db.Pool_patch.destroy ~__context ~self);
454+
455+
(* Clean updates that don't have a corresponding patch record *)
456+
Db.Pool_update.get_all ~__context
457+
|> List.filter (fun self -> Xapi_pool_patch.pool_patch_of_update ~__context self = Ref.null)
458+
|> List.iter (fun self -> destroy ~__context ~self)
449459

450460
let pool_update_download_handler (req: Request.t) s _ =
451461
debug "pool_update.pool_update_download_handler URL %s" req.Request.uri;

0 commit comments

Comments
 (0)