mirror of https://github.com/apache/cloudstack.git
bug 14103: mark account for cleanup only in cleanupAccount and disableAccount method, not in the callers methods
status 14103: resolved fixed
This commit is contained in:
parent
854997aab6
commit
fb2ed48304
|
|
@ -1078,6 +1078,9 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
s_logger.info("Cleanup for account " + account.getId() + (accountCleanupNeeded ? " is needed." : " is not needed."));
|
||||
if (accountCleanupNeeded) {
|
||||
_accountDao.markForCleanup(accountId);
|
||||
} else {
|
||||
account.setNeedsCleanup(false);
|
||||
_accountDao.update(accountId, account);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1101,9 +1104,18 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
success = _accountDao.update(Long.valueOf(accountId), acctForUpdate);
|
||||
|
||||
if (success) {
|
||||
if (!doDisableAccount(accountId)) {
|
||||
s_logger.warn("Failed to disable account " + account + " resources as a part of disableAccount call, marking the account for cleanup");
|
||||
_accountDao.markForCleanup(accountId);
|
||||
boolean disableAccountResult = false;
|
||||
try {
|
||||
disableAccountResult = doDisableAccount(accountId);
|
||||
} finally {
|
||||
if (!disableAccountResult) {
|
||||
s_logger.warn("Failed to disable account " + account + " resources as a part of disableAccount call, marking the account for cleanup");
|
||||
_accountDao.markForCleanup(accountId);
|
||||
} else {
|
||||
acctForUpdate = _accountDao.createForUpdate();
|
||||
account.setNeedsCleanup(false);
|
||||
_accountDao.update(accountId, account);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1773,14 +1785,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
s_logger.info("Found " + removedAccounts.size() + " removed accounts to cleanup");
|
||||
for (AccountVO account : removedAccounts) {
|
||||
s_logger.debug("Cleaning up " + account.getId());
|
||||
try {
|
||||
if (cleanupAccount(account, getSystemUser().getId(), getSystemAccount())) {
|
||||
account.setNeedsCleanup(false);
|
||||
_accountDao.update(account.getId(), account);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Skipping due to error on account " + account.getId(), e);
|
||||
}
|
||||
cleanupAccount(account, getSystemUser().getId(), getSystemAccount());
|
||||
}
|
||||
|
||||
//cleanup disabled accounts
|
||||
|
|
@ -1789,10 +1794,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
for (AccountVO account : disabledAccounts) {
|
||||
s_logger.debug("Cleaning up " + account.getId());
|
||||
try {
|
||||
if (disableAccount(account.getId())) {
|
||||
account.setNeedsCleanup(false);
|
||||
_accountDao.update(account.getId(), account);
|
||||
}
|
||||
disableAccount(account.getId());
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Skipping due to error on account " + account.getId(), e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue