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/4d08bb89 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4d08bb89 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4d08bb89 Branch: refs/heads/statscollector-graphite Commit: 4d08bb89355a68e8a0e9a2f6654889d008c29ebd Parents: e25de54 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:50:31 2014 +0530 ---------------------------------------------------------------------- .../engine/orchestration/NetworkOrchestrator.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4d08bb89/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 ab5a21c..553bca1 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);