Skip to content

Commit 106ec71

Browse files
committed
Revert "CLOUDSTACK-7872: network getting shutdown inspite of running VM's in the network"
This reverts commit 709bf07. Network GC is broken with out-of-band VM movements due to the original commit, so reverting.
1 parent 51ee900 commit 106ec71

4 files changed

Lines changed: 2 additions & 31 deletions

File tree

‎engine/schema/src/com/cloud/network/dao/NetworkDaoImpl.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ protected void init() {
244244
GarbageCollectedSearch = createSearchBuilder(Long.class);
245245
GarbageCollectedSearch.selectFields(GarbageCollectedSearch.entity().getId());
246246
SearchBuilder<NetworkOpVO> join7 = _ntwkOpDao.createSearchBuilder();
247+
join7.and("activenics", join7.entity().getActiveNicsCount(), Op.EQ);
247248
join7.and("gc", join7.entity().isGarbageCollected(), Op.EQ);
248249
join7.and("check", join7.entity().isCheckForGc(), Op.EQ);
249250
GarbageCollectedSearch.join("ntwkOpGC", join7, GarbageCollectedSearch.entity().getId(), join7.entity().getId(), JoinBuilder.JoinType.INNER);
@@ -437,6 +438,7 @@ public int getActiveNicsIn(long networkId) {
437438
public List<Long> findNetworksToGarbageCollect() {
438439
SearchCriteria<Long> sc = GarbageCollectedSearch.create();
439440
sc.setJoinParameters("ntwkOffGC", "isPersistent", false);
441+
sc.setJoinParameters("ntwkOpGC", "activenics", 0);
440442
sc.setJoinParameters("ntwkOpGC", "gc", true);
441443
sc.setJoinParameters("ntwkOpGC", "check", true);
442444
return customSearch(sc, null);

‎engine/schema/src/com/cloud/vm/dao/NicDao.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,4 @@ public interface NicDao extends GenericDao<NicVO, Long> {
7474
List<NicVO> listByNetworkIdTypeAndGatewayAndBroadcastUri(long networkId, VirtualMachine.Type vmType, String gateway, URI broadcastUri);
7575

7676
int countNicsForStartingVms(long networkId);
77-
78-
int countNicsForRunningVms(long networkId);
7977
}

‎engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public class NicDaoImpl extends GenericDaoBase<NicVO, Long> implements NicDao {
4646
private SearchBuilder<NicVO> NonReleasedSearch;
4747
private GenericSearchBuilder<NicVO, Integer> CountBy;
4848
private GenericSearchBuilder<NicVO, Integer> CountByForStartingVms;
49-
private GenericSearchBuilder<NicVO, Integer> CountByForRunningVms;
5049

5150
@Inject
5251
VMInstanceDao _vmDao;
@@ -96,17 +95,6 @@ protected void init() {
9695
join1.and("state", join1.entity().getState(), Op.EQ);
9796
CountByForStartingVms.join("vm", join1, CountByForStartingVms.entity().getInstanceId(), join1.entity().getId(), JoinBuilder.JoinType.INNER);
9897
CountByForStartingVms.done();
99-
100-
CountByForRunningVms = createSearchBuilder(Integer.class);
101-
CountByForRunningVms.select(null, Func.COUNT, CountByForRunningVms.entity().getId());
102-
CountByForRunningVms.and("networkId", CountByForRunningVms.entity().getNetworkId(), Op.EQ);
103-
CountByForRunningVms.and("removed", CountByForRunningVms.entity().getRemoved(), Op.NULL);
104-
SearchBuilder<VMInstanceVO> join2 = _vmDao.createSearchBuilder();
105-
join2.and("state", join2.entity().getState(), Op.EQ);
106-
join2.and("type", join2.entity().getType(), Op.EQ);
107-
CountByForRunningVms.join("vm", join2, CountByForRunningVms.entity().getInstanceId(), join2.entity().getId(), JoinBuilder.JoinType.INNER);
108-
CountByForRunningVms.done();
109-
11098
}
11199

112100
@Override
@@ -303,14 +291,4 @@ public int countNicsForStartingVms(long networkId) {
303291
List<Integer> results = customSearch(sc, null);
304292
return results.get(0);
305293
}
306-
307-
@Override
308-
public int countNicsForRunningVms(long networkId) {
309-
SearchCriteria<Integer> sc = CountByForRunningVms.create();
310-
sc.setParameters("networkId", networkId);
311-
sc.setJoinParameters("vm", "state", VirtualMachine.State.Running);
312-
sc.setJoinParameters("vm", "type", VirtualMachine.Type.User);
313-
List<Integer> results = customSearch(sc, null);
314-
return results.get(0);
315-
}
316294
}

‎server/src/com/cloud/network/NetworkModelImpl.java‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,13 +2232,6 @@ public boolean isNetworkReadyForGc(long networkId) {
22322232
return false;
22332233
}
22342234

2235-
// Due to VMSync issue, there can be cases where nic count is zero, but there can be VM's running in the network
2236-
// so add extra guard to check if network GC is actially required.
2237-
if (_nicDao.countNicsForRunningVms(networkId) > 0) {
2238-
s_logger.debug("Network id=" + networkId + " is not ready for GC as it has vms that are Running at the moment");
2239-
return false;
2240-
}
2241-
22422235
return true;
22432236
}
22442237

0 commit comments

Comments
 (0)