From 4d08bb89355a68e8a0e9a2f6654889d008c29ebd Mon Sep 17 00:00:00 2001 From: Koushik Das Date: Sat, 8 Nov 2014 13:17:50 +0530 Subject: [PATCH] CLOUDSTACK-7867: Delete network resulting in exception Publish event was getting called from within a DB transaction which is not allowed. --- .../engine/orchestration/NetworkOrchestrator.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java index ab5a21c7406..553bca16959 100755 --- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java @@ -2278,10 +2278,6 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra NetworkAccountVO networkAccount = _networkAccountDao.getAccountNetworkMapByNetworkId(networkFinal.getId()); if (networkAccount != null) _networkAccountDao.remove(networkAccount.getId()); - - // remove its related ACL permission - Pair, Long> networkMsg = new Pair, Long>(Network.class, networkFinal.getId()); - _messageBus.publish(_name, EntityManager.MESSAGE_REMOVE_ENTITY_EVENT, PublishScope.LOCAL, networkMsg); } NetworkOffering ntwkOff = _entityMgr.findById(NetworkOffering.class, networkFinal.getNetworkOfferingId()); @@ -2292,6 +2288,11 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra } } }); + if (_networksDao.findById(network.getId()) == null) { + // remove its related ACL permission + Pair, Long> networkMsg = new Pair, Long>(Network.class, networkFinal.getId()); + _messageBus.publish(_name, EntityManager.MESSAGE_REMOVE_ENTITY_EVENT, PublishScope.LOCAL, networkMsg); + } return true; } catch (CloudRuntimeException e) { s_logger.error("Failed to delete network", e);