CLOUDSTACK-7867: Delete network resulting in exception Publish event was getting called from within a DB transaction which is not allowed.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/49115e03 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/49115e03 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/49115e03 Branch: refs/heads/statscollector-graphite Commit: 49115e03331f89f9032a6689fb6e6b5661fb783d Parents: 6a6d4d8 Author: Koushik Das <kous...@apache.org> Authored: Sat Nov 8 13:17:50 2014 +0530 Committer: Koushik Das <kous...@apache.org> Committed: Sat Nov 8 13:46:54 2014 +0530 ---------------------------------------------------------------------- .../engine/orchestration/NetworkOrchestrator.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49115e03/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java ---------------------------------------------------------------------- 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 8b47289..f077db9 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<Class<?>, Long> networkMsg = new Pair<Class<?>, 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<Class<?>, Long> networkMsg = new Pair<Class<?>, 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);