mirror of https://github.com/apache/cloudstack.git
Let failed VM in deployment phase to fall into error state
This commit is contained in:
parent
fd04147ed4
commit
8081713020
|
|
@ -66,8 +66,7 @@ public enum State {
|
|||
static {
|
||||
s_fsm.addTransition(null, VirtualMachine.Event.CreateRequested, State.Creating);
|
||||
s_fsm.addTransition(State.Creating, VirtualMachine.Event.OperationSucceeded, State.Stopped);
|
||||
s_fsm.addTransition(State.Creating, VirtualMachine.Event.OperationFailed, State.Destroyed);
|
||||
s_fsm.addTransition(State.Creating, VirtualMachine.Event.DestroyRequested, State.Destroyed);
|
||||
s_fsm.addTransition(State.Creating, VirtualMachine.Event.OperationFailed, State.Error);
|
||||
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.StartRequested, State.Starting);
|
||||
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.DestroyRequested, State.Destroyed);
|
||||
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.StopRequested, State.Stopped);
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
|||
@Override
|
||||
public List<UserVmVO> findDestroyedVms(Date date) {
|
||||
SearchCriteria sc = DestroySearch.create();
|
||||
sc.setParameters("state", State.Destroyed, State.Expunging);
|
||||
sc.setParameters("state", State.Destroyed, State.Expunging, State.Error);
|
||||
sc.setParameters("updateTime", date);
|
||||
|
||||
return listActiveBy(sc);
|
||||
|
|
|
|||
|
|
@ -266,6 +266,7 @@ import com.cloud.vm.VMInstanceVO;
|
|||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineName;
|
||||
import com.cloud.vm.VmStats;
|
||||
import com.cloud.vm.VirtualMachine.Event;
|
||||
import com.cloud.vm.dao.ConsoleProxyDao;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.SecondaryStorageVmDao;
|
||||
|
|
@ -2330,8 +2331,8 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
throw iee;
|
||||
} finally {
|
||||
if(created == null) {
|
||||
s_logger.warn("Failed to create VM, delete the DB record, vmId: " + initial.getId());
|
||||
_vmDao.remove(initial.getId());
|
||||
s_logger.warn("Failed to create VM, mark VM into destroyed state, vmId: " + initial.getId());
|
||||
_vmDao.updateIf(initial, Event.OperationFailed, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2382,13 +2383,8 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
List<Pair<VolumeVO, StoragePoolVO>> disks = new ArrayList<Pair<VolumeVO, StoragePoolVO>>();
|
||||
// NOTE: We now destroy a VM if the deploy process fails at any step. We now
|
||||
// have a lazy delete so there is still some time to figure out what's wrong.
|
||||
if(created != null) {
|
||||
disks = _storageMgr.isStoredOn(created);
|
||||
_vmMgr.destroyVirtualMachine(userId, created.getId());
|
||||
} else {
|
||||
if(initial != null)
|
||||
_vmMgr.destroyVirtualMachine(userId, initial.getId());
|
||||
}
|
||||
disks = _storageMgr.isStoredOn(created);
|
||||
_vmMgr.destroyVirtualMachine(userId, created.getId());
|
||||
|
||||
boolean retryCreate = true;
|
||||
for (Pair<VolumeVO, StoragePoolVO> disk : disks) {
|
||||
|
|
|
|||
|
|
@ -1320,9 +1320,11 @@ public class UserVmManagerImpl implements UserVmManager {
|
|||
return _vmDao.findById(vmId);
|
||||
} catch (Throwable th) {
|
||||
s_logger.error("Unable to create vm", th);
|
||||
/*
|
||||
if (vm != null) {
|
||||
_vmDao.delete(vmId);
|
||||
}
|
||||
*/
|
||||
_accountMgr.decrementResourceCount(account.getId(), ResourceType.user_vm);
|
||||
_accountMgr.decrementResourceCount(account.getId(), ResourceType.volume, numVolumes);
|
||||
|
||||
|
|
@ -2541,7 +2543,10 @@ public class UserVmManagerImpl implements UserVmManager {
|
|||
boolean addedToGroups = _networkGroupManager.addInstanceToGroups(vmId, networkGroups);
|
||||
if (!addedToGroups) {
|
||||
s_logger.warn("Not all specified network groups can be found");
|
||||
_vmDao.delete(vm.getId());
|
||||
|
||||
/*
|
||||
_vmDao.delete(vm.getId());
|
||||
*/
|
||||
throw new InvalidParameterValueException("Not all specified network groups can be found");
|
||||
}
|
||||
|
||||
|
|
@ -2549,7 +2554,9 @@ public class UserVmManagerImpl implements UserVmManager {
|
|||
try {
|
||||
poolId = _storageMgr.createUserVM(account, vm, template, dc, pod.first(), offering, diskOffering, a);
|
||||
} catch (CloudRuntimeException e) {
|
||||
/*
|
||||
_vmDao.delete(vmId);
|
||||
*/
|
||||
_ipAddressDao.unassignIpAddress(guestIp);
|
||||
s_logger.debug("Released a guest ip address because we could not find storage: ip=" + guestIp);
|
||||
guestIp = null;
|
||||
|
|
@ -2731,7 +2738,9 @@ public class UserVmManagerImpl implements UserVmManager {
|
|||
try {
|
||||
poolId = _storageMgr.createUserVM(account, vm, template, dc, pod.first(), offering, diskOffering, a);
|
||||
} catch (CloudRuntimeException e) {
|
||||
/*
|
||||
_vmDao.delete(vmId);
|
||||
*/
|
||||
_accountMgr.decrementResourceCount(account.getId(), ResourceType.user_vm);
|
||||
_accountMgr.decrementResourceCount(account.getId(), ResourceType.volume, numVolumes);
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue