Skip to content

Commit 0156ec7

Browse files
committed
bug 11497:
1. remove Garbagecollection primary storage allocator. other storage allocators fails may because there is primary storage with the same tag, it is not caused by no primary storage capacity. 2. delete template will try to delete templates in secondary storage in the API. status 11497: resolved fixed GarbageCollecting Conflicts: server/src/com/cloud/template/HyervisorTemplateAdapter.java
1 parent c0f87a2 commit 0156ec7

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎client/tomcatconf/components.xml.in‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
<adapters key="com.cloud.storage.allocator.StoragePoolAllocator">
4444
<adapter name="LocalStorage" class="com.cloud.storage.allocator.LocalStoragePoolAllocator"/>
4545
<adapter name="Storage" class="com.cloud.storage.allocator.FirstFitStoragePoolAllocator"/>
46-
<adapter name="GarbageCollecting" class="com.cloud.storage.allocator.GarbageCollectingStoragePoolAllocator"/>
4746
</adapters>
4847
<adapters key="com.cloud.agent.manager.allocator.PodAllocator">
4948
<adapter name="User First" class="com.cloud.agent.manager.allocator.impl.UserConcentratedAllocator"/>

‎server/src/com/cloud/template/HyervisorTemplateAdapter.java‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
import org.apache.log4j.Logger;
1313

14+
import com.cloud.agent.AgentManager;
15+
import com.cloud.agent.api.Answer;
16+
import com.cloud.agent.api.storage.DeleteTemplateCommand;
1417
import com.cloud.api.commands.DeleteIsoCmd;
1518
import com.cloud.api.commands.DeleteTemplateCmd;
1619
import com.cloud.api.commands.RegisterIsoCmd;
@@ -40,6 +43,7 @@ public class HyervisorTemplateAdapter extends TemplateAdapterBase implements Tem
4043
private final static Logger s_logger = Logger.getLogger(HyervisorTemplateAdapter.class);
4144
@Inject DownloadMonitor _downloadMonitor;
4245
@Inject SecondaryStorageVmManager _ssvmMgr;
46+
@Inject AgentManager _agentMgr;
4347

4448
private String validateUrl(String url) {
4549
try {
@@ -176,7 +180,6 @@ public boolean delete(TemplateProfile profile) {
176180
List<VMTemplateHostVO> templateHostVOs = _tmpltHostDao.listByHostTemplate(hostId, templateId);
177181
for (VMTemplateHostVO templateHostVO : templateHostVOs) {
178182
VMTemplateHostVO lock = _tmpltHostDao.acquireInLockTable(templateHostVO.getId());
179-
180183
try {
181184
if (lock == null) {
182185
s_logger.debug("Failed to acquire lock when deleting templateHostVO with ID: " + templateHostVO.getId());
@@ -187,6 +190,19 @@ public boolean delete(TemplateProfile profile) {
187190
_usageEventDao.persist(usageEvent);
188191
templateHostVO.setDestroyed(true);
189192
_tmpltHostDao.update(templateHostVO.getId(), templateHostVO);
193+
String installPath = templateHostVO.getInstallPath();
194+
if (installPath != null) {
195+
Answer answer = _agentMgr.sendToSecStorage(secondaryStorageHost, new DeleteTemplateCommand(secondaryStorageHost.getStorageUrl(), installPath));
196+
197+
if (answer == null || !answer.getResult()) {
198+
s_logger.debug("Failed to delete " + templateHostVO + " due to " + ((answer == null) ? "answer is null" : answer.getDetails()));
199+
} else {
200+
_tmpltHostDao.remove(templateHostVO.getId());
201+
s_logger.debug("Deleted template at: " + installPath);
202+
}
203+
} else {
204+
_tmpltHostDao.remove(templateHostVO.getId());
205+
}
190206
VMTemplateZoneVO templateZone = _tmpltZoneDao.findByZoneTemplate(sZoneId, templateId);
191207

192208
if (templateZone != null) {

0 commit comments

Comments
 (0)