Skip to content

Commit

Permalink
Separated HA and WLB prechecks so the problems can be resolved at the…
Browse files Browse the repository at this point in the history
… same time.

Signed-off-by: Konstantina Chremmou <[email protected]>
  • Loading branch information
kc284 committed Sep 19, 2023
1 parent 884160e commit ff0ce93
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 70 deletions.
18 changes: 5 additions & 13 deletions XenAdmin/Diagnostics/Checks/AssertCanEvacuateCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,11 @@ private static CannotMigrateVM.CannotMigrateVMReason GetMoreSpecificReasonForCan
protected override Problem RunHostCheck()
{
Pool pool = Helpers.GetPool(Host.Connection);
if (pool != null)
{
if (pool.ha_enabled)
return new HAEnabledWarning(this, pool, Host);

if (Helpers.WlbEnabled(pool.Connection))
return new WLBEnabledWarning(this, pool, Host);
}

return null;
if (pool == null || (!pool.ha_enabled && !pool.wlb_enabled))
return null;

return new HaWlbEnabledWarning(this, pool, Host);
}

public override List<Problem> RunAllChecks()
Expand All @@ -279,9 +274,6 @@ public override List<Problem> RunAllChecks()
return CheckHost();
}

public override string Description
{
get { return Messages.ASSERT_CAN_EVACUATE_CHECK_DESCRIPTION; }
}
public override string Description => Messages.ASSERT_CAN_EVACUATE_CHECK_DESCRIPTION;
}
}
29 changes: 20 additions & 9 deletions XenAdmin/Diagnostics/Checks/HaWlbOffCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,44 @@
* SUCH DAMAGE.
*/

using XenAdmin.Core;
using XenAdmin.Diagnostics.Problems;
using XenAdmin.Diagnostics.Problems.PoolProblem;
using XenAPI;


namespace XenAdmin.Diagnostics.Checks
{
class HaWlbOffCheck : PoolCheck
internal class HaOffCheck : PoolCheck
{
public HaWlbOffCheck(Pool pool)
public HaOffCheck(Pool pool)
: base(pool)
{
}

protected override Problem RunCheck()
{
if (Pool.ha_enabled)
return new HAEnabledProblem(this, Pool);
return Pool.ha_enabled ? new HAEnabledProblem(this, Pool) : null;
}

public override string Description => Messages.HA_CHECK_DESCRIPTION;

public override string SuccessfulCheckDescription => string.Format(Messages.PATCHING_WIZARD_CHECK_ON_XENOBJECT_OK, Pool.Name(), Description);
}


if (Helpers.WlbEnabled(Pool.Connection))
return new WLBEnabledProblem(this, Pool);
internal class WlbOffCheck : PoolCheck
{
public WlbOffCheck(Pool pool)
: base(pool)
{
}

return null;
protected override Problem RunCheck()
{
return Pool.wlb_enabled ? new WLBEnabledProblem(this, Pool) : null;
}

public override string Description => Messages.HA_WLB_CHECK_DESCRIPTION;
public override string Description => Messages.WLB_CHECK_DESCRIPTION;

public override string SuccessfulCheckDescription => string.Format(Messages.PATCHING_WIZARD_CHECK_ON_XENOBJECT_OK, Pool.Name(), Description);
}
Expand Down
29 changes: 22 additions & 7 deletions XenAdmin/Diagnostics/Problems/PoolProblem/HAEnabledProblem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,35 @@ public DrHAEnabledProblem(Check check, Pool pool)
public override string Description => Messages.DR_WIZARD_PROBLEM_HA_ENABLED;
}

class HAEnabledWarning : Warning
internal class HaWlbEnabledWarning : Warning
{
private readonly Pool pool;
private readonly Host host;
private readonly Pool _pool;
private readonly Host _host;

public HAEnabledWarning(Check check, Pool pool, Host host)
public HaWlbEnabledWarning(Check check, Pool pool, Host host)
: base(check)
{
this.pool = pool;
this.host = host;
_pool = pool;
_host = host;
}

public override string Title => Check.Description;

public override string Description => string.Format(Messages.UPDATES_WIZARD_HA_ON_WARNING, host, pool);
public override string Description
{
get
{
if (_pool.ha_enabled && _pool.wlb_enabled)
return string.Format(Messages.UPDATES_WIZARD_HA_AND_WLB_ON_WARNING, _host, _pool);

if (_pool.ha_enabled)
return string.Format(Messages.UPDATES_WIZARD_HA_ON_WARNING, _host, _pool);

if (_pool.wlb_enabled)
return string.Format(Messages.UPDATES_WIZARD_WLB_ON_WARNING, _host, _pool);

return string.Empty;
}
}
}
}
17 changes: 0 additions & 17 deletions XenAdmin/Diagnostics/Problems/PoolProblem/WLBEnabledProblem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,4 @@ public override AsyncAction CreateUnwindChangesAction()
return pool == null ? null : new EnableWLBAction(pool);
}
}

class WLBEnabledWarning : Warning
{
private readonly Pool pool;
private readonly Host host;

public WLBEnabledWarning(Check check, Pool pool, Host host)
: base(check)
{
this.pool = pool;
this.host = host;
}

public override string Title => Check.Description;

public override string Description => string.Format(Messages.UPDATES_WIZARD_WLB_ON_WARNING, host, pool);
}
}
11 changes: 7 additions & 4 deletions XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,16 @@ private List<CheckGroup> GenerateCommonChecks(List<Host> applicableServers)

groups.Add(new CheckGroup(Messages.CHECKING_HOST_LIVENESS_STATUS, livenessChecks));

//HA checks
//HA and WLB checks

var haChecks = new List<Check>();
var haWlbChecks = new List<Check>();
foreach (Pool pool in SelectedPools)
haChecks.Add(new HaWlbOffCheck(pool));
{
haWlbChecks.Add(new HaOffCheck(pool));
haWlbChecks.Add(new WlbOffCheck(pool));
}

groups.Add(new CheckGroup(Messages.CHECKING_HA_STATUS, haChecks));
groups.Add(new CheckGroup(Messages.CHECKING_HA_AND_WLB_STATUS, haWlbChecks));

//PBDsPluggedCheck
var pbdChecks = new List<Check>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,16 @@ where check.CanRun()
if (pvChecks.Count > 0)
groups.Add(new CheckGroup(Messages.CHECKING_PV_GUESTS, pvChecks));

//HA checks - for each pool
var haChecks = (from Pool pool in SelectedPools
select new HaWlbOffCheck(pool) as Check).ToList();
//HA and WLB checks - for each pool
var haWlbChecks = new List<Check>();
foreach (var pool in SelectedPools)
{
haWlbChecks.Add(new HaOffCheck(pool));
haWlbChecks.Add(new WlbOffCheck(pool));
}

if (haChecks.Count > 0)
groups.Add(new CheckGroup(Messages.CHECKING_HA_STATUS, haChecks));
if (haWlbChecks.Count > 0)
groups.Add(new CheckGroup(Messages.CHECKING_HA_AND_WLB_STATUS, haWlbChecks));

//Checking can evacuate host - for hosts that will be upgraded or updated
var evacuateChecks = (from Host host in hostsToUpgradeOrUpdate
Expand Down
40 changes: 29 additions & 11 deletions XenModel/Messages.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions XenModel/Messages.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2866,7 +2866,7 @@ Do you want to assign these VMs to the schedule '{0}' instead?</value>
<data name="CHECKING_FOR_PENDING_RESTART" xml:space="preserve">
<value>Checking for pending restart</value>
</data>
<data name="CHECKING_HA_STATUS" xml:space="preserve">
<data name="CHECKING_HA_AND_WLB_STATUS" xml:space="preserve">
<value>Checking HA and WLB status</value>
</data>
<data name="CHECKING_HEALTH_CHECK_SERVICE" xml:space="preserve">
Expand Down Expand Up @@ -6580,6 +6580,9 @@ not currently live:
<data name="HA_CANNOT_EVACUATE_COORDINATOR" xml:space="preserve">
<value>Server '{0}' cannot be placed in Maintenance Mode because it is the coordinator of an HA-enabled pool.</value>
</data>
<data name="HA_CHECK_DESCRIPTION" xml:space="preserve">
<value>HA check</value>
</data>
<data name="HA_CHOOSESR_PAGE_PAGETITLE" xml:space="preserve">
<value>Choose a heartbeat SR</value>
</data>
Expand Down Expand Up @@ -6817,9 +6820,6 @@ Click Configure HA to alter the settings displayed below.</value>
<data name="HA_WIZARD_FINISH_PAGE_TITLE" xml:space="preserve">
<value>Review configuration and activate HA</value>
</data>
<data name="HA_WLB_CHECK_DESCRIPTION" xml:space="preserve">
<value>HA and WLB check</value>
</data>
<data name="HAS_CUSTOM_FIELDS" xml:space="preserve">
<value>Has any custom field</value>
</data>
Expand Down Expand Up @@ -13136,6 +13136,9 @@ Note that if RBAC is enabled, only updates which you have privileges to dismiss

Check your settings and try again.</value>
</data>
<data name="UPDATES_WIZARD_HA_AND_WLB_ON_WARNING" xml:space="preserve">
<value>{0}: Check skipped because HA and WLB are enabled on pool {1}.</value>
</data>
<data name="UPDATES_WIZARD_HA_ON_DESCRIPTION" xml:space="preserve">
<value>Pool '{0}' cannot have HA enabled.</value>
</data>
Expand Down Expand Up @@ -14301,6 +14304,9 @@ Schedule:
<data name="WLB_AUTOMATION_SUBTEXT" xml:space="preserve">
<value>Configure WLB Automation</value>
</data>
<data name="WLB_CHECK_DESCRIPTION" xml:space="preserve">
<value>WLB check</value>
</data>
<data name="WLB_COMMAND_MENU_ITEM" xml:space="preserve">
<value>Workload &amp;Balancing</value>
</data>
Expand Down

0 comments on commit ff0ce93

Please sign in to comment.