Skip to content

Commit 6fda757

Browse files
While starting VM with 'considerlasthost' enabled, don't load host tags/details for the last host when it doesn't exist [main] (apache#9063)
1 parent 6459357 commit 6fda757

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,10 @@ protected void checkAndAttemptMigrateVmAcrossCluster(final VMInstanceVO vm, fina
10771077
return;
10781078
}
10791079
Host lastHost = _hostDao.findById(vm.getLastHostId());
1080+
if (lastHost == null) {
1081+
logger.warn("Could not find last host with id [{}], skipping migrate VM [{}] across cluster check." , vm.getLastHostId(), vm.getUuid());
1082+
return;
1083+
}
10801084
if (destinationClusterId.equals(lastHost.getClusterId())) {
10811085
return;
10821086
}

server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,9 @@ private DeployDestination deployInVmLastHost(VirtualMachineProfile vmProfile, De
458458
DeploymentPlanner planner, VirtualMachine vm, DataCenter dc, ServiceOffering offering, int cpuRequested, long ramRequested,
459459
boolean volumesRequireEncryption) throws InsufficientServerCapacityException {
460460
HostVO host = _hostDao.findById(vm.getLastHostId());
461-
_hostDao.loadHostTags(host);
462-
_hostDao.loadDetails(host);
463-
464461
if (canUseLastHost(host, avoids, plan, vm, offering, volumesRequireEncryption)) {
462+
_hostDao.loadHostTags(host);
463+
_hostDao.loadDetails(host);
465464
if (host.getStatus() != Status.Up) {
466465
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 [{}].",
467466
vm.getUuid(), host.getUuid(), host.getState().name(), host.getResourceState());

0 commit comments

Comments
 (0)