mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-5653:S3 object store as Secondary Storage, the template
created from different zone is not available for the other zones.
This commit is contained in:
parent
526af5e326
commit
6f800506fd
@ -42,4 +42,6 @@ public interface DataStoreManager {
|
||||
List<DataStore> listImageStores();
|
||||
|
||||
List<DataStore> listImageCacheStores();
|
||||
|
||||
boolean isRegionStore(DataStore store);
|
||||
}
|
||||
|
||||
@ -75,7 +75,6 @@ import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.ScopeType;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
@ -394,7 +393,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
s_logger.info("Template Sync did not find " + uniqueName + " on image store " + storeId +
|
||||
", may request download based on available hypervisor types");
|
||||
if (tmpltStore != null) {
|
||||
if (isRegionStore(store) && tmpltStore.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED
|
||||
if (_storeMgr.isRegionStore(store) && tmpltStore.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED
|
||||
&& tmpltStore.getState() == State.Ready
|
||||
&& tmpltStore.getInstallPath() == null) {
|
||||
s_logger.info("Keep fake entry in template store table for migration of previous NFS to object store");
|
||||
@ -435,7 +434,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
|
||||
// if this is a region store, and there is already an DOWNLOADED entry there without install_path information, which
|
||||
// means that this is a duplicate entry from migration of previous NFS to staging.
|
||||
if (isRegionStore(store)) {
|
||||
if (_storeMgr.isRegionStore(store)) {
|
||||
TemplateDataStoreVO tmpltStore = _vmTemplateStoreDao.findByStoreTemplate(storeId, tmplt.getId());
|
||||
if (tmpltStore != null && tmpltStore.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED && tmpltStore.getState() == State.Ready
|
||||
&& tmpltStore.getInstallPath() == null) {
|
||||
@ -685,18 +684,11 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isRegionStore(DataStore store) {
|
||||
if (store.getScope().getScopeType() == ScopeType.ZONE && store.getScope().getScopeId() == null)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// This routine is used to push templates currently on cache store, but not in region store to region store.
|
||||
// used in migrating existing NFS secondary storage to S3.
|
||||
@Override
|
||||
public void syncTemplateToRegionStore(long templateId, DataStore store) {
|
||||
if (isRegionStore(store)) {
|
||||
if (_storeMgr.isRegionStore(store)) {
|
||||
// if template is on region wide object store, check if it is really downloaded there (by checking install_path). Sync template to region
|
||||
// wide store if it is not there physically.
|
||||
TemplateInfo tmplOnStore = _templateFactory.getTemplate(templateId, store);
|
||||
|
||||
@ -32,6 +32,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
|
||||
import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
|
||||
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.ScopeType;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Component
|
||||
@ -82,6 +83,14 @@ public class DataStoreManagerImpl implements DataStoreManager {
|
||||
return stores.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegionStore(DataStore store) {
|
||||
if (store.getScope().getScopeType() == ScopeType.ZONE && store.getScope().getScopeId() == null)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataStore getPrimaryDataStore(long storeId) {
|
||||
return primaryStoreMgr.getPrimaryDataStore(storeId);
|
||||
|
||||
@ -1395,8 +1395,14 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
throw new CloudRuntimeException("Failed to create template" + result.getResult());
|
||||
}
|
||||
|
||||
VMTemplateZoneVO templateZone = new VMTemplateZoneVO(zoneId, templateId, new Date());
|
||||
_tmpltZoneDao.persist(templateZone);
|
||||
// create entries in template_zone_ref table
|
||||
if (_dataStoreMgr.isRegionStore(store)) {
|
||||
// template created on region store
|
||||
_tmpltSvr.associateTemplateToZone(templateId, null);
|
||||
} else {
|
||||
VMTemplateZoneVO templateZone = new VMTemplateZoneVO(zoneId, templateId, new Date());
|
||||
_tmpltZoneDao.persist(templateZone);
|
||||
}
|
||||
|
||||
privateTemplate = _tmpltDao.findById(templateId);
|
||||
if (snapshotId != null) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user