mirror of https://github.com/apache/cloudstack.git
Enhance log messages with host name (#4575)
* Enhance log messages with hostName
* Use host.toString() on most of host logs.
* Remove redundant "Host" in logs and enhance logs
* duplicated "for"
* Adopt String.format, and enhance code
* Address reviews enhancing log messages
Update server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
-- server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
-- server/src/main/java/com/cloud/resource/RollingMaintenanceManagerImpl.java
Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com>
* Fix String.format issue and change log message from debug to warn
* Fix checkstyle issue
* Fix string.format log
* Address review: enhance logs
* Enhance log of hosts in maintenance avoid list
* Remove "VM" on logs as vm.toString() already appends VM-<details>
* Add more details of the VM when postStateTransitionEvent
* Address reviewer and enhance VMInstanceVO.toString()
Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com>
This commit is contained in:
parent
b5d75352f2
commit
ca78f5b386
|
|
@ -286,7 +286,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||
|
||||
@Override
|
||||
protected AgentAttache createAttacheForDirectConnect(final Host host, final ServerResource resource) {
|
||||
s_logger.debug("create ClusteredDirectAgentAttache for " + host.getId());
|
||||
s_logger.debug(String.format("Create ClusteredDirectAgentAttache for %s.", host));
|
||||
final DirectAgentAttache attache = new ClusteredDirectAgentAttache(this, host.getId(), host.getName(), _nodeId, resource, host.isInMaintenanceStates());
|
||||
AgentAttache old = null;
|
||||
synchronized (_agents) {
|
||||
|
|
|
|||
|
|
@ -4346,19 +4346,25 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
|
||||
VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
|
||||
s_logger.info("Migrating " + vm + " to " + dest);
|
||||
s_logger.info(String.format("Migrating %s to %s", vm, dest));
|
||||
|
||||
vm.getServiceOfferingId();
|
||||
final long dstHostId = dest.getHost().getId();
|
||||
final Host fromHost = _hostDao.findById(srcHostId);
|
||||
Host srcHost = _hostDao.findById(srcHostId);
|
||||
if (fromHost == null) {
|
||||
s_logger.info("Unable to find the host to migrate from: " + srcHostId);
|
||||
throw new CloudRuntimeException("Unable to find the host to migrate from: " + srcHostId);
|
||||
String logMessageUnableToFindHost = String.format("Unable to find host to migrate from %s.", srcHost);
|
||||
s_logger.info(logMessageUnableToFindHost);
|
||||
throw new CloudRuntimeException(logMessageUnableToFindHost);
|
||||
}
|
||||
|
||||
if (fromHost.getClusterId().longValue() != dest.getCluster().getId()) {
|
||||
s_logger.info("Source and destination host are not in same cluster, unable to migrate to host: " + dstHostId);
|
||||
throw new CloudRuntimeException("Source and destination host are not in same cluster, unable to migrate to host: " + dest.getHost().getId());
|
||||
Host dstHost = _hostDao.findById(dstHostId);
|
||||
long destHostClusterId = dest.getCluster().getId();
|
||||
long fromHostClusterId = fromHost.getClusterId();
|
||||
if (fromHostClusterId != destHostClusterId) {
|
||||
String logMessageHostsOnDifferentCluster = String.format("Source and destination host are not in same cluster, unable to migrate to %s", srcHost);
|
||||
s_logger.info(logMessageHostsOnDifferentCluster);
|
||||
throw new CloudRuntimeException(logMessageHostsOnDifferentCluster);
|
||||
}
|
||||
|
||||
final VirtualMachineGuru vmGuru = getVmGuru(vm);
|
||||
|
|
@ -4475,13 +4481,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
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("Unable to cleanup source %s. ", srcHost), e);
|
||||
}
|
||||
cleanup(vmGuru, new VirtualMachineProfileImpl(vm), work, Event.AgentReportStopped, true);
|
||||
throw new CloudRuntimeException("Unable to complete migration for " + vm);
|
||||
}
|
||||
} catch (final OperationTimedoutException e) {
|
||||
s_logger.debug("Error while checking the vm " + vm + " on host " + dstHostId, e);
|
||||
s_logger.debug(String.format("Error while checking the %s on %s", vm, dstHost), e);
|
||||
}
|
||||
|
||||
migrated = true;
|
||||
|
|
@ -4489,9 +4495,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
if (!migrated) {
|
||||
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.");
|
||||
String alertSubject = String.format("Unable to migrate %s from %s in Zone [%s] and Pod [%s].",
|
||||
vm.getInstanceName(), fromHost, dest.getDataCenter().getName(), dest.getPod().getName());
|
||||
String alertBody = "Migrate Command failed. Please check logs.";
|
||||
_alertMgr.sendAlert(alertType, fromHost.getDataCenterId(), fromHost.getPodId(), alertSubject, alertBody);
|
||||
try {
|
||||
_agentMgr.send(dstHostId, new Commands(cleanup(vm.getInstanceName())), null);
|
||||
} catch (final AgentUnavailableException ae) {
|
||||
|
|
@ -4841,6 +4848,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
// 3) handle out of sync stationary states, marking VM from Stopped to Running with
|
||||
// alert messages
|
||||
//
|
||||
Host host = _hostDao.findById(vm.getHostId());
|
||||
Host poweredHost = _hostDao.findById(vm.getPowerHostId());
|
||||
switch (vm.getState()) {
|
||||
case Starting:
|
||||
s_logger.info("VM " + vm.getInstanceName() + " is at " + vm.getState() + " and we received a power-on report while there is no pending jobs on it");
|
||||
|
|
@ -4862,7 +4871,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
case Running:
|
||||
try {
|
||||
if (vm.getHostId() != null && vm.getHostId().longValue() != vm.getPowerHostId().longValue()) {
|
||||
s_logger.info("Detected out of band VM migration from host " + vm.getHostId() + " to host " + vm.getPowerHostId());
|
||||
s_logger.info(String.format("Detected out of band VM migration from %s to %s", host, poweredHost));
|
||||
}
|
||||
stateTransitTo(vm, VirtualMachine.Event.FollowAgentPowerOnReport, vm.getPowerHostId());
|
||||
} catch (final NoTransitionException e) {
|
||||
|
|
|
|||
|
|
@ -196,4 +196,9 @@ public class ClusterVO implements Cluster {
|
|||
public PartitionType partitionType() {
|
||||
return PartitionType.Cluster;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Cluster {id: \"%s\", name: \"%s\", uuid: \"%s\"}", id, name, uuid);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -506,7 +506,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("VM instance {\"id\": \"%s\", \"name\": \"%s\", \"uuid\": \"%s\", \"type\"=\"%s\"}", id, getInstanceName(), uuid, type);
|
||||
return String.format("VM instance {id: \"%s\", name: \"%s\", uuid: \"%s\", type=\"%s\"}", id, getInstanceName(), uuid, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -926,8 +926,11 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
|
|||
State oldState = transition.getCurrentState();
|
||||
State newState = transition.getToState();
|
||||
Event event = transition.getEvent();
|
||||
s_logger.debug("VM state transitted from :" + oldState + " to " + newState + " with event: " + event + "vm's original host id: " + vm.getLastHostId() +
|
||||
" new host id: " + vm.getHostId() + " host id before state transition: " + oldHostId);
|
||||
Host lastHost = _hostDao.findById(vm.getLastHostId());
|
||||
Host oldHost = _hostDao.findById(oldHostId);
|
||||
Host newHost = _hostDao.findById(vm.getHostId());
|
||||
s_logger.debug(String.format("%s state transited from [%s] to [%s] with event [%s]. VM's original host: %s, new host: %s, host before state transition: %s", vm, oldState,
|
||||
newState, event, lastHost, newHost, oldHost));
|
||||
|
||||
if (oldState == State.Starting) {
|
||||
if (newState != State.Running) {
|
||||
|
|
|
|||
|
|
@ -411,12 +411,13 @@ NetworkMigrationResponder, AggregatedCommandExecutor, RedundantResource, DnsServ
|
|||
if (canHandle(network, Service.Vpn)) {
|
||||
final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
|
||||
if (routers == null || routers.isEmpty()) {
|
||||
s_logger.debug("Virtual router elemnt doesn't need stop vpn on the backend; virtual router doesn't " + "exist in the network " + network.getId());
|
||||
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.",
|
||||
network.getUuid(), network.getName()));
|
||||
return true;
|
||||
}
|
||||
return _routerMgr.deleteRemoteAccessVpn(network, vpn, routers);
|
||||
} else {
|
||||
s_logger.debug("Element " + getName() + " doesn't handle removeVpn command");
|
||||
s_logger.debug(String.format("Element %s doesn't handle removeVpn command", getName()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -909,6 +909,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
host.setClusterId(null);
|
||||
_hostDao.update(host.getId(), host);
|
||||
|
||||
Host hostRemoved = _hostDao.findById(hostId);
|
||||
_hostDao.remove(hostId);
|
||||
if (clusterId != null) {
|
||||
final List<HostVO> hosts = listAllHostsInCluster(clusterId);
|
||||
|
|
@ -922,7 +923,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
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(String.format("Cannot transit %s to Enabled state", host), e);
|
||||
}
|
||||
|
||||
// Delete the associated entries in host ref table
|
||||
|
|
@ -947,7 +948,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
storagePool.setClusterId(null);
|
||||
_storagePoolDao.update(poolId, storagePool);
|
||||
_storagePoolDao.remove(poolId);
|
||||
s_logger.debug("Local storage id=" + poolId + " is removed as a part of host removal id=" + hostId);
|
||||
s_logger.debug(String.format("Local storage [id: %s] is removed as a part of %s removal", poolId, hostRemoved.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1278,7 +1279,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
try {
|
||||
resourceStateTransitTo(host, ResourceState.Event.AdminAskMaintenance, _nodeId);
|
||||
} catch (final NoTransitionException e) {
|
||||
final String err = "Cannot transmit resource state of host " + host.getId() + " to " + ResourceState.Maintenance;
|
||||
final String err = String.format("Cannot transit resource state of %s to %s", host, ResourceState.Maintenance);
|
||||
s_logger.debug(err, e);
|
||||
throw new CloudRuntimeException(err + e.getMessage());
|
||||
}
|
||||
|
|
@ -1530,7 +1531,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
protected boolean attemptMaintain(HostVO host) throws NoTransitionException {
|
||||
final long hostId = host.getId();
|
||||
|
||||
s_logger.info("Attempting maintenance for host " + host.getName());
|
||||
s_logger.info(String.format("Attempting maintenance for %s", host));
|
||||
|
||||
// Step 0: First gather if VMs have pending HAWork for migration with retries left.
|
||||
final List<VMInstanceVO> allVmsOnHost = _vmDao.listByHostId(hostId);
|
||||
|
|
@ -1538,7 +1539,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
boolean hasPendingMigrationRetries = false;
|
||||
for (VMInstanceVO vmInstanceVO : allVmsOnHost) {
|
||||
if (_haMgr.hasPendingMigrationsWork(vmInstanceVO.getId())) {
|
||||
s_logger.info("Attempting maintenance for " + host + " found pending migration for VM " + vmInstanceVO);
|
||||
s_logger.info(String.format("Attempting maintenance for %s found pending migration for %s.", host, vmInstanceVO));
|
||||
hasPendingMigrationRetries = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -1595,7 +1596,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
hostInMaintenance = attemptMaintain(host);
|
||||
}
|
||||
} catch (final NoTransitionException e) {
|
||||
s_logger.debug("Cannot transmit host " + host.getId() + " to Maintenance state", e);
|
||||
s_logger.warn(String.format("Cannot transit %s from %s to Maintenance state.", host, host.getResourceState()), e);
|
||||
}
|
||||
return hostInMaintenance;
|
||||
}
|
||||
|
|
@ -2062,12 +2063,12 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
/* Agent goes to Connecting status */
|
||||
_agentMgr.agentStatusTransitTo(host, Status.Event.AgentConnected, _nodeId);
|
||||
} catch (final Exception e) {
|
||||
s_logger.debug("Cannot transmit host " + host.getId() + " to Creating state", e);
|
||||
s_logger.debug(String.format("Cannot transit %s to Creating state", host), e);
|
||||
_agentMgr.agentStatusTransitTo(host, Status.Event.Error, _nodeId);
|
||||
try {
|
||||
resourceStateTransitTo(host, ResourceState.Event.Error, _nodeId);
|
||||
} catch (final NoTransitionException e1) {
|
||||
s_logger.debug("Cannot transmit host " + host.getId() + "to Error state", e);
|
||||
s_logger.debug(String.format("Cannot transit %s to Error state", host), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2202,7 +2203,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
host = findHostByGuid(firstCmd.getGuidWithoutResource());
|
||||
}
|
||||
if (host != null && host.getRemoved() == null) { // host already added, no need to add again
|
||||
s_logger.debug("Found the host " + host.getId() + " by guid: " + firstCmd.getGuid() + ", old host reconnected as new");
|
||||
s_logger.debug(String.format("Found %s by guid: %s, old host reconnected as new", host, firstCmd.getGuid()));
|
||||
hostExists = true; // ensures that host status is left unchanged in case of adding same one again
|
||||
return null;
|
||||
}
|
||||
|
|
@ -2275,7 +2276,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
// added, no
|
||||
// need to add
|
||||
// again
|
||||
s_logger.debug("Found the host " + host.getId() + " by guid: " + firstCmd.getGuid() + ", old host reconnected as new");
|
||||
s_logger.debug(String.format("Found %s by guid %s, old host reconnected as new.", host, firstCmd.getGuid()));
|
||||
hostExists = true; // ensures that host status is left
|
||||
// unchanged in case of adding same one
|
||||
// again
|
||||
|
|
@ -2451,11 +2452,11 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
@Override
|
||||
public void deleteRoutingHost(final HostVO host, final boolean isForced, final boolean forceDestroyStorage) throws UnableDeleteHostException {
|
||||
if (host.getType() != Host.Type.Routing) {
|
||||
throw new CloudRuntimeException("Non-Routing host gets in deleteRoutingHost, id is " + host.getId());
|
||||
throw new CloudRuntimeException(String.format("Non-Routing host gets in deleteRoutingHost, id is %s", host.getId()));
|
||||
}
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Deleting Host: " + host.getId() + " Guid:" + host.getGuid());
|
||||
s_logger.debug(String.format("Deleting %s", host));
|
||||
}
|
||||
|
||||
final StoragePoolVO storagePool = _storageMgr.findLocalStorageOnHost(host.getId());
|
||||
|
|
@ -2481,7 +2482,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
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();
|
||||
String errorMsg = String.format("There was an error when destroying %s as a part of hostDelete for %s", vm, host);
|
||||
s_logger.debug(errorMsg, e);
|
||||
throw new UnableDeleteHostException(errorMsg + "," + e.getMessage());
|
||||
}
|
||||
|
|
@ -2500,16 +2501,16 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
}
|
||||
for (final VMInstanceVO vm : vms) {
|
||||
if ((! HighAvailabilityManager.ForceHA.value() && !vm.isHaEnabled()) || vm.getState() == State.Stopping) {
|
||||
s_logger.debug("Stopping vm: " + vm + " as a part of deleteHost id=" + host.getId());
|
||||
s_logger.debug(String.format("Stopping %s as a part of hostDelete for %s",vm, host));
|
||||
try {
|
||||
_haMgr.scheduleStop(vm, host.getId(), WorkType.Stop);
|
||||
} 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 %s as a part of hostDelete for %s", vm, host);
|
||||
s_logger.debug(errorMsg, e);
|
||||
throw new UnableDeleteHostException(errorMsg + "," + e.getMessage());
|
||||
}
|
||||
} else if ((HighAvailabilityManager.ForceHA.value() || 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(String.format("Scheduling restart for %s, state: %s on host: %s.", vm, vm.getState(), host));
|
||||
_haMgr.scheduleRestart(vm, false);
|
||||
}
|
||||
}
|
||||
|
|
@ -2555,7 +2556,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
resourceStateTransitTo(host, ResourceState.Event.AdminCancelMaintenance, _nodeId);
|
||||
_agentMgr.pullAgentOutMaintenance(hostId);
|
||||
} catch (final NoTransitionException e) {
|
||||
s_logger.debug("Cannot transmit host " + host.getId() + "to Enabled state", e);
|
||||
s_logger.debug(String.format("Cannot transit %s to Enabled state", host), e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -2607,13 +2608,13 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
final com.trilead.ssh2.Connection connection = SSHCmdHelper.acquireAuthorizedConnection(
|
||||
host.getPrivateIpAddress(), 22, username, password);
|
||||
if (connection == null) {
|
||||
throw new CloudRuntimeException("SSH to agent is enabled, but failed to connect to host: " + host.getPrivateIpAddress());
|
||||
throw new CloudRuntimeException(String.format("SSH to agent is enabled, but failed to connect to %s via IP address [%s].", host, host.getPrivateIpAddress()));
|
||||
}
|
||||
try {
|
||||
SSHCmdHelper.SSHCmdResult result = SSHCmdHelper.sshExecuteCmdOneShot(
|
||||
connection, "service cloudstack-agent restart");
|
||||
if (result.getReturnCode() != 0) {
|
||||
throw new CloudRuntimeException("Could not restart agent on host " + host.getId() + " due to: " + result.getStdErr());
|
||||
throw new CloudRuntimeException(String.format("Could not restart agent on %s due to: %s", host, result.getStdErr()));
|
||||
}
|
||||
s_logger.debug("cloudstack-agent restart result: " + result.toString());
|
||||
} catch (final SshException e) {
|
||||
|
|
@ -2715,13 +2716,14 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
return result;
|
||||
}
|
||||
} catch (final AgentUnavailableException e) {
|
||||
s_logger.error("Agent is not availbale!", e);
|
||||
s_logger.error("Agent is not available!", e);
|
||||
}
|
||||
|
||||
if (shouldUpdateHostPasswd) {
|
||||
final boolean isUpdated = doUpdateHostPassword(host.getId());
|
||||
if (!isUpdated) {
|
||||
throw new CloudRuntimeException("CloudStack failed to update the password of the Host with UUID / ID ==> " + host.getUuid() + " / " + host.getId() + ". Please make sure you are still able to connect to your hosts.");
|
||||
throw new CloudRuntimeException(
|
||||
String.format("CloudStack failed to update the password of %s. Please make sure you are still able to connect to your hosts.", host));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2797,8 +2799,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
". Emitting event UnableToMigrate.");
|
||||
return resourceStateTransitTo(host, ResourceState.Event.UnableToMigrate, _nodeId);
|
||||
} catch (final NoTransitionException e) {
|
||||
s_logger.debug("No next resource state for host " + host.getId() + " while current state is " + host.getResourceState() + " with event " +
|
||||
ResourceState.Event.UnableToMigrate, e);
|
||||
s_logger.debug(String.format("No next resource state for %s while current state is [%s] with event %s", host, host.getResourceState(), ResourceState.Event.UnableToMigrate), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -3117,7 +3118,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
return null;
|
||||
}
|
||||
if (answer == null || !answer.getResult()) {
|
||||
final String msg = "Unable to obtain GPU stats for host " + host.getName();
|
||||
final String msg = String.format("Unable to obtain GPU stats for %s", host);
|
||||
s_logger.warn(msg);
|
||||
return null;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -395,7 +395,7 @@ public class RollingMaintenanceManagerImpl extends ManagerBase implements Rollin
|
|||
* @throws AgentUnavailableException
|
||||
*/
|
||||
private void putHostIntoMaintenance(Host host) throws InterruptedException, AgentUnavailableException {
|
||||
s_logger.debug("Trying to set the host " + host.getId() + " into maintenance");
|
||||
s_logger.debug(String.format("Trying to set %s into maintenance", host));
|
||||
PrepareForMaintenanceCmd cmd = new PrepareForMaintenanceCmd();
|
||||
cmd.setId(host.getId());
|
||||
resourceManager.maintain(cmd);
|
||||
|
|
@ -423,9 +423,9 @@ public class RollingMaintenanceManagerImpl extends ManagerBase implements Rollin
|
|||
private Ternary<Boolean, Boolean, String> reCheckCapacityBeforeMaintenanceOnHost(Cluster cluster, Host host, Boolean forced, List<HostSkipped> hostsSkipped) {
|
||||
Pair<Boolean, String> capacityCheckBeforeMaintenance = performCapacityChecksBeforeHostInMaintenance(host, cluster);
|
||||
if (!capacityCheckBeforeMaintenance.first()) {
|
||||
String errorMsg = "Capacity check failed for host " + host.getUuid() + ": " + capacityCheckBeforeMaintenance.second();
|
||||
String errorMsg = String.format("Capacity check failed for %s: %s", host, capacityCheckBeforeMaintenance.second());
|
||||
if (forced) {
|
||||
s_logger.info("Skipping host " + host.getUuid() + " as: " + errorMsg);
|
||||
s_logger.info(String.format("Skipping %s as: %s", host, errorMsg));
|
||||
hostsSkipped.add(new HostSkipped(host, errorMsg));
|
||||
return new Ternary<>(true, true, capacityCheckBeforeMaintenance.second());
|
||||
}
|
||||
|
|
@ -439,9 +439,9 @@ public class RollingMaintenanceManagerImpl extends ManagerBase implements Rollin
|
|||
*/
|
||||
private boolean isMaintenanceStageAvoided(Host host, Map<Long, String> hostsToAvoidMaintenance, List<HostSkipped> hostsSkipped) {
|
||||
if (hostsToAvoidMaintenance.containsKey(host.getId())) {
|
||||
s_logger.debug("Host " + host.getId() + " is not being put into maintenance, skipping it");
|
||||
HostSkipped hostSkipped = new HostSkipped(host, hostsToAvoidMaintenance.get(host.getId()));
|
||||
hostsSkipped.add(hostSkipped);
|
||||
s_logger.debug(String.format("%s is in avoid maintenance list [hosts skipped: %d], skipping its maintenance.", host, hostsSkipped.size()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -468,7 +468,7 @@ public class RollingMaintenanceManagerImpl extends ManagerBase implements Rollin
|
|||
return new Ternary<>(true, false, result.second());
|
||||
}
|
||||
if (result.third() && !hostsToAvoidMaintenance.containsKey(host.getId())) {
|
||||
s_logger.debug("Host " + host.getId() + " added to the avoid maintenance set");
|
||||
logHostAddedToAvoidMaintenanceSet(host);
|
||||
hostsToAvoidMaintenance.put(host.getId(), "Pre-maintenance stage set to avoid maintenance");
|
||||
}
|
||||
return new Ternary<>(false, false, result.second());
|
||||
|
|
@ -491,7 +491,7 @@ public class RollingMaintenanceManagerImpl extends ManagerBase implements Rollin
|
|||
RollingMaintenanceAnswer answer = (RollingMaintenanceAnswer) agentManager.send(host.getId(), new RollingMaintenanceCommand(true));
|
||||
return answer.isMaintenaceScriptDefined();
|
||||
} catch (AgentUnavailableException | OperationTimedoutException e) {
|
||||
String msg = "Could not check for maintenance script on host " + host.getId() + " due to: " + e.getMessage();
|
||||
String msg = String.format("Could not check for maintenance script on %s due to: %s", host, e.getMessage());
|
||||
s_logger.error(msg, e);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -537,8 +537,8 @@ public class RollingMaintenanceManagerImpl extends ManagerBase implements Rollin
|
|||
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();
|
||||
s_logger.warn(msg);
|
||||
String msg = String.format("Cannot send command to %s, waiting %sms - %s", host, pingInterval, e.getMessage());
|
||||
s_logger.warn(msg, e);
|
||||
cmd.setStarted(true);
|
||||
Thread.sleep(pingInterval);
|
||||
timeSpent += pingInterval;
|
||||
|
|
@ -571,12 +571,16 @@ public class RollingMaintenanceManagerImpl extends ManagerBase implements Rollin
|
|||
for (Host host : hosts) {
|
||||
Ternary<Boolean, String, Boolean> result = performStageOnHost(host, Stage.PreFlight, timeout, payload, forced);
|
||||
if (result.third() && !hostsToAvoidMaintenance.containsKey(host.getId())) {
|
||||
s_logger.debug("Host " + host.getId() + " added to the avoid maintenance set");
|
||||
logHostAddedToAvoidMaintenanceSet(host);
|
||||
hostsToAvoidMaintenance.put(host.getId(), "Pre-flight stage set to avoid maintenance");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void logHostAddedToAvoidMaintenanceSet(Host host) {
|
||||
s_logger.debug(String.format("%s added to the avoid maintenance set.", host));
|
||||
}
|
||||
|
||||
/**
|
||||
* Capacity checks on hosts
|
||||
*/
|
||||
|
|
@ -584,7 +588,7 @@ public class RollingMaintenanceManagerImpl extends ManagerBase implements Rollin
|
|||
for (Host host : hosts) {
|
||||
Pair<Boolean, String> result = performCapacityChecksBeforeHostInMaintenance(host, cluster);
|
||||
if (!result.first() && !forced) {
|
||||
throw new CloudRuntimeException("Capacity check failed for host " + host.getUuid() + ": " + result.second());
|
||||
throw new CloudRuntimeException(String.format("Capacity check failed for %s : %s", host, result.second()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -616,8 +620,7 @@ public class RollingMaintenanceManagerImpl extends ManagerBase implements Rollin
|
|||
ServiceOfferingVO serviceOffering = serviceOfferingDao.findById(runningVM.getServiceOfferingId());
|
||||
for (Host hostInCluster : hostsInCluster) {
|
||||
if (!checkHostTags(hostTags, hostTagsDao.gethostTags(hostInCluster.getId()), serviceOffering.getHostTag())) {
|
||||
s_logger.debug("Host tags mismatch between host " + host.getUuid() + " and host " + hostInCluster.getUuid() +
|
||||
". Skipping it from the capacity check");
|
||||
s_logger.debug(String.format("Host tags mismatch between %s and %s Skipping it from the capacity check", host, hostInCluster));
|
||||
continue;
|
||||
}
|
||||
DeployDestination deployDestination = new DeployDestination(null, null, null, host);
|
||||
|
|
@ -627,8 +630,7 @@ public class RollingMaintenanceManagerImpl extends ManagerBase implements Rollin
|
|||
affinityChecks = affinityChecks && affinityProcessor.check(vmProfile, deployDestination);
|
||||
}
|
||||
if (!affinityChecks) {
|
||||
s_logger.debug("Affinity check failed between host " + host.getUuid() + " and host " + hostInCluster.getUuid() +
|
||||
". Skipping it from the capacity check");
|
||||
s_logger.debug(String.format("Affinity check failed between %s and %s Skipping it from the capacity check", host, hostInCluster));
|
||||
continue;
|
||||
}
|
||||
boolean maxGuestLimit = capacityManager.checkIfHostReachMaxGuestLimit(host);
|
||||
|
|
@ -647,15 +649,15 @@ public class RollingMaintenanceManagerImpl extends ManagerBase implements Rollin
|
|||
}
|
||||
}
|
||||
if (!canMigrateVm) {
|
||||
String msg = "VM " + runningVM.getUuid() + " cannot be migrated away from host " + host.getUuid() +
|
||||
" to any other host in the cluster";
|
||||
String msg = String.format("%s cannot be migrated away from %s to any other host in the cluster", runningVM, host);
|
||||
s_logger.error(msg);
|
||||
return new Pair<>(false, msg);
|
||||
}
|
||||
sucessfullyCheckedVmMigrations++;
|
||||
}
|
||||
if (sucessfullyCheckedVmMigrations != vmsRunning.size()) {
|
||||
return new Pair<>(false, "Host " + host.getId() + " cannot enter maintenance mode as capacity check failed for hosts in cluster " + cluster.getUuid());
|
||||
String migrationCheckDetails = String.format("%s cannot enter maintenance mode as capacity check failed for hosts in cluster %s", host, cluster);
|
||||
return new Pair<>(false, migrationCheckDetails);
|
||||
}
|
||||
return new Pair<>(true, "OK");
|
||||
}
|
||||
|
|
@ -735,4 +737,4 @@ public class RollingMaintenanceManagerImpl extends ManagerBase implements Rollin
|
|||
public ConfigKey<?>[] getConfigKeys() {
|
||||
return new ConfigKey<?>[] {KvmRollingMaintenanceStageTimeout, KvmRollingMaintenancePingInterval, KvmRollingMaintenanceWaitForMaintenanceTimeout};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5255,7 +5255,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
}
|
||||
});
|
||||
} 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 %s from %s", userVm.getInstanceName(), host), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ public class IndirectAgentLBServiceImpl extends ComponentLifecycleBase implement
|
|||
final SetupMSListCommand cmd = new SetupMSListCommand(msList, lbAlgorithm, lbCheckInterval);
|
||||
final Answer answer = agentManager.easySend(host.getId(), cmd);
|
||||
if (answer == null || !answer.getResult()) {
|
||||
LOG.warn("Failed to setup management servers list to the agent of host id=" + host.getId());
|
||||
LOG.warn(String.format("Failed to setup management servers list to the agent of %s", host));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
if (sentCount != null && sentCount <= 0) {
|
||||
boolean concurrentUpdateResult = hostAlertCache.asMap().replace(host.getId(), sentCount, sentCount+1L);
|
||||
if (concurrentUpdateResult) {
|
||||
final String subject = String.format("Out-of-band management auth-error detected for host:%d in cluster:%d, zone:%d", host.getId(), host.getClusterId(), host.getDataCenterId());
|
||||
final String subject = String.format("Out-of-band management auth-error detected for %s in cluster [id: %d] and zone [id: %d].", host, host.getClusterId(), host.getDataCenterId());
|
||||
LOG.error(subject + ": " + message);
|
||||
alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_OOBM_AUTH_ERROR, host.getDataCenterId(), host.getPodId(), subject, message);
|
||||
}
|
||||
|
|
@ -203,11 +203,12 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
return false;
|
||||
}
|
||||
OutOfBandManagement.PowerState currentPowerState = outOfBandManagementHost.getPowerState();
|
||||
Host host = hostDao.findById(outOfBandManagementHost.getHostId());
|
||||
try {
|
||||
OutOfBandManagement.PowerState newPowerState = OutOfBandManagement.PowerState.getStateMachine().getNextState(currentPowerState, event);
|
||||
boolean result = OutOfBandManagement.PowerState.getStateMachine().transitTo(outOfBandManagementHost, event, null, outOfBandManagementDao);
|
||||
if (result) {
|
||||
final String message = String.format("Transitioned out-of-band management power state from:%s to:%s due to event:%s for the host id:%d", currentPowerState, newPowerState, event, outOfBandManagementHost.getHostId());
|
||||
final String message = String.format("Transitioned out-of-band management power state from %s to %s due to event: %s for %s", currentPowerState, newPowerState, event, host);
|
||||
LOG.debug(message);
|
||||
if (newPowerState == OutOfBandManagement.PowerState.Unknown) {
|
||||
ActionEventUtils.onActionEvent(CallContext.current().getCallingUserId(), CallContext.current().getCallingAccountId(), Domain.ROOT_DOMAIN,
|
||||
|
|
@ -216,7 +217,7 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
}
|
||||
return result;
|
||||
} catch (NoTransitionException ignored) {
|
||||
LOG.trace(String.format("Unable to transition out-of-band management power state for host id=%s for the event=%s and current power state=%s", outOfBandManagementHost.getHostId(), event, currentPowerState));
|
||||
LOG.trace(String.format("Unable to transition out-of-band management power state for %s for the event: %s and current power state: %s", host, event, currentPowerState));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -372,13 +373,14 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
}
|
||||
|
||||
boolean updatedConfig = outOfBandManagementDao.update(outOfBandManagementConfig.getId(), (OutOfBandManagementVO) outOfBandManagementConfig);
|
||||
CallContext.current().setEventDetails("host id:" + host.getId() + " configuration:" + outOfBandManagementConfig.getAddress() + ":" + outOfBandManagementConfig.getPort());
|
||||
String eventDetails = String.format("Configuring %s out-of-band with address [%s] and port [%s]", host, outOfBandManagementConfig.getAddress(), outOfBandManagementConfig.getPort());
|
||||
CallContext.current().setEventDetails(eventDetails);
|
||||
|
||||
if (!updatedConfig) {
|
||||
throw new CloudRuntimeException("Failed to update out-of-band management config for the host in the database.");
|
||||
throw new CloudRuntimeException(String.format("Failed to update out-of-band management config for %s in the database.", host));
|
||||
}
|
||||
|
||||
String result = "Out-of-band management successfully configured for the host";
|
||||
String result = String.format("Out-of-band management successfully configured for %s.", host);
|
||||
LOG.debug(result);
|
||||
|
||||
final OutOfBandManagementResponse response = new OutOfBandManagementResponse(outOfBandManagementDao.findByHost(host.getId()));
|
||||
|
|
@ -404,7 +406,7 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
final OutOfBandManagementDriverResponse driverResponse = driver.execute(cmd);
|
||||
|
||||
if (driverResponse == null) {
|
||||
throw new CloudRuntimeException(String.format("Out-of-band Management action (%s) on host (%s) failed due to no response from the driver", powerOperation, host.getUuid()));
|
||||
throw new CloudRuntimeException(String.format("Out-of-band Management action [%s] on %s failed due to no response from the driver", powerOperation, host));
|
||||
}
|
||||
|
||||
if (powerOperation.equals(OutOfBandManagement.PowerOperation.STATUS)) {
|
||||
|
|
@ -412,9 +414,9 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
}
|
||||
|
||||
if (!driverResponse.isSuccess()) {
|
||||
String errorMessage = String.format("Out-of-band Management action (%s) on host (%s) failed with error: %s", powerOperation, host.getUuid(), driverResponse.getError());
|
||||
String errorMessage = String.format("Out-of-band Management action [%s] on %s failed with error: %s", powerOperation, host, driverResponse.getError());
|
||||
if (driverResponse.hasAuthFailure()) {
|
||||
errorMessage = String.format("Out-of-band Management action (%s) on host (%s) failed due to authentication error: %s. Please check configured credentials.", powerOperation, host.getUuid(), driverResponse.getError());
|
||||
errorMessage = String.format("Out-of-band Management action [%s] on %s failed due to authentication error: %s. Please check configured credentials.", powerOperation, host, driverResponse.getError());
|
||||
sendAuthError(host, errorMessage);
|
||||
}
|
||||
if (!powerOperation.equals(OutOfBandManagement.PowerOperation.STATUS)) {
|
||||
|
|
@ -436,13 +438,13 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
public OutOfBandManagementResponse changePassword(final Host host, final String newPassword) {
|
||||
checkOutOfBandManagementEnabledByZoneClusterHost(host);
|
||||
if (Strings.isNullOrEmpty(newPassword)) {
|
||||
throw new CloudRuntimeException(String.format("Cannot change out-of-band management password as provided new-password is null or empty for the host %s.", host.getUuid()));
|
||||
throw new CloudRuntimeException(String.format("Cannot change out-of-band management password as provided new-password is null or empty for %s.", host));
|
||||
}
|
||||
|
||||
final OutOfBandManagement outOfBandManagementConfig = outOfBandManagementDao.findByHost(host.getId());
|
||||
final ImmutableMap<OutOfBandManagement.Option, String> options = getOptions(outOfBandManagementConfig);
|
||||
if (!(options.containsKey(OutOfBandManagement.Option.PASSWORD) && !Strings.isNullOrEmpty(options.get(OutOfBandManagement.Option.PASSWORD)))) {
|
||||
throw new CloudRuntimeException(String.format("Cannot change out-of-band management password as we've no previously configured password for the host %s.", host.getUuid()));
|
||||
throw new CloudRuntimeException(String.format("Cannot change out-of-band management password as we've no previously configured password for %s.", host));
|
||||
}
|
||||
final OutOfBandManagementDriver driver = getDriver(outOfBandManagementConfig);
|
||||
final OutOfBandManagementDriverChangePasswordCommand changePasswordCmd = new OutOfBandManagementDriverChangePasswordCommand(options, ActionTimeout.valueIn(host.getClusterId()), newPassword);
|
||||
|
|
@ -455,7 +457,7 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
boolean result = outOfBandManagementDao.update(updatedOutOfBandManagementConfig.getId(), (OutOfBandManagementVO) updatedOutOfBandManagementConfig);
|
||||
|
||||
if (!result) {
|
||||
throw new CloudRuntimeException(String.format("Failed to change out-of-band management password for host (%s) in the database.", host.getUuid()));
|
||||
throw new CloudRuntimeException(String.format("Failed to change out-of-band management password for %s in the database.", host));
|
||||
}
|
||||
|
||||
final OutOfBandManagementDriverResponse driverResponse;
|
||||
|
|
@ -463,11 +465,11 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
driverResponse = driver.execute(changePasswordCmd);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Out-of-band management change password failed due to driver error: " + e.getMessage());
|
||||
throw new CloudRuntimeException(String.format("Failed to change out-of-band management password for host (%s) due to driver error: %s", host.getUuid(), e.getMessage()));
|
||||
throw new CloudRuntimeException(String.format("Failed to change out-of-band management password for %s due to driver error: %s", host, e.getMessage()));
|
||||
}
|
||||
|
||||
if (!driverResponse.isSuccess()) {
|
||||
throw new CloudRuntimeException(String.format("Failed to change out-of-band management password for host (%s) with error: %s", host.getUuid(), driverResponse.getError()));
|
||||
throw new CloudRuntimeException(String.format("Failed to change out-of-band management password for %s with error: %s", host, driverResponse.getError()));
|
||||
}
|
||||
|
||||
return result && driverResponse.isSuccess();
|
||||
|
|
@ -566,7 +568,7 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
} else if (outOfBandManagementHost.getPowerState() != OutOfBandManagement.PowerState.Disabled) {
|
||||
if (transitionPowerStateToDisabled(Collections.singletonList(host))) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Out-of-band management was disabled in zone/cluster/host, disabled power state for host id:" + host.getId());
|
||||
LOG.debug(String.format("Out-of-band management was disabled in zone/cluster/host, disabled power state for %s", host));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue