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
This commit is contained in:
alena 2011-09-20 10:28:03 -07:00
parent 5a89ba4dbb
commit 39b3cfe340
2 changed files with 10 additions and 3 deletions

View File

@ -998,6 +998,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
s_logger.debug("Destroying # of vms (accountId=" + accountId + "): " + vms.size());
}
//no need to catch exception at this place as expunging vm should pass in order to perform further cleanup
for (UserVmVO vm : vms) {
if (!_vmMgr.expunge(vm, callerUserId, caller)) {
s_logger.error("Unable to destroy vm: " + vm.getId());
@ -1011,7 +1012,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
if (!volume.getState().equals(Volume.State.Destroy)) {
try {
_storageMgr.destroyVolume(volume);
} catch (ConcurrentOperationException ex) {
} catch (Exception ex) {
s_logger.warn("Failed to cleanup volumes as a part of account id=" + accountId + " cleanup due to Exception: ", ex);
accountCleanupNeeded = true;
}
@ -1069,7 +1070,11 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
}
return true;
} finally {
} catch (Exception ex) {
s_logger.warn("Failed to cleanup account " + account + " due to ", ex);
accountCleanupNeeded = true;
return true;
}finally {
s_logger.info("Cleanup for account " + account.getId() + (accountCleanupNeeded ? " is needed." : " is not needed."));
if (accountCleanupNeeded) {
_accountDao.markForCleanup(accountId);

View File

@ -228,7 +228,9 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
AccountVO account = findByIdIncludingRemoved(accountId);
if (!account.getNeedsCleanup()) {
account.setNeedsCleanup(true);
update(accountId, account);
if (!update(accountId, account)) {
s_logger.warn("Failed to mark account id=" + accountId + " for cleanup");
}
}
}
}