mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Fix CLOUDSTACK-2525: clean up db entries in vm_template and
template_store_ref in case of template creation failure.
This commit is contained in:
parent
ef541a2a7b
commit
565bdfb27b
@ -37,6 +37,8 @@ public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO, Lo
|
||||
|
||||
public void deletePrimaryRecordsForStore(long id);
|
||||
|
||||
public void deletePrimaryRecordsForTemplate(long templateId);
|
||||
|
||||
List<TemplateDataStoreVO> listByTemplateStore(long templateId, long storeId);
|
||||
|
||||
List<TemplateDataStoreVO> listByTemplateStoreStatus(long templateId, long storeId, State... states);
|
||||
|
||||
@ -182,6 +182,15 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePrimaryRecordsForTemplate(long templateId) {
|
||||
SearchCriteria<TemplateDataStoreVO> sc = templateSearch.create();
|
||||
sc.setParameters("template_id", templateId);
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
expunge(sc);
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateDataStoreVO> listByTemplateStore(long templateId, long storeId) {
|
||||
|
||||
@ -1456,6 +1456,8 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
if (privateTemplate == null) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
// Remove the template_store_ref record first, otherwise, we cannot remove the template record due to FK constraints
|
||||
this._tmplStoreDao.deletePrimaryRecordsForTemplate(templateId);
|
||||
// Remove the template record
|
||||
this._tmpltDao.expunge(templateId);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user