@Override public VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId) { SearchCriteria<VolumeDataStoreVO> sc = storeVolumeSearch.create(); sc.setParameters("store_id", storeId); sc.setParameters("volume_id", volumeId); sc.setParameters("destroyed", false); /* When we download volume then we create entry in volume_store_ref table. We mark the volume entry to ready state once download_url gets generated. When we migrate that volume, then again one more entry is created with same volume id. Its state is marked as allocated. Later we try to list only one dataobject in datastore for state transition during volume migration. If the listed volume's state is allocated then migration passes otherwise it fails. Below fix will remove the randomness and give priority to volume entry which is made for migration (download_url/extracturl will be null in case of migration). Giving priority to download volume case is not needed as there will be only one entry in that case so no randomness. */ List<VolumeDataStoreVO> vos = listBy(sc); if(vos.size() > 1) { for(VolumeDataStoreVO vo : vos) { if(vo.getExtractUrl() == null) { return vo; } } } return vos.size() == 1 ? vos.get(0) : null; }
s_logger.debug("Removing download url " + volumeOnImageStore.getExtractUrl() + " for volume id " + volumeId); secStore.deleteExtractUrl(volumeOnImageStore.getInstallPath(), volumeOnImageStore.getExtractUrl(), Upload.Type.VOLUME); s_logger.warn("Caught exception while deleting download url " + volumeOnImageStore.getExtractUrl() + " for volume id " + volumeOnImageStore.getVolumeId(), th);
downloadVolumeSearch.and("download_url", downloadVolumeSearch.entity().getExtractUrl(), Op.NNULL); downloadVolumeSearch.and("download_url_created", downloadVolumeSearch.entity().getExtractUrlCreated(), Op.NNULL); downloadVolumeSearch.and("destroyed", downloadVolumeSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
try { DataStore dataStore = storeMgr.getDataStore(volumeDataStore.getDataStoreId(), DataStoreRole.Image); EndPoint ep = _epSelector.select(dataStore, volumeDataStore.getExtractUrl()); if (ep == null) { s_logger.warn("There is no secondary storage VM for image store " + dataStore.getName()); s_logger.warn("Exception while checking status for uploaded volume " + volumeDataStore.getExtractUrl() + ". Error details: " + th.getMessage()); if (s_logger.isTraceEnabled()) { s_logger.trace("Exception details: ", th);
EndPoint ep = _epSelector.select(dataStore, volumeDataStore.getExtractUrl()); if (ep == null) { s_logger.warn("There is no secondary storage VM for image store " + dataStore.getName() + ", cannot destroy uploaded volume " + volume.getUuid());
if (volumeStoreRef != null && volumeStoreRef.getExtractUrl() != null) { return volumeStoreRef.getExtractUrl();