Skip to content

Commit 56e0450

Browse files
authored
Logging improvements on migration in the VmwareResource (#8300)
1 parent 4e34e6b commit 56e0450

File tree

1 file changed

+11
-1
lines changed
  • plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource

1 file changed

+11
-1
lines changed

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4766,7 +4766,13 @@ protected Answer execute(MigrateCommand cmd) {
47664766
final String vmName = cmd.getVmName();
47674767
try {
47684768
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
4769+
if (hyperHost == null) {
4770+
throw new CloudRuntimeException("no hypervisor host found for migrate command");
4771+
}
47694772
ManagedObjectReference morDc = hyperHost.getHyperHostDatacenter();
4773+
if (morDc == null) {
4774+
throw new CloudRuntimeException("no Managed Object Reference for the Data Center found for migrate command");
4775+
}
47704776

47714777
// find VM through datacenter (VM is not at the target host yet)
47724778
VirtualMachineMO vmMo = hyperHost.findVmOnPeerHyperHost(vmName);
@@ -4777,6 +4783,9 @@ protected Answer execute(MigrateCommand cmd) {
47774783
}
47784784

47794785
VmwareHypervisorHost destHyperHost = getTargetHyperHost(new DatacenterMO(hyperHost.getContext(), morDc), cmd.getDestinationIp());
4786+
if (destHyperHost == null) {
4787+
throw new CloudRuntimeException("no destination Hypervisor Host found for migrate command");
4788+
}
47804789

47814790
ManagedObjectReference morTargetPhysicalHost = destHyperHost.findMigrationTarget(vmMo);
47824791
if (morTargetPhysicalHost == null) {
@@ -4788,7 +4797,8 @@ protected Answer execute(MigrateCommand cmd) {
47884797
}
47894798

47904799
return new MigrateAnswer(cmd, true, "migration succeeded", null);
4791-
} catch (Throwable e) {
4800+
} catch (Exception e) {
4801+
s_logger.info(String.format("migrate command for %s failed due to %s", vmName, e.getLocalizedMessage()));
47924802
return new MigrateAnswer(cmd, false, createLogMessageException(e, cmd), null);
47934803
}
47944804
}

0 commit comments

Comments
 (0)