mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Issue #: 5775
Release vnet and private IP allocation when domR fails to start
This commit is contained in:
parent
fb8e3ffec5
commit
d202ce4c7a
@ -794,6 +794,8 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||||||
s_logger.debug("Lock on router " + routerId + " is acquired");
|
s_logger.debug("Lock on router " + routerId + " is acquired");
|
||||||
|
|
||||||
boolean started = false;
|
boolean started = false;
|
||||||
|
String vnet = null;
|
||||||
|
boolean vnetAllocated = false;
|
||||||
try {
|
try {
|
||||||
final State state = router.getState();
|
final State state = router.getState();
|
||||||
if (state == State.Running) {
|
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());
|
throw new ConcurrentOperationException("Someone else is starting the router: " + router.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
String vnet = null;
|
|
||||||
boolean vnetAllocated = false;
|
|
||||||
final boolean mirroredVols = router.isMirroredVols();
|
final boolean mirroredVols = router.isMirroredVols();
|
||||||
try {
|
try {
|
||||||
event = new EventVO();
|
event = new EventVO();
|
||||||
@ -862,6 +862,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||||||
for (final UserVmVO vm : vms) {
|
for (final UserVmVO vm : vms) {
|
||||||
if (vm.getVnet() != null) {
|
if (vm.getVnet() != null) {
|
||||||
vnet = vm.getVnet();
|
vnet = vm.getVnet();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1002,28 +1003,6 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||||||
return _routerDao.findById(routerId);
|
return _routerDao.findById(routerId);
|
||||||
} catch (final Throwable th) {
|
} catch (final Throwable th) {
|
||||||
|
|
||||||
Transaction txn = Transaction.currentTxn();
|
|
||||||
if (!started) {
|
|
||||||
txn.start();
|
|
||||||
if (vnetAllocated == true && vnet != null) {
|
|
||||||
_dcDao.releaseVnet(vnet, router.getDataCenterId(), router.getAccountId());
|
|
||||||
}
|
|
||||||
|
|
||||||
router.setVnet(null);
|
|
||||||
String privateIpAddress = router.getPrivateIpAddress();
|
|
||||||
|
|
||||||
router.setPrivateIpAddress(null);
|
|
||||||
|
|
||||||
if (privateIpAddress != null) {
|
|
||||||
_dcDao.releasePrivateIpAddress(privateIpAddress, router.getDataCenterId(), router.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (_routerDao.updateIf(router, Event.OperationFailed, null)) {
|
|
||||||
txn.commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (th instanceof ExecutionException) {
|
if (th instanceof ExecutionException) {
|
||||||
s_logger.error("Error while starting router due to " + th.getMessage());
|
s_logger.error("Error while starting router due to " + th.getMessage());
|
||||||
} else if (th instanceof ConcurrentOperationException) {
|
} else if (th instanceof ConcurrentOperationException) {
|
||||||
@ -1036,13 +1015,28 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (router != null) {
|
|
||||||
|
if (!started){
|
||||||
if(s_logger.isDebugEnabled())
|
Transaction txn = Transaction.currentTxn();
|
||||||
s_logger.debug("Releasing lock on router " + routerId);
|
txn.start();
|
||||||
_routerDao.release(routerId);
|
if (vnetAllocated == true && vnet != null) {
|
||||||
}
|
_dcDao.releaseVnet(vnet, router.getDataCenterId(), router.getAccountId());
|
||||||
if (!started){
|
}
|
||||||
|
|
||||||
|
router.setVnet(null);
|
||||||
|
String privateIpAddress = router.getPrivateIpAddress();
|
||||||
|
|
||||||
|
router.setPrivateIpAddress(null);
|
||||||
|
|
||||||
|
if (privateIpAddress != null) {
|
||||||
|
_dcDao.releasePrivateIpAddress(privateIpAddress, router.getDataCenterId(), router.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (_routerDao.updateIf(router, Event.OperationFailed, null)) {
|
||||||
|
txn.commit();
|
||||||
|
}
|
||||||
|
|
||||||
EventVO event = new EventVO();
|
EventVO event = new EventVO();
|
||||||
event.setUserId(1L);
|
event.setUserId(1L);
|
||||||
event.setAccountId(router.getAccountId());
|
event.setAccountId(router.getAccountId());
|
||||||
@ -1051,7 +1045,14 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||||||
event.setLevel(EventVO.LEVEL_ERROR);
|
event.setLevel(EventVO.LEVEL_ERROR);
|
||||||
event.setStartId(startEventId);
|
event.setStartId(startEventId);
|
||||||
_eventDao.persist(event);
|
_eventDao.persist(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (router != null) {
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
s_logger.debug("Releasing lock on router " + routerId);
|
||||||
|
_routerDao.release(routerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user