You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ml...@apache.org on 2013/07/30 19:22:51 UTC

git commit: updated refs/heads/4.2 to f91c0f3

Updated Branches:
  refs/heads/4.2 155b9df8e -> f91c0f3cb


Summary: Fix null pointer and op_networks blocker to account cleanup

Detail: Accounts can fail in cleanup/gc process due to inconsistent op_networks
table and null pointer in looking up account for event publishing.

BUG-ID: CLOUDSTACK-3957
Signed-off-by: Marcus Sorensen <ma...@betterservers.com> 1375204815 -0600


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f91c0f3c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f91c0f3c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f91c0f3c

Branch: refs/heads/4.2
Commit: f91c0f3cb2729a8952a898f3e88b3cf23764f798
Parents: 155b9df
Author: Marcus Sorensen <ma...@betterservers.com>
Authored: Tue Jul 30 11:20:15 2013 -0600
Committer: Marcus Sorensen <ma...@betterservers.com>
Committed: Tue Jul 30 11:20:15 2013 -0600

----------------------------------------------------------------------
 server/src/com/cloud/event/ActionEventUtils.java    |  4 ++++
 .../src/com/cloud/network/NetworkManagerImpl.java   | 16 +++++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f91c0f3c/server/src/com/cloud/event/ActionEventUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/event/ActionEventUtils.java b/server/src/com/cloud/event/ActionEventUtils.java
index 906689f..5956eae 100755
--- a/server/src/com/cloud/event/ActionEventUtils.java
+++ b/server/src/com/cloud/event/ActionEventUtils.java
@@ -193,6 +193,10 @@ public class ActionEventUtils {
 
     private static long getDomainId(long accountId){
         AccountVO account = _accountDao.findByIdIncludingRemoved(accountId);
+        if (account == null) {
+            s_logger.error("Failed to find account(including removed ones) by id '" + accountId + "'");
+            return 0;
+        }
         return account.getDomainId();
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f91c0f3c/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index b112199..c9380f8 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -2878,13 +2878,6 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
             return false;
         }
 
-        // Don't allow to delete network via api call when it has vms assigned to it
-        int nicCount = getActiveNicsInNetwork(networkId);
-        if (nicCount > 0) {
-            s_logger.debug("Unable to remove the network id=" + networkId + " as it has active Nics.");
-            return false;
-        }
-
         // Make sure that there are no user vms in the network that are not Expunged/Error
         List<UserVmVO> userVms = _userVmDao.listByNetworkIdAndStates(networkId);
 
@@ -2895,6 +2888,15 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
             }
         }
 
+        // Don't allow to delete network via api call when it has vms assigned to it
+        int nicCount = getActiveNicsInNetwork(networkId);
+        if (nicCount > 0) {
+            s_logger.debug("The network id=" + networkId + " has active Nics, but shouldn't.");
+            // at this point we have already determined that there are no active user vms in network
+            // if the op_networks table shows active nics, it's a bug in releasing nics updating op_networks
+            _networksDao.changeActiveNicsBy(networkId, (-1 * nicCount)); 
+        }
+
         //In Basic zone, make sure that there are no non-removed console proxies and SSVMs using the network
         DataCenter zone = _configMgr.getZone(network.getDataCenterId());
         if (zone.getNetworkType() == NetworkType.Basic) {