Skip to content

Commit 441d9d7

Browse files
committed
bug 11154: host can go in Maintenance state only after all vms are migrated from it
status 11154: resolved fixed
1 parent 54e4e00 commit 441d9d7

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎server/src/com/cloud/agent/manager/AgentMonitor.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ public void run() {
138138

139139
if (host.getType() != Host.Type.Storage) {
140140
List<VMInstanceVO> vos = _vmDao.listByHostId(hostId);
141-
if (vos.size() == 0) {
141+
List<VMInstanceVO> vosMigrating = _vmDao.listVmsMigratingFromHost(hostId);
142+
if (vos.isEmpty() && vosMigrating.isEmpty()) {
142143
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Migration Complete for host " + hostDesc, "Host [" + hostDesc + "] is ready for maintenance");
143144
_hostDao.updateStatus(host, Event.PreparationComplete, _msId);
144145
}

‎server/src/com/cloud/vm/dao/VMInstanceDao.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,6 @@ public interface VMInstanceDao extends GenericDao<VMInstanceVO, Long>, StateDao<
8181
List<VMInstanceVO> listByAccountId(long accountId);
8282
public Long countAllocatedVirtualRoutersForAccount(long accountId);
8383

84-
List<VMInstanceVO> listByClusterId(long clusterId);
84+
List<VMInstanceVO> listByClusterId(long clusterId);
85+
List<VMInstanceVO> listVmsMigratingFromHost(Long hostId);
8586
}

‎server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,4 +329,12 @@ public Long countAllocatedVirtualRoutersForAccount(long accountId) {
329329
sc.setParameters("state", new Object[] {State.Destroyed, State.Error, State.Expunging});
330330
return customSearch(sc, null).get(0);
331331
}
332+
333+
@Override
334+
public List<VMInstanceVO> listVmsMigratingFromHost(Long hostId) {
335+
SearchCriteria<VMInstanceVO> sc = AllFieldsSearch.create();
336+
sc.setParameters("lastHost", hostId);
337+
sc.setParameters("state", State.Migrating);
338+
return listBy(sc);
339+
}
332340
}

0 commit comments

Comments
 (0)