Merge pull request #1641 from letsboogey/CA-220169

CA-220169 - Network heartbeat status initially shows 'Error' after en…
This commit is contained in:
Mihaela Stoica 2017-06-21 17:02:36 +01:00 committed by GitHub
commit 15d748925a
3 changed files with 64 additions and 16 deletions

View File

@ -52,6 +52,14 @@ namespace XenAdmin.TabPages
private IXenObject xenObject;
private bool restartHBInitializationTimer;
private bool initializationDelayElapsed;
private System.Timers.Timer initializationDelayTimer;
private const int HB_INITIALIZATION_DELAY = 30000;
private readonly CollectionChangeEventHandler Host_CollectionChangedWithInvoke;
/// <summary>
/// The object that the panel is displaying HA info for. Must be set on the event thread.
@ -90,6 +98,7 @@ namespace XenAdmin.TabPages
base.Text = Messages.HIGH_AVAILABILITY;
pictureBoxWarningTriangle.Image = SystemIcons.Warning.ToBitmap();
restartHBInitializationTimer = true;
}
private void History_CollectionChanged(object sender, CollectionChangeEventArgs e)
@ -301,8 +310,17 @@ namespace XenAdmin.TabPages
private void generatePoolHABox(Pool pool)
{
if (!pool.ha_enabled)
{
restartHBInitializationTimer = true;
return;
}
if (restartHBInitializationTimer)
{
restartHBInitializationTimer = false;
SetNetworkHBInitDelay();
}
// 'High Availability' heading
CustomListRow header = CreateHeader(Messages.HA_CONFIGURATION_TITLE);
customListPanel.AddRow(header);
@ -444,27 +462,28 @@ namespace XenAdmin.TabPages
l.Padding = new Padding(0, 5, 0, 5);
l.Font = BaseTabPage.ItemValueFont;
l.AutoSize = true;
if (members[i].ha_network_peers.Length == members.Count)
l.ForeColor = (members[i].ha_network_peers.Length == members.Count && initializationDelayElapsed) ? Color.Green : BaseTabPage.ItemValueForeColor;
if (initializationDelayElapsed)
{
l.ForeColor = Color.Green;
}
if (members[i].ha_network_peers.Length == 0)
{
l.Text = Messages.HA_HEARTBEAT_UNHEALTHY;
}
else if (members[i].ha_network_peers.Length == members.Count)
{
l.Text = Messages.HA_HEARTBEAT_HEALTHY;
}
else
{
l.Text = String.Format(Messages.HA_HEARTBEAT_SERVERS, members[i].ha_network_peers.Length, members.Count);
}
}
else
{
l.ForeColor = BaseTabPage.ItemValueForeColor;
l.Text = Messages.HA_HEARTBEAT_SERVERS_INITIALISING;
}
if (members[i].ha_network_peers.Length == 0)
{
l.Text = Messages.HA_HEARTBEAT_UNHEALTHY;
}
else if (members[i].ha_network_peers.Length == members.Count)
{
l.Text = Messages.HA_HEARTBEAT_HEALTHY;
}
else
{
l.Text = string.Format(Messages.HA_HEARTBEAT_SERVERS, members[i].ha_network_peers.Length, members.Count);
}
tableLatencies.Controls.Add(l);
tableLatencies.SetCellPosition(l, new TableLayoutPanelCellPosition(1, i + 1));
tableLatencies.SetColumnSpan(l, 2);
@ -670,5 +689,22 @@ namespace XenAdmin.TabPages
Program.MainWindow.ShowPerConnectionWizard(pool.Connection, new HAWizard(pool));
}
}
private void SetNetworkHBInitDelay()
{
initializationDelayElapsed = false;
//30 second delay to allow network HB status to initialize
initializationDelayTimer = new System.Timers.Timer(HB_INITIALIZATION_DELAY);
initializationDelayTimer.Elapsed += HeartbeatInitialization_TimeElapsed;
initializationDelayTimer.AutoReset = false;
initializationDelayTimer.Enabled = true;
}
private void HeartbeatInitialization_TimeElapsed(Object source, System.Timers.ElapsedEventArgs e)
{
initializationDelayElapsed = true;
Program.Invoke(Program.MainWindow, Rebuild);
}
}
}

View File

@ -16403,6 +16403,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to Initializing....
/// </summary>
public static string HA_HEARTBEAT_SERVERS_INITIALISING {
get {
return ResourceManager.GetString("HA_HEARTBEAT_SERVERS_INITIALISING", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to HA Heartbeat SR.
/// </summary>

View File

@ -5760,6 +5760,9 @@ not currently live:
<data name="HA_HEARTBEAT_SERVERS" xml:space="preserve">
<value>{0} out of {1} servers</value>
</data>
<data name="HA_HEARTBEAT_SERVERS_INITIALISING" xml:space="preserve">
<value>Initializing...</value>
</data>
<data name="HA_HEARTBEAT_SR" xml:space="preserve">
<value>HA Heartbeat SR</value>
</data>