cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [16/41] git commit: updated refs/heads/4.4 to 010a217
Date Thu, 11 Dec 2014 16:53:56 GMT
CLOUDSTACK-7872: network getting shutdown inspite of running VM's in the network

(cherry picked from commit 709bf074de9f8f22e6a71362551c4867be884e4b)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

Conflicts:
	engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java

Conflicts:
	engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java


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

Branch: refs/heads/4.4
Commit: c6ef739e25b9f566f11a8e069e6f7aeef15787f0
Parents: a2a7e39
Author: Jayapal <jayapal@apache.org>
Authored: Fri Nov 7 09:37:32 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Thu Dec 11 20:35:30 2014 +0530

----------------------------------------------------------------------
 .../com/cloud/network/dao/NetworkDaoImpl.java   |  2 --
 engine/schema/src/com/cloud/vm/dao/NicDao.java  |  2 ++
 .../schema/src/com/cloud/vm/dao/NicDaoImpl.java | 22 ++++++++++++++++++++
 .../src/com/cloud/network/NetworkModelImpl.java |  7 +++++++
 4 files changed, 31 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c6ef739e/engine/schema/src/com/cloud/network/dao/NetworkDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkDaoImpl.java b/engine/schema/src/com/cloud/network/dao/NetworkDaoImpl.java
index 0c556c8..4a07455 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkDaoImpl.java
@@ -244,7 +244,6 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long>
implements N
         GarbageCollectedSearch = createSearchBuilder(Long.class);
         GarbageCollectedSearch.selectFields(GarbageCollectedSearch.entity().getId());
         SearchBuilder<NetworkOpVO> join7 = _ntwkOpDao.createSearchBuilder();
-        join7.and("activenics", join7.entity().getActiveNicsCount(), Op.EQ);
         join7.and("gc", join7.entity().isGarbageCollected(), Op.EQ);
         join7.and("check", join7.entity().isCheckForGc(), Op.EQ);
         GarbageCollectedSearch.join("ntwkOpGC", join7, GarbageCollectedSearch.entity().getId(),
join7.entity().getId(), JoinBuilder.JoinType.INNER);
@@ -438,7 +437,6 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long>
implements N
     public List<Long> findNetworksToGarbageCollect() {
         SearchCriteria<Long> sc = GarbageCollectedSearch.create();
         sc.setJoinParameters("ntwkOffGC", "isPersistent", false);
-        sc.setJoinParameters("ntwkOpGC", "activenics", 0);
         sc.setJoinParameters("ntwkOpGC", "gc", true);
         sc.setJoinParameters("ntwkOpGC", "check", true);
         return customSearch(sc, null);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c6ef739e/engine/schema/src/com/cloud/vm/dao/NicDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/NicDao.java b/engine/schema/src/com/cloud/vm/dao/NicDao.java
index a7ad016..9f153f8 100644
--- a/engine/schema/src/com/cloud/vm/dao/NicDao.java
+++ b/engine/schema/src/com/cloud/vm/dao/NicDao.java
@@ -74,4 +74,6 @@ public interface NicDao extends GenericDao<NicVO, Long> {
     List<NicVO> listByNetworkIdTypeAndGatewayAndBroadcastUri(long networkId, VirtualMachine.Type
vmType, String gateway, URI broadcastUri);
 
     int countNicsForStartingVms(long networkId);
+
+    int countNicsForRunningVms(long networkId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c6ef739e/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java
index 2a9a602..ca44b63 100644
--- a/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java
@@ -46,6 +46,7 @@ public class NicDaoImpl extends GenericDaoBase<NicVO, Long> implements
NicDao {
     private SearchBuilder<NicVO> NonReleasedSearch;
     private GenericSearchBuilder<NicVO, Integer> CountBy;
     private GenericSearchBuilder<NicVO, Integer> CountByForStartingVms;
+    private GenericSearchBuilder<NicVO, Integer> CountByForRunningVms;
 
     @Inject
     VMInstanceDao _vmDao;
@@ -95,6 +96,17 @@ public class NicDaoImpl extends GenericDaoBase<NicVO, Long> implements
NicDao {
         join1.and("state", join1.entity().getState(), Op.EQ);
         CountByForStartingVms.join("vm", join1, CountByForStartingVms.entity().getInstanceId(),
join1.entity().getId(), JoinBuilder.JoinType.INNER);
         CountByForStartingVms.done();
+
+        CountByForRunningVms = createSearchBuilder(Integer.class);
+        CountByForRunningVms.select(null, Func.COUNT, CountByForRunningVms.entity().getId());
+        CountByForRunningVms.and("networkId", CountByForRunningVms.entity().getNetworkId(),
Op.EQ);
+        CountByForRunningVms.and("removed", CountByForRunningVms.entity().getRemoved(), Op.NULL);
+        SearchBuilder<VMInstanceVO> join2 = _vmDao.createSearchBuilder();
+        join2.and("state", join2.entity().getState(), Op.EQ);
+        join2.and("type", join2.entity().getType(), Op.EQ);
+        CountByForRunningVms.join("vm", join2, CountByForRunningVms.entity().getInstanceId(),
join2.entity().getId(), JoinBuilder.JoinType.INNER);
+        CountByForRunningVms.done();
+
     }
 
     @Override
@@ -291,4 +303,14 @@ public class NicDaoImpl extends GenericDaoBase<NicVO, Long> implements
NicDao {
         List<Integer> results = customSearch(sc, null);
         return results.get(0);
     }
+
+    @Override
+    public int countNicsForRunningVms(long networkId) {
+        SearchCriteria<Integer> sc = CountByForRunningVms.create();
+        sc.setParameters("networkId", networkId);
+        sc.setJoinParameters("vm", "state", VirtualMachine.State.Running);
+        sc.setJoinParameters("vm", "type", VirtualMachine.Type.User);
+        List<Integer> results = customSearch(sc, null);
+        return results.get(0);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c6ef739e/server/src/com/cloud/network/NetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkModelImpl.java b/server/src/com/cloud/network/NetworkModelImpl.java
index 3d2b133..cb3c326 100755
--- a/server/src/com/cloud/network/NetworkModelImpl.java
+++ b/server/src/com/cloud/network/NetworkModelImpl.java
@@ -2225,6 +2225,13 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel
{
             return false;
         }
 
+        // Due to VMSync issue, there can be cases where nic count is zero, but there can
be VM's running in the network
+        // so add extra guard to check if network GC is actially required.
+        if (_nicDao.countNicsForRunningVms(networkId) > 0) {
+            s_logger.debug("Network id=" + networkId + " is not ready for GC as it has vms
that are Running at the moment");
+            return false;
+        }
+
         return true;
     }
 


Mime
View raw message