CA-339237: Show more information in XenCenter's logs on why a patch or update may have failed to apply.

Also, ensure the Failure.ErrorDescription property is always initialised.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2020-05-05 15:42:38 +01:00
parent 811d142cf1
commit 64aa4e730b
3 changed files with 25 additions and 7 deletions

View File

@ -133,8 +133,17 @@ namespace XenAdmin.Actions
Description = string.Format(Messages.APPLYING_PATCH, patch.Name(), host.Name());
log.DebugFormat("Applying update '{0}' to server '{1}'", patch.Name(), host.Name());
RelatedTask = Pool_patch.async_apply(Session, patchRef, host.opaque_ref);
PollToCompletion();
try
{
RelatedTask = Pool_patch.async_apply(Session, patchRef, host.opaque_ref);
PollToCompletion();
}
catch (Failure f)
{
log.ErrorFormat("Failed to apply patch '{0}' on server '{1}': '{2}'",
patch.Name(), host.Name(), string.Join(", ", f.ErrorDescription)); //CA-339237
throw;
}
log.DebugFormat("Applied update '{0}' to server '{1}'. Result: {2}.", patch.Name(), host.Name(), Result);
Description = string.Format(Messages.PATCH_APPLIED, patch.Name(), host.Name());

View File

@ -67,15 +67,23 @@ namespace XenAdmin.Actions
if (poolUpdate == null)
throw new Failure(Failure.INTERNAL_ERROR, Messages.POOL_UPDATE_GONE);
if (!poolUpdate.AppliedOn(host))
if (poolUpdate.AppliedOn(host))
{
Description = string.Format(Messages.PATCH_APPLIED_ALREADY, update.Name(), host.Name());
return;
}
try
{
RelatedTask = Pool_update.async_apply(Session, poolUpdate.opaque_ref, host.opaque_ref);
PollToCompletion();
Description = string.Format(Messages.PATCH_APPLIED, update.Name(), host.Name());
}
else
catch (Failure f)
{
Description = string.Format(Messages.PATCH_APPLIED_ALREADY, update.Name(), host.Name());
log.ErrorFormat("Failed to apply update '{0}' on server '{1}': '{2}'",
update.Name(), host.Name(), string.Join(", ", f.ErrorDescription)); //CA-339237
throw;
}
}
}

View File

@ -48,7 +48,7 @@ namespace XenAPI
private static ResourceManager errorDescriptions = FriendlyErrorNames.ResourceManager;
private readonly List<string> errorDescription;
private readonly List<string> errorDescription = new List<string>();
private string errorText;
private string shortError;
@ -69,7 +69,8 @@ namespace XenAPI
#region Constructors
public Failure() : base() { }
public Failure()
{}
public Failure(params string[] err)
: this(new List<string>(err))