@@ -1382,6 +1382,7 @@ public void handleVolumeSync(DataStore store) {
13821382 return ;
13831383 }
13841384
1385+ // we can only resume those uploaded volume with a URL specified
13851386 List <VolumeDataStoreVO > dbVolumes = _volumeStoreDao .listUploadedVolumesByStoreId (storeId );
13861387 List <VolumeDataStoreVO > toBeDownloaded = new ArrayList <VolumeDataStoreVO >(dbVolumes );
13871388 for (VolumeDataStoreVO volumeStore : dbVolumes ) {
@@ -1405,7 +1406,7 @@ public void handleVolumeSync(DataStore store) {
14051406 volumeStore .setDownloadState (Status .DOWNLOAD_ERROR );
14061407 String msg = "Volume " + volume .getUuid () + " is corrupted on image store " ;
14071408 volumeStore .setErrorString (msg );
1408- s_logger .info (" msg" );
1409+ s_logger .info (msg );
14091410 if (volumeStore .getDownloadUrl () == null ) {
14101411 msg =
14111412 "Volume (" + volume .getUuid () + ") with install path " + volInfo .getInstallPath () +
@@ -1454,7 +1455,6 @@ public void handleVolumeSync(DataStore store) {
14541455 if (volumeStore .getDownloadState () != Status .DOWNLOADED ) {
14551456 s_logger .info ("Volume Sync did not find " + volume .getName () + " ready on image store " + storeId +
14561457 ", will request download to start/resume shortly" );
1457- toBeDownloaded .add (volumeStore );
14581458 }
14591459 }
14601460
@@ -1477,8 +1477,13 @@ public void handleVolumeSync(DataStore store) {
14771477 }
14781478
14791479 s_logger .debug ("Volume " + volumeHost .getVolumeId () + " needs to be downloaded to " + store .getName ());
1480- // TODO: pass a callback later
1481- VolumeInfo vol = volFactory .getVolume (volumeHost .getVolumeId ());
1480+ // reset volume status back to Allocated
1481+ VolumeObject vol = (VolumeObject )volFactory .getVolume (volumeHost .getVolumeId ());
1482+ vol .processEvent (Event .OperationFailed ); // reset back volume status
1483+ // remove leftover volume_store_ref entry since re-download will create it again
1484+ _volumeStoreDao .remove (volumeHost .getId ());
1485+ // get an updated volumeVO
1486+ vol = (VolumeObject )volFactory .getVolume (volumeHost .getVolumeId ());
14821487 RegisterVolumePayload payload = new RegisterVolumePayload (volumeHost .getDownloadUrl (), volumeHost .getChecksum (), vol .getFormat ().toString ());
14831488 vol .addPayload (payload );
14841489 createVolumeAsync (vol , store );
0 commit comments