mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-17 02:53:18 +01:00
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 <marcus@betterservers.com> 1375204815 -0600
This commit is contained in:
parent
2b0946c6db
commit
566ce3e625
@ -200,6 +200,10 @@ public class ActionEventUtils {
|
|||||||
|
|
||||||
private static long getDomainId(long accountId){
|
private static long getDomainId(long accountId){
|
||||||
AccountVO account = _accountDao.findByIdIncludingRemoved(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();
|
return account.getDomainId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2805,13 +2805,6 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
|||||||
return false;
|
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
|
// Make sure that there are no user vms in the network that are not Expunged/Error
|
||||||
List<UserVmVO> userVms = _userVmDao.listByNetworkIdAndStates(networkId);
|
List<UserVmVO> userVms = _userVmDao.listByNetworkIdAndStates(networkId);
|
||||||
|
|
||||||
@ -2822,6 +2815,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
|
//In Basic zone, make sure that there are no non-removed console proxies and SSVMs using the network
|
||||||
DataCenter zone = _configMgr.getZone(network.getDataCenterId());
|
DataCenter zone = _configMgr.getZone(network.getDataCenterId());
|
||||||
if (zone.getNetworkType() == NetworkType.Basic) {
|
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user