mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02: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> listImageStores();
|
||||||
|
|
||||||
List<DataStore> listImageCacheStores();
|
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.exception.ResourceAllocationException;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.storage.DataStoreRole;
|
import com.cloud.storage.DataStoreRole;
|
||||||
import com.cloud.storage.ScopeType;
|
|
||||||
import com.cloud.storage.Storage.TemplateType;
|
import com.cloud.storage.Storage.TemplateType;
|
||||||
import com.cloud.storage.StoragePool;
|
import com.cloud.storage.StoragePool;
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
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 +
|
s_logger.info("Template Sync did not find " + uniqueName + " on image store " + storeId +
|
||||||
", may request download based on available hypervisor types");
|
", may request download based on available hypervisor types");
|
||||||
if (tmpltStore != null) {
|
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.getState() == State.Ready
|
||||||
&& tmpltStore.getInstallPath() == null) {
|
&& tmpltStore.getInstallPath() == null) {
|
||||||
s_logger.info("Keep fake entry in template store table for migration of previous NFS to object store");
|
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
|
// 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.
|
// 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());
|
TemplateDataStoreVO tmpltStore = _vmTemplateStoreDao.findByStoreTemplate(storeId, tmplt.getId());
|
||||||
if (tmpltStore != null && tmpltStore.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED && tmpltStore.getState() == State.Ready
|
if (tmpltStore != null && tmpltStore.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED && tmpltStore.getState() == State.Ready
|
||||||
&& tmpltStore.getInstallPath() == null) {
|
&& tmpltStore.getInstallPath() == null) {
|
||||||
@ -685,18 +684,11 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
return null;
|
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.
|
// 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.
|
// used in migrating existing NFS secondary storage to S3.
|
||||||
@Override
|
@Override
|
||||||
public void syncTemplateToRegionStore(long templateId, DataStore store) {
|
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
|
// 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.
|
// wide store if it is not there physically.
|
||||||
TemplateInfo tmplOnStore = _templateFactory.getTemplate(templateId, store);
|
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 org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
|
||||||
|
|
||||||
import com.cloud.storage.DataStoreRole;
|
import com.cloud.storage.DataStoreRole;
|
||||||
|
import com.cloud.storage.ScopeType;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@ -82,6 +83,14 @@ public class DataStoreManagerImpl implements DataStoreManager {
|
|||||||
return stores.get(0);
|
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
|
@Override
|
||||||
public DataStore getPrimaryDataStore(long storeId) {
|
public DataStore getPrimaryDataStore(long storeId) {
|
||||||
return primaryStoreMgr.getPrimaryDataStore(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());
|
throw new CloudRuntimeException("Failed to create template" + result.getResult());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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());
|
VMTemplateZoneVO templateZone = new VMTemplateZoneVO(zoneId, templateId, new Date());
|
||||||
_tmpltZoneDao.persist(templateZone);
|
_tmpltZoneDao.persist(templateZone);
|
||||||
|
}
|
||||||
|
|
||||||
privateTemplate = _tmpltDao.findById(templateId);
|
privateTemplate = _tmpltDao.findById(templateId);
|
||||||
if (snapshotId != null) {
|
if (snapshotId != null) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user