Repository: cloudstack Updated Branches: refs/heads/master 4cb950554 -> ea634550f
CLOUDSTACK-8101: volume sync not working as expected - MS restart during upload volume leaves volume in hung state. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ea634550 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ea634550 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ea634550 Branch: refs/heads/master Commit: ea634550fcc257134ff2ffbc29016f86a0c2fa91 Parents: 4cb9505 Author: Min Chen <min.c...@citrix.com> Authored: Fri Dec 19 11:26:59 2014 -0800 Committer: Min Chen <min.c...@citrix.com> Committed: Fri Dec 19 15:51:52 2014 -0800 ---------------------------------------------------------------------- .../cloudstack/storage/volume/VolumeServiceImpl.java | 13 +++++++++---- .../cloud/storage/download/DownloadMonitorImpl.java | 5 +++++ 2 files changed, 14 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ea634550/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java ---------------------------------------------------------------------- diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java index 4f8255a..5d10c7f 100644 --- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java +++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java @@ -1382,6 +1382,7 @@ public class VolumeServiceImpl implements VolumeService { return; } + // we can only resume those uploaded volume with a URL specified List<VolumeDataStoreVO> dbVolumes = _volumeStoreDao.listUploadedVolumesByStoreId(storeId); List<VolumeDataStoreVO> toBeDownloaded = new ArrayList<VolumeDataStoreVO>(dbVolumes); for (VolumeDataStoreVO volumeStore : dbVolumes) { @@ -1405,7 +1406,7 @@ public class VolumeServiceImpl implements VolumeService { volumeStore.setDownloadState(Status.DOWNLOAD_ERROR); String msg = "Volume " + volume.getUuid() + " is corrupted on image store "; volumeStore.setErrorString(msg); - s_logger.info("msg"); + s_logger.info(msg); if (volumeStore.getDownloadUrl() == null) { msg = "Volume (" + volume.getUuid() + ") with install path " + volInfo.getInstallPath() + @@ -1454,7 +1455,6 @@ public class VolumeServiceImpl implements VolumeService { if (volumeStore.getDownloadState() != Status.DOWNLOADED) { s_logger.info("Volume Sync did not find " + volume.getName() + " ready on image store " + storeId + ", will request download to start/resume shortly"); - toBeDownloaded.add(volumeStore); } } @@ -1477,8 +1477,13 @@ 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()); + // reset volume status back to Allocated + VolumeObject vol = (VolumeObject)volFactory.getVolume(volumeHost.getVolumeId()); + vol.processEvent(Event.OperationFailed); // reset back volume status + // remove leftover volume_store_ref entry since re-download will create it again + _volumeStoreDao.remove(volumeHost.getId()); + // get an updated volumeVO + vol = (VolumeObject)volFactory.getVolume(volumeHost.getVolumeId()); RegisterVolumePayload payload = new RegisterVolumePayload(volumeHost.getDownloadUrl(), volumeHost.getChecksum(), vol.getFormat().toString()); vol.addPayload(payload); createVolumeAsync(vol, store); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ea634550/server/src/com/cloud/storage/download/DownloadMonitorImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/download/DownloadMonitorImpl.java b/server/src/com/cloud/storage/download/DownloadMonitorImpl.java index eed1581..f1937f8 100644 --- a/server/src/com/cloud/storage/download/DownloadMonitorImpl.java +++ b/server/src/com/cloud/storage/download/DownloadMonitorImpl.java @@ -219,6 +219,11 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor _volumeStoreDao.persist(volumeHost); } else if ((volumeHost.getJobId() != null) && (volumeHost.getJobId().length() > 2)) { downloadJobExists = true; + } else { + // persit url and checksum + volumeHost.setDownloadUrl(url); + volumeHost.setChecksum(checkSum); + _volumeStoreDao.update(volumeHost.getId(), volumeHost); } Long maxVolumeSizeInBytes = getMaxVolumeSizeInBytes();