Skip to content

Commit bddc2b9

Browse files
committed
bug 11487: catch all exceptions in cleanupAccount, and mark the account for cleanup when the exception is caught.
status 11487: resolved fixed Reviewed-by: will@cloud.com
1 parent b6f58b7 commit bddc2b9

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎server/src/com/cloud/user/AccountManagerImpl.java‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,7 @@ public boolean cleanupAccount(AccountVO account, long callerUserId, Account call
983983
s_logger.debug("Destroying # of vms (accountId=" + accountId + "): " + vms.size());
984984
}
985985

986+
//no need to catch exception at this place as expunging vm should pass in order to perform further cleanup
986987
for (UserVmVO vm : vms) {
987988
if (!_vmMgr.expunge(vm, callerUserId, caller)) {
988989
s_logger.error("Unable to destroy vm: " + vm.getId());
@@ -996,7 +997,7 @@ public boolean cleanupAccount(AccountVO account, long callerUserId, Account call
996997
if (!volume.getState().equals(Volume.State.Destroy)) {
997998
try {
998999
_storageMgr.destroyVolume(volume);
999-
} catch (ConcurrentOperationException ex) {
1000+
} catch (Exception ex) {
10001001
s_logger.warn("Failed to cleanup volumes as a part of account id=" + accountId + " cleanup due to Exception: ", ex);
10011002
accountCleanupNeeded = true;
10021003
}
@@ -1054,7 +1055,11 @@ public boolean cleanupAccount(AccountVO account, long callerUserId, Account call
10541055
}
10551056

10561057
return true;
1057-
} finally {
1058+
} catch (Exception ex) {
1059+
s_logger.warn("Failed to cleanup account " + account + " due to ", ex);
1060+
accountCleanupNeeded = true;
1061+
return true;
1062+
}finally {
10581063
s_logger.info("Cleanup for account " + account.getId() + (accountCleanupNeeded ? " is needed." : " is not needed."));
10591064
if (accountCleanupNeeded) {
10601065
_accountDao.markForCleanup(accountId);

‎server/src/com/cloud/user/dao/AccountDaoImpl.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ public void markForCleanup(long accountId) {
228228
AccountVO account = findByIdIncludingRemoved(accountId);
229229
if (!account.getNeedsCleanup()) {
230230
account.setNeedsCleanup(true);
231-
update(accountId, account);
231+
if (!update(accountId, account)) {
232+
s_logger.warn("Failed to mark account id=" + accountId + " for cleanup");
233+
}
232234
}
233235
}
234236
}

0 commit comments

Comments
 (0)