Rewrote the update application sequence to fix various issues:

- CA-380799: Host evacuation is not needed when the guidance is toolstack restart.
- CA-380796: Sometimes the guidance was applied before the update installation.
- Livepatch notice should be shown only if guidance is not reboot host.

Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com>
This commit is contained in:
Konstantina Chremmou 2023-08-08 00:23:53 +01:00
parent a231ca0876
commit 6eaff6dc54
5 changed files with 31 additions and 73 deletions

View File

@ -209,19 +209,10 @@ namespace XenAdmin.TabPages.CdnUpdates
{
if (hostUpdateInfo.RecommendedGuidance.Length > 0)
{
bool allLivePatches = true;
_childRows.Add(new PostUpdateActionRow(hostUpdateInfo.RecommendedGuidance));
foreach (var id in hostUpdateInfo.UpdateIDs)
{
var update = poolUpdateInfo.Updates.FirstOrDefault(u => u.Id == id);
if (update != null && update.LivePatchGuidance == CdnLivePatchGuidance.None)
{
allLivePatches = false;
break;
}
}
_childRows.Add(new PostUpdateActionRow(hostUpdateInfo.RecommendedGuidance, allLivePatches));
if (hostUpdateInfo.LivePatches.Length > 0 && !hostUpdateInfo.RecommendedGuidance.Contains(CdnGuidance.RebootHost))
_childRows.Add(new LivePatchActionRow());
}
var categories = hostUpdateInfo.GetUpdateCategories(poolUpdateInfo);
@ -293,14 +284,18 @@ namespace XenAdmin.TabPages.CdnUpdates
internal class PostUpdateActionRow : CdnExpandableRow
{
public PostUpdateActionRow(CdnGuidance[] guidance, bool allLivePatches)
public PostUpdateActionRow(CdnGuidance[] guidance)
{
var msg = allLivePatches ? Messages.HOTFIX_POST_UPDATE_LIVEPATCH_ACTIONS : Messages.HOTFIX_POST_UPDATE_ACTIONS;
var text = string.Format(Messages.HOTFIX_POST_UPDATE_ACTIONS, string.Join(Environment.NewLine, guidance.Select(Cdn.FriendlyInstruction)));
SetValues(text, Images.StaticImages.rightArrowLong_Blue_16);
}
}
var text = string.Format(msg, string.Join(Environment.NewLine, guidance.Select(Cdn.FriendlyInstruction)));
var img = allLivePatches ? Images.StaticImages.livepatch_16 : Images.StaticImages.rightArrowLong_Blue_16;
SetValues(text, img);
internal class LivePatchActionRow : CdnExpandableRow
{
public LivePatchActionRow()
{
SetValues(Messages.HOTFIX_POST_UPDATE_LIVEPATCH_ACTIONS, Images.StaticImages.livepatch_16);
}
}

View File

@ -174,45 +174,24 @@ namespace XenAdmin.Wizards.PatchingWizard
var planActionsPerHost = new List<PlanAction>();
var delayedActionsPerHost = new List<PlanAction>();
if (hostUpdateInfo.RecommendedGuidance.Length > 0)
if (hostUpdateInfo.RecommendedGuidance.Length > 0 && PostUpdateTasksAutomatically)
{
bool allLivePatches = true;
foreach (var id in hostUpdateInfo.UpdateIDs)
{
var update = poolUpdateInfo.Updates.FirstOrDefault(u => u.Id == id);
if (update != null && update.LivePatchGuidance == CdnLivePatchGuidance.None)
{
allLivePatches = false;
break;
}
}
if (hostUpdateInfo.RecommendedGuidance.Contains(CdnGuidance.RebootHost))
{
if (!allLivePatches)
planActionsPerHost.Add(new EvacuateHostPlanAction(host));
if (PostUpdateTasksAutomatically)
delayedActionsPerHost.Add(new RestartHostPlanAction(host, host.GetRunningVMs()));
}
else if (hostUpdateInfo.RecommendedGuidance.Contains(CdnGuidance.RestartToolstack))
{
if (!allLivePatches)
planActionsPerHost.Add(new EvacuateHostPlanAction(host));
if (PostUpdateTasksAutomatically)
planActionsPerHost.Add(new RestartAgentPlanAction(host));
delayedActionsPerHost.Add(new RestartAgentPlanAction(host));
}
else if (hostUpdateInfo.RecommendedGuidance.Contains(CdnGuidance.EvacuateHost))
{
if (!allLivePatches)
planActionsPerHost.Add(new EvacuateHostPlanAction(host));
}
else if (hostUpdateInfo.RecommendedGuidance.Contains(CdnGuidance.RestartDeviceModel))
{
if (!allLivePatches)
planActionsPerHost.Add(new RebootVMsPlanAction(host, host.GetRunningVMs()));
delayedActionsPerHost.Add(new RebootVMsPlanAction(host, host.GetRunningVMs()));
}
}

View File

@ -296,20 +296,6 @@ namespace XenAdmin.Wizards.PatchingWizard
foreach (var hostUpdateInfo in poolUpdateInfo.HostsWithUpdates)
{
if (hostUpdateInfo.RecommendedGuidance.Length > 0)
{
bool allLivePatches = true;
foreach (var id in hostUpdateInfo.UpdateIDs)
{
var update = poolUpdateInfo.Updates.FirstOrDefault(u => u.Id == id);
if (update != null && update.LivePatchGuidance == CdnLivePatchGuidance.None)
{
allLivePatches = false;
break;
}
}
if (!allLivePatches)
{
var host = pool.Connection.Resolve(new XenRef<Host>(hostUpdateInfo.HostOpaqueRef));
if (host != null)
@ -322,11 +308,13 @@ namespace XenAdmin.Wizards.PatchingWizard
foreach (var g in hostUpdateInfo.RecommendedGuidance)
hostSb.AppendIndented(Cdn.FriendlyInstruction(g), 4).AppendLine();
if (hostUpdateInfo.LivePatches.Length > 0 && !hostUpdateInfo.RecommendedGuidance.Contains(CdnGuidance.RebootHost))
hostSb.AppendIndented(Messages.HOTFIX_POST_UPDATE_LIVEPATCH_ACTIONS, 4).AppendLine();
hostDict[host] = hostSb;
}
}
}
}
poolDict[pool] = new StringBuilder(string.Join(Environment.NewLine,
hostDict.OrderBy(k => k.Key).Select(k => k.Value.ToString())));

View File

@ -20514,9 +20514,7 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to This server will be live patched.
///Post-update tasks to be performed if live patch fails:
///{0}.
/// Looks up a localized string similar to This server will be live patched. If live patch fails, a server reboot will be required..
/// </summary>
public static string HOTFIX_POST_UPDATE_LIVEPATCH_ACTIONS {
get {

View File

@ -7162,9 +7162,7 @@ This might result in failure to migrate VMs to this server during the RPU or to
{0}</value>
</data>
<data name="HOTFIX_POST_UPDATE_LIVEPATCH_ACTIONS" xml:space="preserve">
<value>This server will be live patched.
Post-update tasks to be performed if live patch fails:
{0}</value>
<value>This server will be live patched. If live patch fails, a server reboot will be required.</value>
</data>
<data name="HOTFIX_RPMS_TO_INSTALL" xml:space="preserve">
<value>{0} packages will be updated</value>