DaanHoogland commented on code in PR #13614:
URL: https://github.com/apache/cloudstack/pull/13614#discussion_r3613842827
##########
server/src/main/java/com/cloud/user/AccountManagerImpl.java:
##########
@@ -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);
}
+
Review Comment:
```suggestion
```
##########
server/src/main/java/com/cloud/user/AccountManagerImpl.java:
##########
@@ -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);
}
+
// 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
+ 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);
Review Comment:
this is a bit unusual. the “due to” is generally thought to already imply an
exception.
##########
server/src/main/java/com/cloud/user/AccountManagerImpl.java:
##########
@@ -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);
}
+
// 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
Review Comment:
```suggestion
// Prevent boolean overwriting by checking failure
explicitly
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]