From cf123bdf1a959641947d195437af11102817e026 Mon Sep 17 00:00:00 2001 From: Gabor Apati-Nagy Date: Mon, 19 Dec 2016 18:46:35 +0000 Subject: [PATCH] CA-236566: test-hotfix-basic-7 throws error 'VDI is in use by some other operation' Remove the VDI only on a best effort basis if the upload failed in the UploadSupplementalPackAction. This will make XenCenter to display the message from the original exception and not from the removal action if the latter had also failed. Signed-off-by: Gabor Apati-Nagy --- .../UploadSupplementalPackAction.cs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/XenModel/Actions/SupplementalPack/UploadSupplementalPackAction.cs b/XenModel/Actions/SupplementalPack/UploadSupplementalPackAction.cs index 2715dfb15..a8934c7d3 100644 --- a/XenModel/Actions/SupplementalPack/UploadSupplementalPackAction.cs +++ b/XenModel/Actions/SupplementalPack/UploadSupplementalPackAction.cs @@ -164,10 +164,24 @@ namespace XenAdmin.Actions } catch (Exception ex) { - log.ErrorFormat("{0} {1}", "Failed to import a virtual disk over HTTP.", ex.Message); - if (vdiRef != null) - RemoveVDI(Session, vdiRef); - throw; + log.ErrorFormat("{0} {1}", "Failed to import a virtual disk over HTTP.", ex.Message); + + if (vdiRef != null) + { + log.DebugFormat("Removing the VDI on a best effort basis."); + + try + { + RemoveVDI(Session, vdiRef); + } + catch (Exception removeEx) + { + //best effort + log.Error("Failed to remove the VDI.", removeEx); + } + } + + throw ex; //after having tried to remove the VDI, the original exception is thrown for the UI } finally {