mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-5420: The agent manager wasn't transitioning the host to maintenance
mode if their are no vms running on the host. Made the change to do so.
This commit is contained in:
parent
f1260e8606
commit
079323f591
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
|
|
@ -84,6 +85,8 @@ public interface ResourceManager extends ResourceService {
|
|||
|
||||
public boolean maintain(final long hostId) throws AgentUnavailableException;
|
||||
|
||||
public boolean checkAndMaintain(final long hostId);
|
||||
|
||||
@Override
|
||||
public boolean deleteHost(long hostId, boolean isForced, boolean isForceDeleteStorage);
|
||||
|
||||
|
|
|
|||
|
|
@ -1473,20 +1473,12 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
|
|||
List<HostVO> hosts = sc.list();
|
||||
|
||||
for (HostVO host : hosts) {
|
||||
long hostId = host.getId();
|
||||
DataCenterVO dcVO = _dcDao.findById(host.getDataCenterId());
|
||||
HostPodVO podVO = _podDao.findById(host.getPodId());
|
||||
String hostDesc = "name: " + host.getName() + " (id:" + hostId + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName();
|
||||
|
||||
if (host.getType() != Host.Type.Storage) {
|
||||
// List<VMInstanceVO> vos = _vmDao.listByHostId(hostId);
|
||||
// List<VMInstanceVO> vosMigrating = _vmDao.listVmsMigratingFromHost(hostId);
|
||||
// if (vos.isEmpty() && vosMigrating.isEmpty()) {
|
||||
// _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Migration Complete for host " + hostDesc, "Host ["
|
||||
// + hostDesc
|
||||
// + "] is ready for maintenance");
|
||||
// _resourceMgr.resourceStateTransitTo(host, ResourceState.Event.InternalEnterMaintenance, _msId);
|
||||
// }
|
||||
if (_resourceMgr.checkAndMaintain(host.getId())) {
|
||||
DataCenterVO dcVO = _dcDao.findById(host.getDataCenterId());
|
||||
HostPodVO podVO = _podDao.findById(host.getPodId());
|
||||
String hostDesc = "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName();
|
||||
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Migration Complete for host " + hostDesc, "Host ["
|
||||
+ hostDesc + "] is ready for maintenance");
|
||||
}
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
|
|
|
|||
|
|
@ -1230,6 +1230,26 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkAndMaintain(final long hostId) {
|
||||
boolean hostInMaintenance = false;
|
||||
HostVO host = _hostDao.findById(hostId);
|
||||
|
||||
try {
|
||||
if (host.getType() != Host.Type.Storage) {
|
||||
List<VMInstanceVO> vos = _vmDao.listByHostId(hostId);
|
||||
List<VMInstanceVO> vosMigrating = _vmDao.listVmsMigratingFromHost(hostId);
|
||||
if (vos.isEmpty() && vosMigrating.isEmpty()) {
|
||||
resourceStateTransitTo(host, ResourceState.Event.InternalEnterMaintenance, _nodeId);
|
||||
hostInMaintenance = true;
|
||||
}
|
||||
}
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.debug("Cannot transmit host " + host.getId() + "to Maintenance state", e);
|
||||
}
|
||||
return hostInMaintenance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Host updateHost(UpdateHostCmd cmd) throws NoTransitionException {
|
||||
Long hostId = cmd.getId();
|
||||
|
|
|
|||
|
|
@ -316,6 +316,15 @@ public class MockResourceManagerImpl extends ManagerBase implements ResourceMana
|
|||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.resource.ResourceManager#maintain(long)
|
||||
*/
|
||||
@Override
|
||||
public boolean checkAndMaintain(long hostId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.resource.ResourceManager#deleteHost(long, boolean, boolean)
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue