-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Delete template from storage pool instantly if no volume is using it #11782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.20
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -150,6 +150,16 @@ public VMTemplateStoragePoolVO findByPoolTemplate(long poolId, long templateId, | |||||||||||||||||||
return findOneIncludingRemovedBy(sc); | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
@Override | ||||||||||||||||||||
public List<VMTemplateStoragePoolVO> listByPoolIdsAndTemplate(List<Long> poolIds, Long templateId) { | ||||||||||||||||||||
SearchCriteria<VMTemplateStoragePoolVO> sc = PoolTemplateSearch.create(); | ||||||||||||||||||||
if (CollectionUtils.isNotEmpty(poolIds)) { | ||||||||||||||||||||
sc.setParameters("pool_id", poolIds.toArray()); | ||||||||||||||||||||
} | ||||||||||||||||||||
Comment on lines
+155
to
+158
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When poolIds is empty, the search criteria will not filter by pool_id, which could return all template-pool relationships for the given templateId instead of an empty result. Consider adding an early return for empty poolIds list to avoid unintended behavior.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||
sc.setParameters("template_id", templateId); | ||||||||||||||||||||
return listBy(sc); | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
@Override | ||||||||||||||||||||
public List<VMTemplateStoragePoolVO> listByTemplateStatus(long templateId, VMTemplateStoragePoolVO.Status downloadState) { | ||||||||||||||||||||
SearchCriteria<VMTemplateStoragePoolVO> sc = TemplateStatusSearch.create(); | ||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abh1sar do we really need a global setting for this usecase, I think we can directly delete the template if there is no usage found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@harikrishna-patnala I added it as a failsafe or in case someone doesn't care about how faster the space is reclaimed, but doesn't want to risk any kind of data loss. Also in case someone wants to use the setting
storage.template.cleanup.enabled=false
orstorage.cleanup.enabled=false
where the deleted template is never cleaned up.