mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-7920: NPE in the payload was causing the ssvm agent to not connect, fix it and also make sure that template/volume sync are robust that exceptions do not cause ssvm agent disconnect issues.
This commit is contained in:
parent
39a671dfd8
commit
5213401ace
@ -46,4 +46,6 @@ public interface VolumeDataStoreDao extends GenericDao<VolumeDataStoreVO, Long>,
|
|||||||
List<VolumeDataStoreVO> listVolumeDownloadUrls();
|
List<VolumeDataStoreVO> listVolumeDownloadUrls();
|
||||||
|
|
||||||
void expireDnldUrlsForZone(Long dcId);
|
void expireDnldUrlsForZone(Long dcId);
|
||||||
|
|
||||||
|
List<VolumeDataStoreVO> listUploadedVolumesByStoreId(long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,6 +52,7 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO, Lo
|
|||||||
private SearchBuilder<VolumeDataStoreVO> cacheSearch;
|
private SearchBuilder<VolumeDataStoreVO> cacheSearch;
|
||||||
private SearchBuilder<VolumeDataStoreVO> storeVolumeSearch;
|
private SearchBuilder<VolumeDataStoreVO> storeVolumeSearch;
|
||||||
private SearchBuilder<VolumeDataStoreVO> downloadVolumeSearch;
|
private SearchBuilder<VolumeDataStoreVO> downloadVolumeSearch;
|
||||||
|
private SearchBuilder<VolumeDataStoreVO> uploadVolumeSearch;
|
||||||
private static final String EXPIRE_DOWNLOAD_URLS_FOR_ZONE = "update volume_store_ref set download_url_created=? where store_id in (select id from image_store where data_center_id=?)";
|
private static final String EXPIRE_DOWNLOAD_URLS_FOR_ZONE = "update volume_store_ref set download_url_created=? where store_id in (select id from image_store where data_center_id=?)";
|
||||||
|
|
||||||
|
|
||||||
@ -95,6 +96,12 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO, Lo
|
|||||||
downloadVolumeSearch.and("destroyed", downloadVolumeSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
downloadVolumeSearch.and("destroyed", downloadVolumeSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||||
downloadVolumeSearch.done();
|
downloadVolumeSearch.done();
|
||||||
|
|
||||||
|
uploadVolumeSearch = createSearchBuilder();
|
||||||
|
uploadVolumeSearch.and("store_id", uploadVolumeSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ);
|
||||||
|
uploadVolumeSearch.and("url", uploadVolumeSearch.entity().getDownloadUrl(), Op.NNULL);
|
||||||
|
uploadVolumeSearch.and("destroyed", uploadVolumeSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||||
|
uploadVolumeSearch.done();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,6 +278,15 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO, Lo
|
|||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<VolumeDataStoreVO> listUploadedVolumesByStoreId(long id) {
|
||||||
|
SearchCriteria<VolumeDataStoreVO> sc = uploadVolumeSearch.create();
|
||||||
|
sc.setParameters("store_id", id);
|
||||||
|
sc.setParameters("destroyed", false);
|
||||||
|
return listIncludingRemovedBy(sc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void expireDnldUrlsForZone(Long dcId){
|
public void expireDnldUrlsForZone(Long dcId){
|
||||||
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import com.cloud.storage.RegisterVolumePayload;
|
||||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
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.ChapInfo;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
|
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
|
||||||
@ -1370,7 +1371,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<VolumeDataStoreVO> dbVolumes = _volumeStoreDao.listByStoreId(storeId);
|
List<VolumeDataStoreVO> dbVolumes = _volumeStoreDao.listUploadedVolumesByStoreId(storeId);
|
||||||
List<VolumeDataStoreVO> toBeDownloaded = new ArrayList<VolumeDataStoreVO>(dbVolumes);
|
List<VolumeDataStoreVO> toBeDownloaded = new ArrayList<VolumeDataStoreVO>(dbVolumes);
|
||||||
for (VolumeDataStoreVO volumeStore : dbVolumes) {
|
for (VolumeDataStoreVO volumeStore : dbVolumes) {
|
||||||
VolumeVO volume = _volumeDao.findById(volumeStore.getVolumeId());
|
VolumeVO volume = _volumeDao.findById(volumeStore.getVolumeId());
|
||||||
@ -1467,6 +1468,8 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
s_logger.debug("Volume " + volumeHost.getVolumeId() + " needs to be downloaded to " + store.getName());
|
s_logger.debug("Volume " + volumeHost.getVolumeId() + " needs to be downloaded to " + store.getName());
|
||||||
// TODO: pass a callback later
|
// TODO: pass a callback later
|
||||||
VolumeInfo vol = volFactory.getVolume(volumeHost.getVolumeId());
|
VolumeInfo vol = volFactory.getVolume(volumeHost.getVolumeId());
|
||||||
|
RegisterVolumePayload payload = new RegisterVolumePayload(volumeHost.getDownloadUrl(), volumeHost.getChecksum(), vol.getFormat().toString());
|
||||||
|
vol.addPayload(payload);
|
||||||
createVolumeAsync(vol, store);
|
createVolumeAsync(vol, store);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -298,10 +298,14 @@ public class DownloadListener implements Listener {
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
else if (cmd instanceof StartupSecondaryStorageCommand) {
|
else if (cmd instanceof StartupSecondaryStorageCommand) {
|
||||||
List<DataStore> imageStores = _storeMgr.getImageStoresByScope(new ZoneScope(agent.getDataCenterId()));
|
try{
|
||||||
for (DataStore store : imageStores) {
|
List<DataStore> imageStores = _storeMgr.getImageStoresByScope(new ZoneScope(agent.getDataCenterId()));
|
||||||
_volumeSrv.handleVolumeSync(store);
|
for (DataStore store : imageStores) {
|
||||||
_imageSrv.handleTemplateSync(store);
|
_volumeSrv.handleVolumeSync(store);
|
||||||
|
_imageSrv.handleTemplateSync(store);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
s_logger.error("Caught exception while doing template/volume sync ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user