Skip to content

Commit 061ee2f

Browse files
Address review: enhance logs
1 parent b860d31 commit 061ee2f

4 files changed

Lines changed: 15 additions & 9 deletions

File tree

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4480,7 +4480,7 @@ private void orchestrateMigrateForScale(final String vmUuid, final long srcHostI
44804480
try {
44814481
_agentMgr.send(srcHostId, new Commands(cleanup(vm.getInstanceName())), null);
44824482
} catch (final AgentUnavailableException e) {
4483-
s_logger.error(String.format("AgentUnavailableException while cleanup on source %s: ", srcHost), e);
4483+
s_logger.error(String.format("Unable to cleanup source %s. ", srcHost), e);
44844484
}
44854485
cleanup(vmGuru, new VirtualMachineProfileImpl(vm), work, Event.AgentReportStopped, true);
44864486
throw new CloudRuntimeException("Unable to complete migration for " + vm);
@@ -4494,9 +4494,10 @@ private void orchestrateMigrateForScale(final String vmUuid, final long srcHostI
44944494
if (!migrated) {
44954495
s_logger.info("Migration was unsuccessful. Cleaning up: " + vm);
44964496

4497-
_alertMgr.sendAlert(alertType, fromHost.getDataCenterId(), fromHost.getPodId(),
4498-
"Unable to migrate vm " + vm.getInstanceName() + " from " + fromHost + " in zone " + dest.getDataCenter().getName() + " and pod " +
4499-
dest.getPod().getName(), "Migrate Command failed. Please check logs.");
4497+
String alertSubject = String.format("Unable to migrate VM [%s] from %s in Zone [%s] and Pod [%s].",
4498+
vm.getInstanceName(), fromHost, dest.getDataCenter().getName(), dest.getPod().getName());
4499+
String alertBody = "Migrate Command failed. Please check logs.";
4500+
_alertMgr.sendAlert(alertType, fromHost.getDataCenterId(), fromHost.getPodId(), alertSubject, alertBody);
45004501
try {
45014502
_agentMgr.send(dstHostId, new Commands(cleanup(vm.getInstanceName())), null);
45024503
} catch (final AgentUnavailableException ae) {

server/src/main/java/com/cloud/network/element/VirtualRouterElement.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,8 @@ public boolean stopVpn(final RemoteAccessVpn vpn) throws ResourceUnavailableExce
411411
if (canHandle(network, Service.Vpn)) {
412412
final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
413413
if (routers == null || routers.isEmpty()) {
414-
s_logger.debug(String.format("Virtual router element doesn't need stop VPN on the backend; virtual router doesn't exist in the network %s", network.getId()));
414+
s_logger.debug(String.format("There is no virtual router in network [uuid: %s, name: %s], it is not necessary to stop the VPN on backend.",
415+
network.getUuid(), network.getName()));
415416
return true;
416417
}
417418
return _routerMgr.deleteRemoteAccessVpn(network, vpn, routers);

server/src/main/java/com/cloud/resource/ResourceManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2482,7 +2482,7 @@ public void deleteRoutingHost(final HostVO host, final boolean isForced, final b
24822482
try {
24832483
_vmMgr.destroy(vm.getUuid(), false);
24842484
} catch (final Exception e) {
2485-
String errorMsg = String.format("There was an error when destroying the VM: %s as a part of hostDelete: %s", vm, host);
2485+
String errorMsg = String.format("There was an error when destroying %s as a part of hostDelete for %s", vm, host);
24862486
s_logger.debug(errorMsg, e);
24872487
throw new UnableDeleteHostException(errorMsg + "," + e.getMessage());
24882488
}
@@ -2608,7 +2608,7 @@ protected void connectAndRestartAgentOnHost(HostVO host, String username, String
26082608
final com.trilead.ssh2.Connection connection = SSHCmdHelper.acquireAuthorizedConnection(
26092609
host.getPrivateIpAddress(), 22, username, password);
26102610
if (connection == null) {
2611-
throw new CloudRuntimeException(String.format("SSH to agent is enabled, but failed to connect to %s via IP address %s.", host, host.getPrivateIpAddress()));
2611+
throw new CloudRuntimeException(String.format("SSH to agent is enabled, but failed to connect to %s via IP address [%s].", host, host.getPrivateIpAddress()));
26122612
}
26132613
try {
26142614
SSHCmdHelper.SSHCmdResult result = SSHCmdHelper.sshExecuteCmdOneShot(

server/src/main/java/com/cloud/resource/RollingMaintenanceManagerImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ private Ternary<Boolean, Boolean, String> performPreMaintenanceStageOnHost(Host
468468
return new Ternary<>(true, false, result.second());
469469
}
470470
if (result.third() && !hostsToAvoidMaintenance.containsKey(host.getId())) {
471-
s_logger.debug(String.format("%s added to the avoid maintenance set", host));
471+
logHostAddedToAvoidMaintenanceSet(host);
472472
hostsToAvoidMaintenance.put(host.getId(), "Pre-maintenance stage set to avoid maintenance");
473473
}
474474
return new Ternary<>(false, false, result.second());
@@ -571,12 +571,16 @@ private void performPreFlightChecks(List<Host> hosts, int timeout, String payloa
571571
for (Host host : hosts) {
572572
Ternary<Boolean, String, Boolean> result = performStageOnHost(host, Stage.PreFlight, timeout, payload, forced);
573573
if (result.third() && !hostsToAvoidMaintenance.containsKey(host.getId())) {
574-
s_logger.debug(String.format("%s added to the avoid maintenance set", host));
574+
logHostAddedToAvoidMaintenanceSet(host);
575575
hostsToAvoidMaintenance.put(host.getId(), "Pre-flight stage set to avoid maintenance");
576576
}
577577
}
578578
}
579579

580+
private void logHostAddedToAvoidMaintenanceSet(Host host) {
581+
s_logger.debug(String.format("%s added to the avoid maintenance set.", host));
582+
}
583+
580584
/**
581585
* Capacity checks on hosts
582586
*/

0 commit comments

Comments
 (0)