Skip to content

Commit fb8d40d

Browse files
authored
server: skip max guest limit check for KVM host (#5417)
Addresses #3015 Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent c85eb10 commit fb8d40d

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// under the License.
1717
package com.cloud.capacity;
1818

19+
import static com.cloud.utils.NumbersUtil.toHumanReadableSize;
20+
1921
import java.net.URI;
2022
import java.util.HashMap;
2123
import java.util.List;
@@ -96,8 +98,6 @@
9698
import com.cloud.vm.dao.VMInstanceDao;
9799
import com.cloud.vm.snapshot.dao.VMSnapshotDao;
98100

99-
import static com.cloud.utils.NumbersUtil.toHumanReadableSize;
100-
101101
public class CapacityManagerImpl extends ManagerBase implements CapacityManager, StateListener<State, VirtualMachine.Event, VirtualMachine>, Listener, ResourceListener,
102102
Configurable {
103103
private static final Logger s_logger = Logger.getLogger(CapacityManagerImpl.class);
@@ -1232,13 +1232,17 @@ public void processPrepareMaintenaceEventBefore(Long hostId) {
12321232

12331233
@Override
12341234
public boolean checkIfHostReachMaxGuestLimit(Host host) {
1235-
Long vmCount = _vmDao.countActiveByHostId(host.getId());
12361235
HypervisorType hypervisorType = host.getHypervisorType();
1236+
if (hypervisorType.equals(HypervisorType.KVM)) {
1237+
s_logger.debug(String.format("Host {id: %s, name: %s, uuid: %s} is %s hypervisor type, no max guest limit check needed", host.getId(), host.getName(), host.getUuid(), hypervisorType));
1238+
return false;
1239+
}
1240+
Long vmCount = _vmDao.countActiveByHostId(host.getId());
12371241
String hypervisorVersion = host.getHypervisorVersion();
12381242
Long maxGuestLimit = _hypervisorCapabilitiesDao.getMaxGuestsLimit(hypervisorType, hypervisorVersion);
1239-
if (vmCount.longValue() >= maxGuestLimit.longValue()) {
1240-
s_logger.info("Host name: " + host.getName() + ", hostId: " + host.getId() + " already reached max Running VMs(count includes system VMs), limit: " +
1241-
maxGuestLimit + ", Running VM count: " + vmCount.longValue());
1243+
if (vmCount >= maxGuestLimit) {
1244+
s_logger.info(String.format("Host {id: %s, name: %s, uuid: %s} already reached max Running VMs(count includes system VMs), limit: %d, running VM count: %s",
1245+
host.getId(), host.getName(), host.getUuid(), maxGuestLimit, vmCount));
12421246
return true;
12431247
}
12441248
return false;

0 commit comments

Comments
 (0)