mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-10326: Prevent hosts fall into Maintenance when there are running VMs on it
This commit is contained in:
parent
e41b4ed786
commit
cc35f9ddb0
@ -150,4 +150,9 @@ public interface VMInstanceDao extends GenericDao<VMInstanceVO, Long>, StateDao<
|
|||||||
VMInstanceVO findVMByHostNameInZone(String hostName, long zoneId);
|
VMInstanceVO findVMByHostNameInZone(String hostName, long zoneId);
|
||||||
|
|
||||||
boolean isPowerStateUpToDate(long instanceId);
|
boolean isPowerStateUpToDate(long instanceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List running VMs which host and lastHost id are the same
|
||||||
|
*/
|
||||||
|
List<VMInstanceVO> listRunningVmsByHostAndLastHostSameId(long hostId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -304,6 +304,15 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
|||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<VMInstanceVO> listRunningVmsByHostAndLastHostSameId(long hostId) {
|
||||||
|
SearchCriteria<VMInstanceVO> sc = AllFieldsSearch.create();
|
||||||
|
sc.setParameters("host", hostId);
|
||||||
|
sc.setParameters("lastHost", hostId);
|
||||||
|
sc.setParameters("state", State.Running);
|
||||||
|
return listBy(sc);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VMInstanceVO> listByZoneId(long zoneId) {
|
public List<VMInstanceVO> listByZoneId(long zoneId) {
|
||||||
SearchCriteria<VMInstanceVO> sc = AllFieldsSearch.create();
|
SearchCriteria<VMInstanceVO> sc = AllFieldsSearch.create();
|
||||||
|
|||||||
@ -1296,7 +1296,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||||||
if (host.getType() != Host.Type.Storage) {
|
if (host.getType() != Host.Type.Storage) {
|
||||||
final List<VMInstanceVO> vos = _vmDao.listByHostId(hostId);
|
final List<VMInstanceVO> vos = _vmDao.listByHostId(hostId);
|
||||||
final List<VMInstanceVO> vosMigrating = _vmDao.listVmsMigratingFromHost(hostId);
|
final List<VMInstanceVO> vosMigrating = _vmDao.listVmsMigratingFromHost(hostId);
|
||||||
if (vos.isEmpty() && vosMigrating.isEmpty()) {
|
final List<VMInstanceVO> failedMigratedVms = _vmDao.listRunningVmsByHostAndLastHostSameId(hostId);
|
||||||
|
if (vos.isEmpty() && vosMigrating.isEmpty() && failedMigratedVms.isEmpty()) {
|
||||||
resourceStateTransitTo(host, ResourceState.Event.InternalEnterMaintenance, _nodeId);
|
resourceStateTransitTo(host, ResourceState.Event.InternalEnterMaintenance, _nodeId);
|
||||||
hostInMaintenance = true;
|
hostInMaintenance = true;
|
||||||
ActionEventUtils.onCompletedActionEvent(CallContext.current().getCallingUserId(), CallContext.current().getCallingAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_MAINTENANCE_PREPARE, "completed maintenance for host " + hostId, 0);
|
ActionEventUtils.onCompletedActionEvent(CallContext.current().getCallingUserId(), CallContext.current().getCallingAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_MAINTENANCE_PREPARE, "completed maintenance for host " + hostId, 0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user