mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-2096 Deployment Planner - Deployment planner is not looking for hosts in other clusters when vm is being started.
Changes: - Cloud-engine 2 step reserver and deploy flow was not retrying out of clusters, if there are no resources in the volume's cluster. - Fixed this by letting the reservationm step not error out and continue to let deploy step find out resources outside cluster
This commit is contained in:
parent
b888450ec8
commit
0e689dbcc7
@ -37,7 +37,7 @@ public interface VMEntityManager {
|
|||||||
|
|
||||||
String reserveVirtualMachine(VMEntityVO vmEntityVO, String plannerToUse, DeploymentPlan plan, ExcludeList exclude) throws InsufficientCapacityException, ResourceUnavailableException;
|
String reserveVirtualMachine(VMEntityVO vmEntityVO, String plannerToUse, DeploymentPlan plan, ExcludeList exclude) throws InsufficientCapacityException, ResourceUnavailableException;
|
||||||
|
|
||||||
void deployVirtualMachine(String reservationId, String caller, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException;
|
void deployVirtualMachine(String reservationId, VMEntityVO vmEntityVO, String caller, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException;
|
||||||
|
|
||||||
boolean stopvirtualmachine(VMEntityVO vmEntityVO, String caller) throws ResourceUnavailableException;
|
boolean stopvirtualmachine(VMEntityVO vmEntityVO, String caller) throws ResourceUnavailableException;
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@ -136,6 +137,7 @@ public class VMEntityManagerImpl implements VMEntityManager {
|
|||||||
plan = new DataCenterDeployment(planToDeploy.getDataCenterId(), planToDeploy.getPodId(), planToDeploy.getClusterId(), planToDeploy.getHostId(), planToDeploy.getPoolId(), planToDeploy.getPhysicalNetworkId());
|
plan = new DataCenterDeployment(planToDeploy.getDataCenterId(), planToDeploy.getPodId(), planToDeploy.getClusterId(), planToDeploy.getHostId(), planToDeploy.getPoolId(), planToDeploy.getPhysicalNetworkId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean planChangedByReadyVolume = false;
|
||||||
List<VolumeVO> vols = _volsDao.findReadyRootVolumesByInstance(vm.getId());
|
List<VolumeVO> vols = _volsDao.findReadyRootVolumesByInstance(vm.getId());
|
||||||
if(!vols.isEmpty()){
|
if(!vols.isEmpty()){
|
||||||
VolumeVO vol = vols.get(0);
|
VolumeVO vol = vols.get(0);
|
||||||
@ -158,7 +160,7 @@ public class VMEntityManagerImpl implements VMEntityManager {
|
|||||||
plan = new DataCenterDeployment(planToDeploy.getDataCenterId(), planToDeploy.getPodId(), planToDeploy.getClusterId(), planToDeploy.getHostId(), vol.getPoolId(), null, null);
|
plan = new DataCenterDeployment(planToDeploy.getDataCenterId(), planToDeploy.getPodId(), planToDeploy.getClusterId(), planToDeploy.getHostId(), vol.getPoolId(), null, null);
|
||||||
}else{
|
}else{
|
||||||
plan = new DataCenterDeployment(rootVolDcId, rootVolPodId, rootVolClusterId, null, vol.getPoolId(), null, null);
|
plan = new DataCenterDeployment(rootVolDcId, rootVolPodId, rootVolClusterId, null, vol.getPoolId(), null, null);
|
||||||
|
planChangedByReadyVolume = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,6 +189,10 @@ public class VMEntityManagerImpl implements VMEntityManager {
|
|||||||
_vmEntityDao.persist(vmEntityVO);
|
_vmEntityDao.persist(vmEntityVO);
|
||||||
|
|
||||||
return vmReservation.getUuid();
|
return vmReservation.getUuid();
|
||||||
|
} else if (planChangedByReadyVolume) {
|
||||||
|
// we could not reserve in the Volume's cluster - let the deploy
|
||||||
|
// call retry it.
|
||||||
|
return UUID.randomUUID().toString();
|
||||||
}else{
|
}else{
|
||||||
throw new InsufficientServerCapacityException("Unable to create a deployment for " + vmProfile, DataCenter.class, plan.getDataCenterId());
|
throw new InsufficientServerCapacityException("Unable to create a deployment for " + vmProfile, DataCenter.class, plan.getDataCenterId());
|
||||||
}
|
}
|
||||||
@ -194,31 +200,36 @@ public class VMEntityManagerImpl implements VMEntityManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deployVirtualMachine(String reservationId, String caller, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException{
|
public void deployVirtualMachine(String reservationId, VMEntityVO vmEntityVO, String caller, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException{
|
||||||
//grab the VM Id and destination using the reservationId.
|
//grab the VM Id and destination using the reservationId.
|
||||||
|
|
||||||
|
VMInstanceVO vm = _vmDao.findByUuid(vmEntityVO.getUuid());
|
||||||
|
|
||||||
VMReservationVO vmReservation = _reservationDao.findByReservationId(reservationId);
|
VMReservationVO vmReservation = _reservationDao.findByReservationId(reservationId);
|
||||||
long vmId = vmReservation.getVmId();
|
if(vmReservation != null){
|
||||||
|
// Pass it down
|
||||||
VMInstanceVO vm = _vmDao.findById(vmId);
|
Long poolId = null;
|
||||||
//Pass it down
|
Map<Long, Long> storage = vmReservation.getVolumeReservation();
|
||||||
Long poolId = null;
|
if (storage != null) {
|
||||||
Map<Long,Long> storage = vmReservation.getVolumeReservation();
|
List<Long> volIdList = new ArrayList<Long>(storage.keySet());
|
||||||
if(storage != null){
|
if (volIdList != null && !volIdList.isEmpty()) {
|
||||||
List<Long> volIdList = new ArrayList<Long>(storage.keySet());
|
poolId = storage.get(volIdList.get(0));
|
||||||
if(volIdList !=null && !volIdList.isEmpty()){
|
}
|
||||||
poolId = storage.get(volIdList.get(0));
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
DataCenterDeployment reservedPlan = new DataCenterDeployment(vm.getDataCenterId(), vmReservation.getPodId(), vmReservation.getClusterId(),
|
DataCenterDeployment reservedPlan = new DataCenterDeployment(vm.getDataCenterId(),
|
||||||
vmReservation.getHostId(), null , null);
|
vmReservation.getPodId(), vmReservation.getClusterId(), vmReservation.getHostId(), null, null);
|
||||||
try{
|
try {
|
||||||
VMInstanceVO vmDeployed = _itMgr.start(vm, params, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()), reservedPlan);
|
VMInstanceVO vmDeployed = _itMgr.start(vm, params, _userDao.findById(new Long(caller)),
|
||||||
}catch(Exception ex){
|
_accountDao.findById(vm.getAccountId()), reservedPlan);
|
||||||
//Retry the deployment without using the reservation plan
|
} catch (Exception ex) {
|
||||||
DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(), null, null,null, null , null);
|
// Retry the deployment without using the reservation plan
|
||||||
_itMgr.start(vm, params, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()), plan);
|
_itMgr.start(vm, params, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()),
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// no reservation found. Let VirtualMachineManager retry
|
||||||
|
_itMgr.start(vm, params, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -206,7 +206,7 @@ public class VirtualMachineEntityImpl implements VirtualMachineEntity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deploy(String reservationId, String caller, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException{
|
public void deploy(String reservationId, String caller, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException{
|
||||||
manager.deployVirtualMachine(reservationId, caller, params);
|
manager.deployVirtualMachine(reservationId, this.vmEntityVO, caller, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user