Skip to content

Commit

Permalink
Reserve memory for host
Browse files Browse the repository at this point in the history
By default cloudstack reserves 1Gb of RAM in hosts
using _dom0_memory field. Add a global setting
"host.reserved.mem.mb" which can used to either
increase or decrese the amount of memory which can be reserved
  • Loading branch information
Sina Kashipazha authored and benj-n committed Jun 21, 2024
1 parent d8c7445 commit 5222343
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,39 @@ public void updateCapacityOfHosts() {
}
}

@Override
public void updateCapacityOfHosts() {
Map<Long, List<Long>> hostsByZone = new HashMap<>();
boolean allHostMemoryValuesAreValid = true;

List<HostVO> allHosts = _resourceMgr.listAllHostsInAllZonesByType(Host.Type.Routing);
if (CollectionUtils.isEmpty(allHosts)) {
return;
}

for (HostVO host : allHosts) {

boolean updateWasSuccessFull = updateHostMemory(host);

if (! updateWasSuccessFull){
allHostMemoryValuesAreValid = false;
continue;
}

Long zoneId = host.getDataCenterId();
List<Long> hostIds = hostsByZone.getOrDefault(zoneId, new ArrayList<>());
hostIds.add(host.getId());
hostsByZone.put(zoneId, hostIds);
}

if (allHostMemoryValuesAreValid) {
sendCommandToAgents(hostsByZone,
hostId -> Collections.singletonMap(
ConfigurationManagerImpl.HOST_RESERVED_MEM_MB.key(),
ConfigurationManagerImpl.HOST_RESERVED_MEM_MB.valueIn(_hostDao.findById(hostId).getClusterId()).toString()));
}
}

private GlobalLock getHostJoinLock(Long hostId) {
return GlobalLock.getInternLock(String.format("%s-%s", "Host-Join", hostId));
}
Expand Down

0 comments on commit 5222343

Please sign in to comment.