Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions server/src/main/java/com/cloud/user/AccountManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1016,15 +1016,20 @@ protected boolean cleanupAccount(AccountVO account, long callerUserId, Account c
logger.debug("Successfully deleted snapshots directories for all volumes under account {} across all zones", account);
}


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

// clean up templates
List<VMTemplateVO> userTemplates = _templateDao.listByAccountId(accountId);
boolean allTemplatesDeleted = true;
for (VMTemplateVO template : userTemplates) {
if (template.getRemoved() == null) {
try {
allTemplatesDeleted = _tmpltMgr.delete(callerUserId, template.getId(), null);
// Fix 1: Prevent boolean overwriting by checking failure explicitly

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Fix 1: Prevent boolean overwriting by checking failure explicitly
// Prevent boolean overwriting by checking failure explicitly

if (!_tmpltMgr.delete(callerUserId, template.getId(), null)) {
logger.warn("TemplateManager returned false when deleting template {} for account {}", template, account);
allTemplatesDeleted = false;
}
} catch (Exception e) {
logger.warn("Failed to delete template {} while removing account {} due to: ", template, account, e);
logger.warn("Failed to delete template {} while removing account {} due to exception: ", template, account, e);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bit unusual. the “due to” is generally thought to already imply an exception.

allTemplatesDeleted = false;
}
}
Expand Down
Loading