@@ -1817,6 +1817,8 @@ public Volume migrateVolume(MigrateVolumeCmd cmd) {
18171817 if (jobResult != null ) {
18181818 if (jobResult instanceof ConcurrentOperationException )
18191819 throw (ConcurrentOperationException )jobResult ;
1820+ else if (jobResult instanceof RuntimeException )
1821+ throw (RuntimeException )jobResult ;
18201822 else if (jobResult instanceof Throwable )
18211823 throw new RuntimeException ("Unexpected exception" , (Throwable )jobResult );
18221824 }
@@ -1839,35 +1841,39 @@ private Volume orchestrateMigrateVolume(long volumeId, long destPoolId, boolean
18391841 assert (destPool != null );
18401842
18411843 Volume newVol = null ;
1842- if ( liveMigrateVolume ) {
1843- newVol = liveMigrateVolume ( vol , destPool );
1844- } else {
1845- try {
1844+ try {
1845+ if ( liveMigrateVolume ) {
1846+ newVol = liveMigrateVolume ( vol , destPool );
1847+ } else {
18461848 newVol = _volumeMgr .migrateVolume (vol , destPool );
1847- } catch (StorageUnavailableException e ) {
1848- s_logger .debug ("Failed to migrate volume" , e );
18491849 }
1850+ } catch (StorageUnavailableException e ) {
1851+ s_logger .debug ("Failed to migrate volume" , e );
1852+ throw new CloudRuntimeException (e .getMessage ());
1853+ } catch (Exception e ) {
1854+ s_logger .debug ("Failed to migrate volume" , e );
1855+ throw new CloudRuntimeException (e .getMessage ());
18501856 }
18511857 return newVol ;
18521858 }
18531859
18541860 @ DB
1855- protected Volume liveMigrateVolume (Volume volume , StoragePool destPool ) {
1861+ protected Volume liveMigrateVolume (Volume volume , StoragePool destPool ) throws StorageUnavailableException {
18561862 VolumeInfo vol = volFactory .getVolume (volume .getId ());
18571863 AsyncCallFuture <VolumeApiResult > future = volService .migrateVolume (vol , (DataStore )destPool );
18581864 try {
18591865 VolumeApiResult result = future .get ();
18601866 if (result .isFailed ()) {
18611867 s_logger .debug ("migrate volume failed:" + result .getResult ());
1862- return null ;
1868+ throw new StorageUnavailableException ( "Migrate volume failed: " + result . getResult (), destPool . getId ()) ;
18631869 }
18641870 return result .getVolume ();
18651871 } catch (InterruptedException e ) {
18661872 s_logger .debug ("migrate volume failed" , e );
1867- return null ;
1873+ throw new CloudRuntimeException ( e . getMessage ()) ;
18681874 } catch (ExecutionException e ) {
18691875 s_logger .debug ("migrate volume failed" , e );
1870- return null ;
1876+ throw new CloudRuntimeException ( e . getMessage ()) ;
18711877 }
18721878 }
18731879
0 commit comments