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();
|
||||
|
||||
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> storeVolumeSearch;
|
||||
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=?)";
|
||||
|
||||
|
||||
@ -95,6 +96,12 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO, Lo
|
||||
downloadVolumeSearch.and("destroyed", downloadVolumeSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -271,6 +278,15 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO, Lo
|
||||
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
|
||||
public void expireDnldUrlsForZone(Long dcId){
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
|
||||
@ -26,6 +26,7 @@ import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.storage.RegisterVolumePayload;
|
||||
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;
|
||||
@ -1370,7 +1371,7 @@ public class VolumeServiceImpl implements VolumeService {
|
||||
return;
|
||||
}
|
||||
|
||||
List<VolumeDataStoreVO> dbVolumes = _volumeStoreDao.listByStoreId(storeId);
|
||||
List<VolumeDataStoreVO> dbVolumes = _volumeStoreDao.listUploadedVolumesByStoreId(storeId);
|
||||
List<VolumeDataStoreVO> toBeDownloaded = new ArrayList<VolumeDataStoreVO>(dbVolumes);
|
||||
for (VolumeDataStoreVO volumeStore : dbVolumes) {
|
||||
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());
|
||||
// TODO: pass a callback later
|
||||
VolumeInfo vol = volFactory.getVolume(volumeHost.getVolumeId());
|
||||
RegisterVolumePayload payload = new RegisterVolumePayload(volumeHost.getDownloadUrl(), volumeHost.getChecksum(), vol.getFormat().toString());
|
||||
vol.addPayload(payload);
|
||||
createVolumeAsync(vol, store);
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,10 +298,14 @@ public class DownloadListener implements Listener {
|
||||
}
|
||||
}*/
|
||||
else if (cmd instanceof StartupSecondaryStorageCommand) {
|
||||
List<DataStore> imageStores = _storeMgr.getImageStoresByScope(new ZoneScope(agent.getDataCenterId()));
|
||||
for (DataStore store : imageStores) {
|
||||
_volumeSrv.handleVolumeSync(store);
|
||||
_imageSrv.handleTemplateSync(store);
|
||||
try{
|
||||
List<DataStore> imageStores = _storeMgr.getImageStoresByScope(new ZoneScope(agent.getDataCenterId()));
|
||||
for (DataStore store : imageStores) {
|
||||
_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