From d7060cbdb18d48811a8676d394044a53709d18de Mon Sep 17 00:00:00 2001 From: Callum McIntyre Date: Tue, 8 Nov 2016 15:31:35 +0000 Subject: [PATCH 1/2] [CA-228723] Cancelling update installation leaves the update in xapi db Modify the cleanup pool update action to also call update destroy (removing the update from xapi db) when the update has not been applied to any hosts (ie we cancelled the wizard before completion). --- .../Wizards/PatchingWizard/PatchingWizard.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard.cs index f4273b4f1..02a4fb38a 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard.cs @@ -380,16 +380,28 @@ namespace XenAdmin.Wizards.PatchingWizard { if (PatchingWizard_UploadPage.AllIntroducedPoolUpdates != null && PatchingWizard_UploadPage.AllIntroducedPoolUpdates.Count > 0) { - return PatchingWizard_UploadPage.AllIntroducedPoolUpdates.Select(pu => GetCleanUpPoolUpdateAction(pu)).ToList(); + return PatchingWizard_UploadPage.AllIntroducedPoolUpdates.Select(GetCleanUpPoolUpdateAction).ToList(); } return new List(); } - private AsyncAction GetCleanUpPoolUpdateAction(Pool_update poolUpdate) + private static AsyncAction GetCleanUpPoolUpdateAction(Pool_update poolUpdate) { return - new DelegatedAsyncAction(poolUpdate.Connection, Messages.REMOVE_PATCH, "", "", session => Pool_update.pool_clean(session, poolUpdate.opaque_ref)); + new DelegatedAsyncAction(poolUpdate.Connection, Messages.REMOVE_PATCH, "", "", session => + { + try + { + Pool_update.pool_clean(session, poolUpdate.opaque_ref); + if(!poolUpdate.AppliedOnHosts.Any()) + Pool_update.async_destroy(session, poolUpdate.opaque_ref); + } + catch (Failure f) + { + log.Error("Clean up failed", f); + } + }); } } } From 638d8fe9e6f9fcef3d5d384214e0fd3d61bd26fe Mon Sep 17 00:00:00 2001 From: Callum McIntyre Date: Wed, 9 Nov 2016 16:32:16 +0000 Subject: [PATCH 2/2] [CA-228723] Use sync destroy method in the cleanup action --- XenAdmin/Wizards/PatchingWizard/PatchingWizard.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard.cs index 02a4fb38a..68fa61ab8 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard.cs @@ -395,7 +395,7 @@ namespace XenAdmin.Wizards.PatchingWizard { Pool_update.pool_clean(session, poolUpdate.opaque_ref); if(!poolUpdate.AppliedOnHosts.Any()) - Pool_update.async_destroy(session, poolUpdate.opaque_ref); + Pool_update.destroy(session, poolUpdate.opaque_ref); } catch (Failure f) {