This is an automated email from the ASF dual-hosted git repository.

vishesh pushed a commit to branch 4.18
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.18 by this push:
     new 56e04505266 Logging improvements on migration in the VmwareResource 
(#8300)
56e04505266 is described below

commit 56e0450526639513a68176fbc8ab87e738b3f8d8
Author: dahn <[email protected]>
AuthorDate: Wed Feb 28 10:59:35 2024 +0100

    Logging improvements on migration in the VmwareResource (#8300)
---
 .../com/cloud/hypervisor/vmware/resource/VmwareResource.java | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git 
a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java
 
b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 22d0a796e14..b65a7847675 100644
--- 
a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ 
b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -4766,7 +4766,13 @@ public class VmwareResource extends ServerResourceBase 
implements StoragePoolRes
         final String vmName = cmd.getVmName();
         try {
             VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
+            if (hyperHost == null) {
+                throw new CloudRuntimeException("no hypervisor host found for 
migrate command");
+            }
             ManagedObjectReference morDc = hyperHost.getHyperHostDatacenter();
+            if (morDc == null) {
+                throw new CloudRuntimeException("no Managed Object Reference 
for the Data Center found for migrate command");
+            }
 
             // find VM through datacenter (VM is not at the target host yet)
             VirtualMachineMO vmMo = hyperHost.findVmOnPeerHyperHost(vmName);
@@ -4777,6 +4783,9 @@ public class VmwareResource extends ServerResourceBase 
implements StoragePoolRes
             }
 
             VmwareHypervisorHost destHyperHost = getTargetHyperHost(new 
DatacenterMO(hyperHost.getContext(), morDc), cmd.getDestinationIp());
+            if (destHyperHost == null) {
+                throw new CloudRuntimeException("no destination Hypervisor 
Host found for migrate command");
+            }
 
             ManagedObjectReference morTargetPhysicalHost = 
destHyperHost.findMigrationTarget(vmMo);
             if (morTargetPhysicalHost == null) {
@@ -4788,7 +4797,8 @@ public class VmwareResource extends ServerResourceBase 
implements StoragePoolRes
             }
 
             return new MigrateAnswer(cmd, true, "migration succeeded", null);
-        } catch (Throwable e) {
+        } catch (Exception e) {
+            s_logger.info(String.format("migrate command for %s failed due to 
%s", vmName, e.getLocalizedMessage()));
             return new MigrateAnswer(cmd, false, createLogMessageException(e, 
cmd), null);
         }
     }

Reply via email to