mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 07:19:18 +01:00
CP-11135: Expand patch precheck to account for OUT_OF_SPACE exception
- Pool_patch.precheck can fail with the xapi error OUT_OF_SPACE when is trying to copy the patch from master to the slaves. This happens before the patch-precheck checks if enough space is available for installation. Therefore is different from the error we are currently processing, PATCH_PRECHECK_FAILED_OUT_OF_SPACE - If the precheck fails with OUT_OF_SPACE then we try and retrieve the disk space requirements and report a HostOutOfSpaceProblem. - Changed the PatchPrecheckCheck to try and find problem from a xapi failure, as well as from the result of the precheck call. - Also removed ampersand from the the link labels (More Info and Clean up) Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
parent
0f7e81d52c
commit
1a484b99ff
@ -38,6 +38,7 @@ using XenAdmin.Diagnostics.Problems.HostProblem;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
using System.Collections.Generic;
|
||||
using XenAdmin.Actions;
|
||||
|
||||
|
||||
namespace XenAdmin.Diagnostics.Checks
|
||||
@ -78,7 +79,7 @@ namespace XenAdmin.Diagnostics.Checks
|
||||
|
||||
try
|
||||
{
|
||||
return FindProblem(Pool_patch.precheck(session, Patch.opaque_ref, Host.opaque_ref), Host);
|
||||
return FindProblem(Pool_patch.precheck(session, Patch.opaque_ref, Host.opaque_ref));
|
||||
|
||||
}
|
||||
catch (Failure f)
|
||||
@ -90,7 +91,11 @@ namespace XenAdmin.Diagnostics.Checks
|
||||
log.Error(f.ErrorDescription[1]);
|
||||
if (f.ErrorDescription.Count > 2)
|
||||
log.Error(f.ErrorDescription[2]);
|
||||
return new PrecheckFailed(this,Host, f);
|
||||
if (f.ErrorDescription.Count > 3)
|
||||
log.Error(f.ErrorDescription[3]);
|
||||
// try and find problem from the xapi failure
|
||||
Problem problem = FindProblem(f);
|
||||
return problem ?? new PrecheckFailed(this, Host, f);
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +111,18 @@ namespace XenAdmin.Diagnostics.Checks
|
||||
|
||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private Problem FindProblem(string result, Host host)
|
||||
/// <summary>
|
||||
/// Find problem from xml result
|
||||
/// </summary>
|
||||
/// <param name="result">xml result, as returned by Pool_patch.precheck() call.
|
||||
/// E.g.:
|
||||
/// <error errorcode="PATCH_PRECHECK_FAILED_OUT_OF_SPACE">
|
||||
/// <found>2049859584</found>
|
||||
/// <required>10000000000</required>
|
||||
/// </error>
|
||||
/// </param>
|
||||
/// <returns>Problem or null, if no problem found</returns>
|
||||
private Problem FindProblem(string result)
|
||||
{
|
||||
if (!PrecheckErrorRegex.IsMatch(result.Replace("\n", "")))
|
||||
return null;
|
||||
@ -118,45 +134,75 @@ namespace XenAdmin.Diagnostics.Checks
|
||||
log.Error(m.ToString());
|
||||
XmlNode errorNode = doc.FirstChild;
|
||||
|
||||
string errorcode = errorNode.Attributes["errorcode"] != null
|
||||
string errorcode = errorNode.Attributes != null && errorNode.Attributes["errorcode"] != null
|
||||
? errorNode.Attributes["errorcode"].Value
|
||||
: string.Empty;
|
||||
|
||||
switch (errorcode)
|
||||
{
|
||||
case "PATCH_PRECHECK_FAILED_WRONG_SERVER_VERSION":
|
||||
foreach (XmlNode node in errorNode.ChildNodes)
|
||||
{
|
||||
if (node.Name == "required")
|
||||
{
|
||||
return new WrongServerVersion(this, node.InnerXml,host);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "PATCH_PRECHECK_FAILED_OUT_OF_SPACE":
|
||||
long required = 0;
|
||||
long found = 0;
|
||||
if (errorcode == "")
|
||||
return null;
|
||||
|
||||
var found = "";
|
||||
var required = "";
|
||||
|
||||
foreach (XmlNode node in errorNode.ChildNodes)
|
||||
{
|
||||
if (node.Name == "found")
|
||||
{
|
||||
long.TryParse(node.InnerText, out found);
|
||||
found = node.InnerXml;
|
||||
else if (node.Name == "required")
|
||||
required = node.InnerXml;
|
||||
}
|
||||
var problem = FindProblem(errorcode, found, required);
|
||||
return problem ?? new PrecheckFailed(this, Host, new Failure(errorcode));
|
||||
}
|
||||
|
||||
if (node.Name == "required")
|
||||
/// <summary>
|
||||
/// Find problem from xapi Failure
|
||||
/// </summary>
|
||||
/// <param name="failure">Xapi failure, thrown by Pool_patch.precheck() call.
|
||||
/// E.g.: failure.ErrorDescription.Count = 4
|
||||
/// ErrorDescription[0] = "PATCH_PRECHECK_FAILED_WRONG_SERVER_VERSION"
|
||||
/// ErrorDescription[1] = "OpaqueRef:612b5eee-03dc-bbf5-3385-6905fdc9b079"
|
||||
/// ErrorDescription[2] = "6.5.0"
|
||||
/// ErrorDescription[3] = "^6\\.2\\.0$"
|
||||
/// E.g.: failure.ErrorDescription.Count = 2
|
||||
/// ErrorDescription[0] = "OUT_OF_SPACE"
|
||||
/// ErrorDescription[1] = "/var/patch"
|
||||
/// </param>
|
||||
/// <returns>Problem or null, if no problem found</returns>
|
||||
private Problem FindProblem(Failure failure)
|
||||
{
|
||||
long.TryParse(node.InnerText, out required);
|
||||
}
|
||||
if (failure.ErrorDescription.Count == 0)
|
||||
return null;
|
||||
|
||||
var errorcode = failure.ErrorDescription[0];
|
||||
var found = "";
|
||||
var required = "";
|
||||
|
||||
if (failure.ErrorDescription.Count > 2)
|
||||
found = failure.ErrorDescription[2];
|
||||
if (failure.ErrorDescription.Count > 3)
|
||||
required = failure.ErrorDescription[3];
|
||||
|
||||
return FindProblem(errorcode, found, required);
|
||||
}
|
||||
|
||||
private Problem FindProblem(string errorcode, string found, string required)
|
||||
{
|
||||
switch (errorcode)
|
||||
{
|
||||
case "PATCH_PRECHECK_FAILED_WRONG_SERVER_VERSION":
|
||||
return new WrongServerVersion(this, required, Host);
|
||||
case "PATCH_PRECHECK_FAILED_OUT_OF_SPACE":
|
||||
long requiredSpace = 0;
|
||||
long foundSpace = 0;
|
||||
long.TryParse(found, out foundSpace);
|
||||
long.TryParse(required, out requiredSpace);
|
||||
// get reclaimable disk space (excluding current patch)
|
||||
long reclaimableDiskSpace = 0;
|
||||
try
|
||||
{
|
||||
var args = new Dictionary<string, string>();
|
||||
if (Patch != null)
|
||||
args.Add("exclude", Patch.uuid);
|
||||
var resultReclaimable = Host.call_plugin(host.Connection.Session, host.opaque_ref, "disk-space", "get_reclaimable_disk_space", args);
|
||||
var args = new Dictionary<string, string> { { "exclude", Patch.uuid } };
|
||||
var resultReclaimable = Host.call_plugin(Host.Connection.Session, Host.opaque_ref, "disk-space", "get_reclaimable_disk_space", args);
|
||||
reclaimableDiskSpace = Convert.ToInt64(resultReclaimable);
|
||||
}
|
||||
catch (Failure failure)
|
||||
@ -164,15 +210,25 @@ namespace XenAdmin.Diagnostics.Checks
|
||||
log.WarnFormat("Plugin call disk-space.get_reclaimable_disk_space on {0} failed with {1}", Host.Name, failure.Message);
|
||||
}
|
||||
|
||||
var operation = XenAdmin.Actions.DiskSpaceRequirements.OperationTypes.install;
|
||||
var diskSpaceReq = new DiskSpaceRequirements(DiskSpaceRequirements.OperationTypes.install, Host, Patch.Name, requiredSpace, foundSpace, reclaimableDiskSpace);
|
||||
|
||||
var diskSpaceReq = new XenAdmin.Actions.DiskSpaceRequirements(operation, host, Patch.Name, required, found, reclaimableDiskSpace);
|
||||
|
||||
return new HostOutOfSpaceProblem(this, host, Patch, diskSpaceReq);
|
||||
case "":
|
||||
return null;
|
||||
default:
|
||||
return new PrecheckFailed(this, host,new Failure(errorcode));
|
||||
return new HostOutOfSpaceProblem(this, Host, Patch, diskSpaceReq);
|
||||
case "OUT_OF_SPACE":
|
||||
//if (Helpers.CreamOrGreater(host.Connection))
|
||||
{
|
||||
var action = new GetDiskSpaceRequirementsAction(Host, Patch, true);
|
||||
try
|
||||
{
|
||||
action.RunExternal(action.Session);
|
||||
}
|
||||
catch
|
||||
{
|
||||
log.WarnFormat("Could not get disk space requirements");
|
||||
}
|
||||
if (action.Succeeded)
|
||||
return new HostOutOfSpaceProblem(this, Host, Patch, action.DiskSpaceRequirements);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -58,7 +58,12 @@ namespace XenAdmin.Diagnostics.Problems.HostProblem
|
||||
|
||||
public override string Description
|
||||
{
|
||||
get { return string.Format(Messages.NOT_ENOUGH_SPACE_MESSAGE_INSTALL, Server.Name, patch.Name); }
|
||||
get
|
||||
{
|
||||
return string.Format(diskSpaceReq.Operation == DiskSpaceRequirements.OperationTypes.install
|
||||
? Messages.NOT_ENOUGH_SPACE_MESSAGE_INSTALL
|
||||
: Messages.NOT_ENOUGH_SPACE_MESSAGE_UPLOAD, Server.Name, patch.Name);
|
||||
}
|
||||
}
|
||||
|
||||
protected override AsyncAction CreateAction(out bool cancelled)
|
||||
@ -75,7 +80,7 @@ namespace XenAdmin.Diagnostics.Problems.HostProblem
|
||||
diskSpaceReq.GetSpaceRequirementsMessage()),
|
||||
new ThreeButtonDialog.TBDButton(Messages.YES, DialogResult.Yes, ThreeButtonDialog.ButtonType.ACCEPT, true),
|
||||
ThreeButtonDialog.ButtonNo
|
||||
).ShowDialog(Program.MainWindow);
|
||||
).ShowDialog();
|
||||
|
||||
|
||||
if (r == DialogResult.Yes)
|
||||
@ -110,6 +115,5 @@ namespace XenAdmin.Diagnostics.Problems.HostProblem
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -93,9 +93,20 @@ namespace XenAdmin.Actions
|
||||
{
|
||||
Description = String.Format(Messages.ACTION_GET_DISK_SPACE_REQUIREMENTS_DESCRIPTION, Host.Name);
|
||||
|
||||
long requiredDiskSpace = updateSize;
|
||||
string result;
|
||||
|
||||
// get required disk space
|
||||
long requiredDiskSpace = updateSize;
|
||||
try
|
||||
{
|
||||
result = Host.call_plugin(Session, Host.opaque_ref, "disk-space", "get_required_space", new Dictionary<string, string>());
|
||||
requiredDiskSpace = Convert.ToInt64(result);
|
||||
}
|
||||
catch (Failure failure)
|
||||
{
|
||||
log.WarnFormat("Plugin call disk-space.get_required_space on {0} failed with {1}", Host.Name, failure.Message);
|
||||
}
|
||||
|
||||
// get available disk space
|
||||
long availableDiskSpace = 0;
|
||||
try
|
||||
@ -155,7 +166,7 @@ namespace XenAdmin.Actions
|
||||
|
||||
public bool CanCleanup
|
||||
{
|
||||
get { return ReclaimableDiskSpace + AvailableDiskSpace > RequiredDiskSpace && RequiredDiskSpace > 0; }
|
||||
get { return ReclaimableDiskSpace + AvailableDiskSpace > RequiredDiskSpace && RequiredDiskSpace > 0 && ReclaimableDiskSpace > 0; }
|
||||
}
|
||||
|
||||
public string GetSpaceRequirementsMessage()
|
||||
|
6
XenModel/Messages.Designer.cs
generated
6
XenModel/Messages.Designer.cs
generated
@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.34209
|
||||
// Runtime Version:4.0.30319.18444
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
@ -24567,7 +24567,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to &Clean up....
|
||||
/// Looks up a localized string similar to Clean up....
|
||||
/// </summary>
|
||||
public static string PATCHINGWIZARD_CLEANUP {
|
||||
get {
|
||||
@ -24639,7 +24639,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to &More info....
|
||||
/// Looks up a localized string similar to More info....
|
||||
/// </summary>
|
||||
public static string PATCHINGWIZARD_MORE_INFO {
|
||||
get {
|
||||
|
@ -8487,7 +8487,7 @@ It is strongly recommended that you Cancel and apply the latest version of the p
|
||||
<value>Paste</value>
|
||||
</data>
|
||||
<data name="PATCHINGWIZARD_CLEANUP" xml:space="preserve">
|
||||
<value>&Clean up...</value>
|
||||
<value>Clean up...</value>
|
||||
</data>
|
||||
<data name="PATCHINGWIZARD_MODEPAGE_NOACTION" xml:space="preserve">
|
||||
<value>No action required</value>
|
||||
@ -8511,7 +8511,7 @@ It is strongly recommended that you Cancel and apply the latest version of the p
|
||||
<value>Unknown</value>
|
||||
</data>
|
||||
<data name="PATCHINGWIZARD_MORE_INFO" xml:space="preserve">
|
||||
<value>&More info...</value>
|
||||
<value>More info...</value>
|
||||
</data>
|
||||
<data name="PATCHINGWIZARD_PATCHINGPAGE_POOL_RESOLVE" xml:space="preserve">
|
||||
<value>Resolve pool problems</value>
|
||||
|
Loading…
Reference in New Issue
Block a user