From 6e175a4280f51f6a909e94b19e8d7bdffc629c7c Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Wed, 16 Aug 2023 22:19:19 +0100 Subject: [PATCH] Corrected prechecks and calculation of post-update tasks for supp-packs installed on new servers. Signed-off-by: Konstantina Chremmou --- .../Checks/HostNeedsRebootCheck.cs | 22 +++++----- .../PatchingWizard/PatchingWizard_ModePage.cs | 43 ++++++++++--------- .../PatchingWizard_PrecheckPage.cs | 12 ++---- 3 files changed, 36 insertions(+), 41 deletions(-) diff --git a/XenAdmin/Diagnostics/Checks/HostNeedsRebootCheck.cs b/XenAdmin/Diagnostics/Checks/HostNeedsRebootCheck.cs index 339e43109..3efb934ba 100644 --- a/XenAdmin/Diagnostics/Checks/HostNeedsRebootCheck.cs +++ b/XenAdmin/Diagnostics/Checks/HostNeedsRebootCheck.cs @@ -74,17 +74,15 @@ namespace XenAdmin.Diagnostics.Checks protected override Problem RunHostCheck() { - if (Helpers.CloudOrGreater(Host)) - { + if (Helpers.CloudOrGreater(Host) && livePatchCodesByHost == null) return new HostNeedsReboot(this, Host); - } - var updateSequenceIsLivePatchable = restartHostPatches != null && restartHostPatches.Count > 0 && restartHostPatches.All(p => p.ContainsLivepatch); + var updateSequenceIsLivePatchable = restartHostPatches != null && restartHostPatches.Count > 0 && + restartHostPatches.All(p => p.ContainsLivepatch); + var hostHasBeenLivePatched = livePatchCodesByHost != null && livePatchCodesByHost.ContainsKey(Host.uuid) && + livePatchCodesByHost[Host.uuid] == livepatch_status.ok_livepatch_complete; - // when livepatching is available, no restart is expected - if (livePatchCodesByHost != null && livePatchCodesByHost.ContainsKey(Host.uuid) && - livePatchCodesByHost[Host.uuid] == livepatch_status.ok_livepatch_complete - || updateSequenceIsLivePatchable) + if (hostHasBeenLivePatched || updateSequenceIsLivePatchable) { var livePatchingRestricted = Helpers.FeatureForbidden(Host.Connection, Host.RestrictLivePatching); var livePatchingRDisabled = Helpers.GetPoolOfOne(Host.Connection)?.live_patching_disabled == true; @@ -96,11 +94,11 @@ namespace XenAdmin.Diagnostics.Checks return null; } - if ((updateGuidance != null && updateGuidance.Contains(update_after_apply_guidance.restartHost)) - || (patchGuidance != null && patchGuidance.Contains(after_apply_guidance.restartHost)) - || (restartHostPatches != null && restartHostPatches.Count > 0)) + if (updateGuidance != null && updateGuidance.Contains(update_after_apply_guidance.restartHost) || + patchGuidance != null && patchGuidance.Contains(after_apply_guidance.restartHost) || + restartHostPatches != null && restartHostPatches.Count > 0) { - return new HostNeedsReboot(this, Host); + return new HostNeedsReboot(this, Host); } successfulCheckDescription = string.Format(Messages.UPDATES_WIZARD_NO_REBOOT_NEEDED, Host); diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_ModePage.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_ModePage.cs index 054c90dcb..81748088e 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_ModePage.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_ModePage.cs @@ -79,30 +79,31 @@ namespace XenAdmin.Wizards.PatchingWizard bool someHostMayRequireRestart; bool automaticDisabled; - if (IsNewGeneration) + switch (SelectedUpdateType) { - ManualTextInstructions = ModeCdnUpdates(); - automaticDisabled = anyPoolForbidsAutostart; - } - else - { - switch (SelectedUpdateType) - { - case UpdateType.Legacy: + case UpdateType.Legacy: + if (IsNewGeneration) + { + ManualTextInstructions = ModeCdnUpdates(); + automaticDisabled = anyPoolForbidsAutostart; + } + else + { ManualTextInstructions = ModePoolPatch(out someHostMayRequireRestart); automaticDisabled = anyPoolForbidsAutostart && someHostMayRequireRestart; - break; - case UpdateType.ISO: - ManualTextInstructions = PoolUpdate != null - ? ModePoolUpdate(out someHostMayRequireRestart) - : ModeSuppPack(out someHostMayRequireRestart); - automaticDisabled = anyPoolForbidsAutostart && someHostMayRequireRestart; - break; - default: - ManualTextInstructions = null; - automaticDisabled = true; - break; - } + } + + break; + case UpdateType.ISO: + ManualTextInstructions = PoolUpdate != null + ? ModePoolUpdate(out someHostMayRequireRestart) + : ModeSuppPack(out someHostMayRequireRestart); + automaticDisabled = anyPoolForbidsAutostart && someHostMayRequireRestart; + break; + default: + ManualTextInstructions = null; + automaticDisabled = true; + break; } if (ManualTextInstructions == null || ManualTextInstructions.Count == 0) diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs index 9cceb9c84..b7272a82e 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs @@ -414,16 +414,12 @@ namespace XenAdmin.Wizards.PatchingWizard if (host == null) continue; - if (hostUpdateInfo.RecommendedGuidance.Contains(CdnGuidance.RebootHost)) - { + var guidance = hostUpdateInfo.RecommendedGuidance; + + if (guidance.Contains(CdnGuidance.RebootHost)) rebootChecks.Add(new HostNeedsRebootCheck(host)); + if (guidance.Contains(CdnGuidance.RebootHost) || guidance.Contains(CdnGuidance.EvacuateHost)) evacuateChecks.Add(new AssertCanEvacuateCheck(host)); - } - else if (hostUpdateInfo.RecommendedGuidance.Contains(CdnGuidance.EvacuateHost) || - hostUpdateInfo.RecommendedGuidance.Contains(CdnGuidance.RestartToolstack)) - { - evacuateChecks.Add(new AssertCanEvacuateCheck(host)); - } } } else