mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-5451:Restart MS after migrating NFS image store to S3,
previous Ready template is not ready anymore.
This commit is contained in:
parent
010b007ee4
commit
df1c34bf2b
@ -41,6 +41,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
|
||||
@ -77,6 +78,7 @@ 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;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VMTemplateZoneVO;
|
||||
@ -392,9 +394,16 @@ 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) {
|
||||
s_logger.info("Removing leftover template " + uniqueName + " entry from template store table");
|
||||
// remove those leftover entries
|
||||
_vmTemplateStoreDao.remove(tmpltStore.getId());
|
||||
if (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");
|
||||
}
|
||||
else {
|
||||
s_logger.info("Removing leftover template " + uniqueName + " entry from template store table");
|
||||
// remove those leftover entries
|
||||
_vmTemplateStoreDao.remove(tmpltStore.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -424,6 +433,17 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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)) {
|
||||
TemplateDataStoreVO tmpltStore = _vmTemplateStoreDao.findByStoreTemplate(storeId, tmplt.getId());
|
||||
if (tmpltStore != null && tmpltStore.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED && tmpltStore.getState() == State.Ready
|
||||
&& tmpltStore.getInstallPath() == null) {
|
||||
s_logger.info("Skip sync template for migration of previous NFS to object store");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (availHypers.contains(tmplt.getHypervisorType())) {
|
||||
s_logger.info("Downloading template " + tmplt.getUniqueName() + " to image store " + store.getName());
|
||||
associateTemplateToZone(tmplt.getId(), zoneId);
|
||||
|
||||
@ -25,6 +25,9 @@ import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
|
||||
@ -57,8 +60,6 @@ import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
|
||||
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
|
||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.storage.ListVolumeAnswer;
|
||||
@ -1228,6 +1229,17 @@ public class VolumeServiceImpl implements VolumeService {
|
||||
s_logger.info("Skip downloading volume " + volumeHost.getVolumeId() + " since no download url is specified.");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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 (store.getScope().getScopeType() == ScopeType.REGION) {
|
||||
if (volumeHost.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED
|
||||
&& volumeHost.getInstallPath() == null) {
|
||||
s_logger.info("Skip sync volume for migration of previous NFS to object store");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
s_logger.debug("Volume " + volumeHost.getVolumeId() + " needs to be downloaded to " + store.getName());
|
||||
// TODO: pass a callback later
|
||||
VolumeInfo vol = volFactory.getVolume(volumeHost.getVolumeId());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user