Skip to content

Commit b9f15fd

Browse files
authored
Remove cpu core from op_host_capacity when host is deleted (#4367)
When a host is put into maintenance mode or its deleted from cloudstack then delete its entries from op_host_capacity table
1 parent ff8a84e commit b9f15fd

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,7 @@ public void processDiscoverEventBefore(Long dcid, Long podId, Long clusterId, UR
11791179
public void processPrepareMaintenaceEventAfter(Long hostId) {
11801180
_capacityDao.removeBy(Capacity.CAPACITY_TYPE_MEMORY, null, null, null, hostId);
11811181
_capacityDao.removeBy(Capacity.CAPACITY_TYPE_CPU, null, null, null, hostId);
1182+
_capacityDao.removeBy(Capacity.CAPACITY_TYPE_CPU_CORE, null, null, null, hostId);
11821183
}
11831184

11841185
@Override

server/src/main/java/com/cloud/resource/ResourceManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
929929
}
930930

931931
// delete the op_host_capacity entry
932-
final Object[] capacityTypes = {Capacity.CAPACITY_TYPE_CPU, Capacity.CAPACITY_TYPE_MEMORY};
932+
final Object[] capacityTypes = {Capacity.CAPACITY_TYPE_CPU, Capacity.CAPACITY_TYPE_MEMORY, Capacity.CAPACITY_TYPE_CPU_CORE};
933933
final SearchCriteria<CapacityVO> hostCapacitySC = _capacityDao.createSearchCriteria();
934934
hostCapacitySC.addAnd("hostOrPoolId", SearchCriteria.Op.EQ, hostId);
935935
hostCapacitySC.addAnd("capacityType", SearchCriteria.Op.IN, capacityTypes);

0 commit comments

Comments
 (0)