GutoVeronezi commented on a change in pull request #4575:
URL: https://github.com/apache/cloudstack/pull/4575#discussion_r628257170
##########
File path:
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
##########
@@ -4339,13 +4345,13 @@ private void orchestrateMigrateForScale(final String
vmUuid, final long srcHostI
try {
_agentMgr.send(srcHostId, new
Commands(cleanup(vm.getInstanceName())), null);
} catch (final AgentUnavailableException e) {
- s_logger.error("AgentUnavailableException while
cleanup on source host: " + srcHostId);
+
s_logger.error(String.format("AgentUnavailableException while cleanup on source
%s: %s", srcHost), e);
Review comment:
There are 2 params passed to format, but only one value.
##########
File path: server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
##########
@@ -2385,7 +2387,7 @@ public void deleteRoutingHost(final HostVO host, final
boolean isForced, final b
try {
_vmMgr.destroy(vm.getUuid(), false);
} catch (final Exception e) {
- final String errorMsg = "There was an error Destory
the vm: " + vm + " as a part of hostDelete id=" + host.getId();
+ final String errorMsg = String.format("There was an
error when destroying the vm: %s as a part of hostDelete: %s", vm, host);
Review comment:
Lowercase `vm`.
##########
File path: server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
##########
@@ -1498,7 +1500,7 @@ public boolean checkAndMaintain(final long hostId) {
hostInMaintenance = attemptMaintain(host);
}
} catch (final NoTransitionException e) {
- s_logger.debug("Cannot transmit host " + host.getId() + " to
Maintenance state", e);
+ s_logger.debug(String.format("Cannot transit %s to Maintenance
state", host), e);
Review comment:
Question / Topic for discussion:
Could exceptions be logged in `debug` instead of `warn` or `error`?
##########
File path: server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
##########
@@ -903,7 +904,8 @@ public void doInTransactionWithoutResult(final
TransactionStatus status) {
try {
resourceStateTransitTo(host,
ResourceState.Event.DeleteHost, _nodeId);
} catch (final NoTransitionException e) {
- s_logger.debug("Cannot transmit host " + host.getId() + "
to Enabled state", e);
+ s_logger.debug("Cannot transit " + host + " to Enabled
state", e);
+ s_logger.debug(String.format("Cannot transit %s to Enabled
state", host), e);
Review comment:
The same message twice.
##########
File path:
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
##########
@@ -4354,8 +4360,8 @@ private void orchestrateMigrateForScale(final String
vmUuid, final long srcHostI
s_logger.info("Migration was unsuccessful. Cleaning up: " +
vm);
_alertMgr.sendAlert(alertType, fromHost.getDataCenterId(),
fromHost.getPodId(),
- "Unable to migrate vm " + vm.getInstanceName() + "
from host " + fromHost.getName() + " in zone " + dest.getDataCenter().getName()
+ " and pod " +
- dest.getPod().getName(), "Migrate Command
failed. Please check logs.");
+ "Unable to migrate vm " + vm.getInstanceName() + "
from " + fromHost + " in zone " + dest.getDataCenter().getName() + " and pod " +
Review comment:
We can use `String.format` here too.
##########
File path: server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
##########
@@ -2400,16 +2402,17 @@ public void deleteRoutingHost(final HostVO host, final
boolean isForced, final b
// Restart HA enabled vms
for (final VMInstanceVO vm : vms) {
if (!vm.isHaEnabled() || vm.getState() ==
State.Stopping) {
- s_logger.debug("Stopping vm: " + vm + " as a part
of deleteHost id=" + host.getId());
+ s_logger.debug("Stopping vm: " + vm + " as a part
of hostDelete: " + host);
try {
_vmMgr.advanceStop(vm.getUuid(), false);
} catch (final Exception e) {
- final String errorMsg = "There was an error
stopping the vm: " + vm + " as a part of hostDelete id=" + host.getId();
+ final String errorMsg = String.format("There
was an error stopping the vm: %s as a part of hostDelete: %s", vm, host);
Review comment:
Lowercase `vm`.
##########
File path: server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
##########
@@ -2400,16 +2402,17 @@ public void deleteRoutingHost(final HostVO host, final
boolean isForced, final b
// Restart HA enabled vms
for (final VMInstanceVO vm : vms) {
if (!vm.isHaEnabled() || vm.getState() ==
State.Stopping) {
- s_logger.debug("Stopping vm: " + vm + " as a part
of deleteHost id=" + host.getId());
+ s_logger.debug("Stopping vm: " + vm + " as a part
of hostDelete: " + host);
Review comment:
Lowercase `vm`.
##########
File path: server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
##########
@@ -2400,16 +2402,17 @@ public void deleteRoutingHost(final HostVO host, final
boolean isForced, final b
// Restart HA enabled vms
for (final VMInstanceVO vm : vms) {
if (!vm.isHaEnabled() || vm.getState() ==
State.Stopping) {
- s_logger.debug("Stopping vm: " + vm + " as a part
of deleteHost id=" + host.getId());
+ s_logger.debug("Stopping vm: " + vm + " as a part
of hostDelete: " + host);
try {
_vmMgr.advanceStop(vm.getUuid(), false);
} catch (final Exception e) {
- final String errorMsg = "There was an error
stopping the vm: " + vm + " as a part of hostDelete id=" + host.getId();
+ final String errorMsg = String.format("There
was an error stopping the vm: %s as a part of hostDelete: %s", vm, host);
s_logger.debug(errorMsg, e);
throw new UnableDeleteHostException(errorMsg +
"," + e.getMessage());
}
} else if (vm.isHaEnabled() && (vm.getState() ==
State.Running || vm.getState() == State.Starting)) {
- s_logger.debug("Scheduling restart for vm: " + vm
+ " " + vm.getState() + " on the host id=" + host.getId());
+ s_logger.debug("Scheduling restart for vm: " + vm
+ " " + vm.getState() + " on host: " + host);
+ s_logger.debug(String.format("Scheduling restart
for vm: %s, state: %s on host: %s.", vm, vm.getState(), host));
Review comment:
The same message twice;
Lowercase `vm`;
##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -5165,7 +5165,7 @@ public void
doInTransactionWithoutResult(TransactionStatus status) {
}
});
} catch (Exception e) {
- s_logger.warn("Unable to update vm disk statistics for vm: " +
userVm.getId() + " from host: " + hostId, e);
+ s_logger.warn(String.format("Unable to update vm disk
statistics for vm %s from %s", userVm.getInstanceName(), host), e);
Review comment:
Lowercase `vm`.
##########
File path:
server/src/main/java/com/cloud/resource/RollingMaintenanceManagerImpl.java
##########
@@ -537,7 +539,7 @@ private boolean isMaintenanceScriptDefinedOnHost(Host host,
List<HostSkipped> ho
answer = agentManager.send(host.getId(), cmd);
} catch (AgentUnavailableException | OperationTimedoutException e)
{
// Agent may be restarted on the scripts - continue polling
until it is up
- String msg = "Cannot send command to host: " + host.getId() +
", waiting " + pingInterval + "ms - " + e.getMessage();
+ String msg = String.format("Cannot send command to %s, waiting
%sms - %s", host, pingInterval, e.getMessage());
s_logger.warn(msg);
Review comment:
Pass exception as parameter.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]