From 7accaadb2607d798b9193c69945f7705332725d7 Mon Sep 17 00:00:00 2001 From: Aaron Robson Date: Mon, 22 Oct 2018 09:33:50 +0100 Subject: [PATCH] CA-271945: Attempting to resolve the pool's connection and searching for it in all open connections for the EnableHAAction in case a host has been destroyed or the master changed. Preventing an Object (host) has been deleted error when attempting to reenable Maintenance Mode on a Host that has been kicked out of the pool when exiting the RPU Wizard. Returning null to prevent making orphened tasks that will be stuck at 0% completion if it is impossible to fulfill. Signed-off-by: Aaron Robson --- .../Problems/HostProblem/HostMaintenanceMode.cs | 8 ++++++-- .../Problems/PoolProblem/HAEnabledProblem.cs | 13 ++++++++++++- .../Problems/VMProblem/AutoStartEnabled.cs | 3 +++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/XenAdmin/Diagnostics/Problems/HostProblem/HostMaintenanceMode.cs b/XenAdmin/Diagnostics/Problems/HostProblem/HostMaintenanceMode.cs index 54e6122c3..390a2f237 100644 --- a/XenAdmin/Diagnostics/Problems/HostProblem/HostMaintenanceMode.cs +++ b/XenAdmin/Diagnostics/Problems/HostProblem/HostMaintenanceMode.cs @@ -63,8 +63,12 @@ namespace XenAdmin.Diagnostics.Problems.HostProblem public override AsyncAction CreateUnwindChangesAction() { - Program.MainWindow.CloseActiveWizards(Server.Connection); - return new DisableHostAction(Server); + var server = Server.Connection.Resolve(new XenRef(Server.opaque_ref)); + if (server == null) + return null; + + Program.MainWindow.CloseActiveWizards(server.Connection); + return new DisableHostAction(server); } } diff --git a/XenAdmin/Diagnostics/Problems/PoolProblem/HAEnabledProblem.cs b/XenAdmin/Diagnostics/Problems/PoolProblem/HAEnabledProblem.cs index b9deee5f0..361e7c1db 100644 --- a/XenAdmin/Diagnostics/Problems/PoolProblem/HAEnabledProblem.cs +++ b/XenAdmin/Diagnostics/Problems/PoolProblem/HAEnabledProblem.cs @@ -58,7 +58,18 @@ namespace XenAdmin.Diagnostics.Problems.PoolProblem public override AsyncAction CreateUnwindChangesAction() { - return new EnableHAAction(Pool, null, HeartbeatSrs, FailuresToTolerate); + var pool = Pool.Connection.Resolve(new XenRef(Pool.opaque_ref)); + if (pool == null) + { + foreach (var xenConnection in ConnectionsManager.XenConnectionsCopy) + { + pool = xenConnection.Resolve(new XenRef(Pool.opaque_ref)); + if (pool != null) + break; + } + } + + return pool != null ? new EnableHAAction(pool, null, HeartbeatSrs, FailuresToTolerate) : null; } public override string Description diff --git a/XenAdmin/Diagnostics/Problems/VMProblem/AutoStartEnabled.cs b/XenAdmin/Diagnostics/Problems/VMProblem/AutoStartEnabled.cs index 697e5cbcd..ae167f4f5 100644 --- a/XenAdmin/Diagnostics/Problems/VMProblem/AutoStartEnabled.cs +++ b/XenAdmin/Diagnostics/Problems/VMProblem/AutoStartEnabled.cs @@ -88,6 +88,9 @@ namespace XenAdmin.Diagnostics.Problems.VMProblem public override AsyncAction CreateUnwindChangesAction() { + if (VM.Connection.Resolve(new XenRef(VM.opaque_ref)) == null) // check if the vm is still in the cache + return null; + return new DelegatedAsyncAction( VM.Connection, Messages.ACTION_ENABLE_AUTOSTART_ON_VM,