Repository navigation
Template cleanup : Update vm_template table to set template as removed on deletion - #4748
Conversation
|
@blueorangutan package |
|
@Pearl1594 a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2864 |
|
@blueorangutan test |
|
@Pearl1594 a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-3649)
|
| InactiveUnremovedTmpltSearch = createSearchBuilder(); | ||
| InactiveUnremovedTmpltSearch.and("state", InactiveUnremovedTmpltSearch.entity().getState(), SearchCriteria.Op.IN); | ||
| InactiveUnremovedTmpltSearch.and("removed", InactiveUnremovedTmpltSearch.entity().getRemoved(), SearchCriteria.Op.NULL); | ||
| InactiveUnremovedTmpltSearch.done(); |
There was a problem hiding this comment.
is this used anywhere?
There was a problem hiding this comment.
Thanks @DaanHoogland . It was supposed to be referenced at listUnRemovedTemplatesByStates() - fixed it.
DaanHoogland
left a comment
There was a problem hiding this comment.
minor requests, code looks good.
| List<VMTemplateZoneVO> templateZones = templateZoneDao.listByTemplateId(template.getId()); | ||
| List<Long> zoneIds = templateZones.stream().map(VMTemplateZoneVO::getZoneId).collect(Collectors.toList()); | ||
| if (zoneIds.size() > 0) { | ||
| return success; | ||
| } | ||
| template.setRemoved(new Date()); | ||
| template.setState(State.Inactive); | ||
| templateDao.update(template.getId(), template); |
There was a problem hiding this comment.
delete() ranges from line 454 to line 621. It deserves its own worker class. I won't ask that (hint hint, wink wink) but can you at least extract your new bit to a separate method?
| if (iStores == null || iStores.size() == 0) { | ||
| // Mark template as Inactive. | ||
| template.setState(VirtualMachineTemplate.State.Inactive); | ||
| templateDao.remove(template.getId()); |
There was a problem hiding this comment.
There's a templateDao member in this class and a _tmpltDao in TemplateAdapterBase, and though I like the first name better, its presence is pollution/technical debt. I think you should use the one from the based class.
| List<VMTemplateVO> vmTemplateVOS = _templateDao.listUnRemovedTemplatesByStates(VirtualMachineTemplate.State.Inactive); | ||
| for (VMTemplateVO template: vmTemplateVOS) { | ||
| template.setRemoved(new Date()); | ||
| _templateDao.update(template.getId(), template); | ||
| } |
There was a problem hiding this comment.
Can you extract this? method already reaches from l1156-1339. ( a class StorageCleaner required :| )
|
@blueorangutan package |
|
@Pearl1594 a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. [S] |
|
Packaging result: ✔️ centos7 ✔️ centos8 ✔️ debian. SL-JID 189 |
|
@blueorangutan test |
|
@Pearl1594 a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-205)
|
|
@blueorangutan package |
|
@Pearl1594 a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
| domainid=self.account.domainid, | ||
| serviceofferingid=self.service_offering.id | ||
| ) | ||
| self.cleanup.append(tmpl) |
There was a problem hiding this comment.
i'd say this, self.cleanup.append(tmpl) is supposed to go to line 1325,
and this line should read self.cleanup.append(virtual_machine)
lines 1339 and 1340 should be removed. As this code is at the moment virtual_machne will be appended to cleanup only if the create fails and self.fail(...) is not called.
a cleanup should go directly after a create (or register) and only if the remove happens for some other reason it should be removed from the list again (if a double delete would be a problem)
|
Packaging result: ✔️ centos7 ✔️ centos8 ✔️ debian. SL-JID 210 |
|
@blueorangutan package |
|
@Pearl1594 a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔️ centos7 ✔️ centos8 ✔️ debian. SL-JID 213 |
|
@blueorangutan test |
|
@Pearl1594 a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-234)
|
Description
Addresses: #4470
This PR fixes the issue noticed while deleting a template in a zone and also adds cleanup, in order to remove such templates left behind. The following is currently observed currently:
In a Zone with only 1 store:
In a Zone with > 1 store:
Notice template still appears Active when destroyed on secondary store
Post fix: On deletion of a public template registered in a zone with > 1 image store (here, 2)
With this patch, when the cleanup job is triggered, it also cleans up all templates that are marked as Inactive but not removed (reduced the cleanup interval by modifying the following global settings:
storage.cleanup.intervalandstorage.cleanup.delay)Also tested a scenario where in a template can be present in other zones as well. In such a case, when a public template is destroyed in a specific zone, the template is left as Active - if it present in other zones:
Types of changes
Bug Severity
How Has This Been Tested?
Observations and tests mentioned above