Skip to content

Commit 9055610

Browse files
Remove duplicate network state checks before shutdown network (#8462)
1 parent 313a165 commit 9055610

2 files changed

Lines changed: 165 additions & 124 deletions

File tree

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3026,30 +3026,21 @@ protected void checkL2OfferingServices(NetworkOfferingVO ntwkOff) {
30263026
@Override
30273027
@DB
30283028
public boolean shutdownNetwork(final long networkId, final ReservationContext context, final boolean cleanupElements) {
3029-
NetworkVO network = _networksDao.findById(networkId);
3030-
if (network.getState() == Network.State.Allocated) {
3031-
s_logger.debug("Network is already shutdown: " + network);
3032-
return true;
3033-
}
3034-
3035-
if (network.getState() != Network.State.Implemented && network.getState() != Network.State.Shutdown) {
3036-
s_logger.debug("Network is not implemented: " + network);
3037-
return false;
3038-
}
3039-
3029+
NetworkVO network = null;
30403030
try {
30413031
//do global lock for the network
30423032
network = _networksDao.acquireInLockTable(networkId, NetworkLockTimeout.value());
30433033
if (network == null) {
3044-
s_logger.warn("Unable to acquire lock for the network " + network + " as a part of network shutdown");
3034+
s_logger.warn("Network with id: " + networkId + " doesn't exist, or unable to acquire lock for it as a part of network shutdown");
30453035
return false;
30463036
}
3037+
30473038
if (s_logger.isDebugEnabled()) {
30483039
s_logger.debug("Lock is acquired for network " + network + " as a part of network shutdown");
30493040
}
30503041

30513042
if (network.getState() == Network.State.Allocated) {
3052-
s_logger.debug("Network is already shutdown: " + network);
3043+
s_logger.debug(String.format("Network [%s] is in Allocated state, no need to shutdown.", network));
30533044
return true;
30543045
}
30553046

0 commit comments

Comments
 (0)