While starting VM with 'considerlasthost' enabled, don't load host tags/details for the last host when it doesn't exist [main] (#9063)

This commit is contained in:
Suresh Kumar Anaparti 2024-06-12 20:33:18 +05:30 committed by GitHub
parent 64593574d8
commit 6fda757936
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -1077,6 +1077,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
return;
}
Host lastHost = _hostDao.findById(vm.getLastHostId());
if (lastHost == null) {
logger.warn("Could not find last host with id [{}], skipping migrate VM [{}] across cluster check." , vm.getLastHostId(), vm.getUuid());
return;
}
if (destinationClusterId.equals(lastHost.getClusterId())) {
return;
}

View File

@ -458,10 +458,9 @@ StateListener<State, VirtualMachine.Event, VirtualMachine>, Configurable {
DeploymentPlanner planner, VirtualMachine vm, DataCenter dc, ServiceOffering offering, int cpuRequested, long ramRequested,
boolean volumesRequireEncryption) throws InsufficientServerCapacityException {
HostVO host = _hostDao.findById(vm.getLastHostId());
if (canUseLastHost(host, avoids, plan, vm, offering, volumesRequireEncryption)) {
_hostDao.loadHostTags(host);
_hostDao.loadDetails(host);
if (canUseLastHost(host, avoids, plan, vm, offering, volumesRequireEncryption)) {
if (host.getStatus() != Status.Up) {
logger.debug("Cannot deploy VM [{}] to the last host [{}] because this host is not in UP state or is not enabled. Host current status [{}] and resource status [{}].",
vm.getUuid(), host.getUuid(), host.getState().name(), host.getResourceState());