Issue #: 5775

Release vnet and private IP allocation when domR fails to start
This commit is contained in:
kishan 2010-08-18 19:43:16 +05:30
parent fb8e3ffec5
commit d202ce4c7a

View File

@ -794,6 +794,8 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
s_logger.debug("Lock on router " + routerId + " is acquired");
boolean started = false;
String vnet = null;
boolean vnetAllocated = false;
try {
final State state = router.getState();
if (state == State.Running) {
@ -847,8 +849,6 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
throw new ConcurrentOperationException("Someone else is starting the router: " + router.toString());
}
String vnet = null;
boolean vnetAllocated = false;
final boolean mirroredVols = router.isMirroredVols();
try {
event = new EventVO();
@ -862,6 +862,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
for (final UserVmVO vm : vms) {
if (vm.getVnet() != null) {
vnet = vm.getVnet();
break;
}
}
}
@ -1002,8 +1003,21 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
return _routerDao.findById(routerId);
} catch (final Throwable th) {
Transaction txn = Transaction.currentTxn();
if (th instanceof ExecutionException) {
s_logger.error("Error while starting router due to " + th.getMessage());
} else if (th instanceof ConcurrentOperationException) {
throw (ConcurrentOperationException)th;
} else if (th instanceof StorageUnavailableException) {
throw (StorageUnavailableException)th;
} else {
s_logger.error("Error while starting router", th);
}
return null;
}
} finally {
if (!started){
Transaction txn = Transaction.currentTxn();
txn.start();
if (vnetAllocated == true && vnet != null) {
_dcDao.releaseVnet(vnet, router.getDataCenterId(), router.getAccountId());
@ -1022,27 +1036,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
if (_routerDao.updateIf(router, Event.OperationFailed, null)) {
txn.commit();
}
}
if (th instanceof ExecutionException) {
s_logger.error("Error while starting router due to " + th.getMessage());
} else if (th instanceof ConcurrentOperationException) {
throw (ConcurrentOperationException)th;
} else if (th instanceof StorageUnavailableException) {
throw (StorageUnavailableException)th;
} else {
s_logger.error("Error while starting router", th);
}
return null;
}
} finally {
if (router != null) {
if(s_logger.isDebugEnabled())
s_logger.debug("Releasing lock on router " + routerId);
_routerDao.release(routerId);
}
if (!started){
EventVO event = new EventVO();
event.setUserId(1L);
event.setAccountId(router.getAccountId());
@ -1052,6 +1046,13 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
event.setStartId(startEventId);
_eventDao.persist(event);
}
if (router != null) {
if(s_logger.isDebugEnabled())
s_logger.debug("Releasing lock on router " + routerId);
_routerDao.release(routerId);
}
}
}