@@ -542,13 +542,6 @@ public void handleDownloadEvent(HostVO host, VolumeVO volume, Status dnldStatus)
542542 txn .start ();
543543
544544 if (dnldStatus == Status .DOWNLOADED ) {
545-
546- // Do the volume state transition
547- try {
548- _storageMgr .stateTransitTo (volume , Event .UploadSucceeded );
549- } catch (NoTransitionException e ) {
550- e .printStackTrace ();
551- }
552545
553546 //Create usage event
554547 long size = -1 ;
@@ -563,13 +556,7 @@ public void handleDownloadEvent(HostVO host, VolumeVO volume, Status dnldStatus)
563556 UsageEventVO usageEvent = new UsageEventVO (eventType , volume .getAccountId (), host .getDataCenterId (), volume .getId (), volume .getName (), null , 0l , size );
564557 _usageEventDao .persist (usageEvent );
565558 }
566- }else if (dnldStatus == Status .DOWNLOAD_ERROR ){
567- //Transistion the volume state
568- try {
569- _storageMgr .stateTransitTo (volume , Volume .Event .OperationFailed );
570- } catch (NoTransitionException e ) {
571- throw new CloudRuntimeException ("Unable to update the failure on a volume: " + volume , e );
572- }
559+ }else if (dnldStatus == Status .DOWNLOAD_ERROR || dnldStatus == Status .ABANDONED || dnldStatus == Status .UNKNOWN ){
573560 //Decrement the volume count
574561 _resourceLimitMgr .decrementResourceCount (volume .getAccountId (), com .cloud .configuration .Resource .ResourceType .volume );
575562 }
@@ -737,27 +724,25 @@ public void handleVolumeSync(HostVO ssHost) {
737724 toBeDownloaded .add (volumeHost );
738725 }
739726
740- } else {
727+ } else { // Put them in right status
741728 volumeHost .setDownloadPercent (100 );
742729 volumeHost .setDownloadState (Status .DOWNLOADED );
743730 volumeHost .setInstallPath (volInfo .getInstallPath ());
744731 volumeHost .setSize (volInfo .getSize ());
745732 volumeHost .setPhysicalSize (volInfo .getPhysicalSize ());
746- volumeHost .setLastUpdated (new Date ());
747- if (volume .getState () == Volume .State .Uploading ){
748- try {
749- _storageMgr .stateTransitTo (volume , Event .UploadSucceeded );
750- } catch (NoTransitionException e ) {
751- e .printStackTrace ();
752- }
753- }
754-
733+ volumeHost .setLastUpdated (new Date ());
755734 _volumeHostDao .update (volumeHost .getId (), volumeHost );
756735 }
736+ continue ;
757737 }
738+ // Volume is not on secondary but we should download.
739+ if (volumeHost .getDownloadState () != Status .DOWNLOADED ) {
740+ s_logger .info ("Volume Sync did not find " + volume .getName () + " ready on server " + sserverId + ", will request download to start/resume shortly" );
741+ toBeDownloaded .add (volumeHost );
742+ }
758743 }
759744
760- //Download volumes which havent been downloaded yet.
745+ //Download volumes which haven't been downloaded yet.
761746 if (toBeDownloaded .size () > 0 ) {
762747 for (VolumeHostVO volumeHost : toBeDownloaded ) {
763748 if (volumeHost .getDownloadUrl () == null ) { // If url is null we can't initiate the download
0 commit comments