@@ -1020,7 +1020,7 @@ protected Void copyVolumeCallBack(AsyncCallbackDispatcher<VolumeServiceImpl, Cop
10201020 }
10211021 srcVolume .processEvent (Event .OperationSuccessed );
10221022 destVolume .processEvent (Event .MigrationCopySucceeded , result .getAnswer ());
1023- _volumeDao .updateUuid (srcVolume .getId (), destVolume .getId ());
1023+ volDao .updateUuid (srcVolume .getId (), destVolume .getId ());
10241024 try {
10251025 destroyVolume (srcVolume .getId ());
10261026 srcVolume = volFactory .getVolume (srcVolume .getId ());
@@ -1225,10 +1225,16 @@ public AsyncCallFuture<VolumeApiResult> registerVolume(VolumeInfo volume, DataSt
12251225
12261226 protected Void registerVolumeCallback (AsyncCallbackDispatcher <VolumeServiceImpl , CreateCmdResult > callback , CreateVolumeContext <VolumeApiResult > context ) {
12271227 CreateCmdResult result = callback .getResult ();
1228+ VolumeObject vo = (VolumeObject )context .volume ;
12281229 try {
1229- VolumeObject vo = (VolumeObject )context .volume ;
12301230 if (result .isFailed ()) {
12311231 vo .processEvent (Event .OperationFailed );
1232+ // delete the volume entry from volumes table in case of failure
1233+ VolumeVO vol = volDao .findById (vo .getId ());
1234+ if (vol != null ) {
1235+ volDao .remove (vo .getId ());
1236+ }
1237+
12321238 } else {
12331239 vo .processEvent (Event .OperationSuccessed , result .getAnswer ());
12341240
@@ -1267,6 +1273,11 @@ protected Void registerVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl,
12671273
12681274 } catch (Exception e ) {
12691275 s_logger .error ("register volume failed: " , e );
1276+ // delete the volume entry from volumes table in case of failure
1277+ VolumeVO vol = volDao .findById (vo .getId ());
1278+ if (vol != null ) {
1279+ volDao .remove (vo .getId ());
1280+ }
12701281 VolumeApiResult res = new VolumeApiResult (null );
12711282 context .future .complete (res );
12721283 return null ;
@@ -1302,7 +1313,7 @@ public void resizeVolumeOnHypervisor(long volumeId, long newSize, long destHostI
13021313 EndPoint ep = RemoteHostEndPoint .getHypervisorHostEndPoint (destHost );
13031314
13041315 if (ep != null ) {
1305- VolumeVO volume = _volumeDao .findById (volumeId );
1316+ VolumeVO volume = volDao .findById (volumeId );
13061317 PrimaryDataStore primaryDataStore = this .dataStoreMgr .getPrimaryDataStore (volume .getPoolId ());
13071318 ResizeVolumeCommand resizeCmd = new ResizeVolumeCommand (volume .getPath (), new StorageFilerTO (primaryDataStore ), volume .getSize (), newSize , true , instanceName );
13081319
@@ -1374,7 +1385,7 @@ public void handleVolumeSync(DataStore store) {
13741385 List <VolumeDataStoreVO > dbVolumes = _volumeStoreDao .listUploadedVolumesByStoreId (storeId );
13751386 List <VolumeDataStoreVO > toBeDownloaded = new ArrayList <VolumeDataStoreVO >(dbVolumes );
13761387 for (VolumeDataStoreVO volumeStore : dbVolumes ) {
1377- VolumeVO volume = _volumeDao .findById (volumeStore .getVolumeId ());
1388+ VolumeVO volume = volDao .findById (volumeStore .getVolumeId ());
13781389 if (volume == null ) {
13791390 s_logger .warn ("Volume_store_ref shows that volume " + volumeStore .getVolumeId () + " is on image store " + storeId +
13801391 ", but the volume is not found in volumes table, potentially some bugs in deleteVolume, so we just treat this volume to be deleted and mark it as destroyed" );
@@ -1419,7 +1430,7 @@ public void handleVolumeSync(DataStore store) {
14191430 if (volume .getSize () == 0 ) {
14201431 // Set volume size in volumes table
14211432 volume .setSize (volInfo .getSize ());
1422- _volumeDao .update (volumeStore .getVolumeId (), volume );
1433+ volDao .update (volumeStore .getVolumeId (), volume );
14231434 }
14241435
14251436 if (volInfo .getSize () > 0 ) {
0 commit comments