|
73 | 73 | import com.cloud.storage.Snapshot; |
74 | 74 | import com.cloud.storage.Storage.ImageFormat; |
75 | 75 | import com.cloud.storage.Volume; |
| 76 | +import com.cloud.storage.VolumeVO; |
76 | 77 | import com.cloud.storage.VolumeDetailVO; |
77 | 78 | import com.cloud.storage.dao.SnapshotDao; |
78 | 79 | import com.cloud.storage.dao.SnapshotDetailsDao; |
@@ -1199,10 +1200,20 @@ private boolean cleanupVolume(final long volumeId) { |
1199 | 1200 | return true; |
1200 | 1201 | } |
1201 | 1202 | if (vol.getState().isTransitional()) { |
1202 | | - if (Volume.State.Migrating.equals(vol.getState()) && Arrays.asList(ImageFormat.RAW, ImageFormat.QCOW2).contains(vol.getFormat()) |
1203 | | - && ReconcileCommandService.ReconcileCommandsEnabled.value()) { |
1204 | | - logger.debug("Skipping cleaning up Migrating volume: " + vol); |
1205 | | - return true; |
| 1203 | + if (Volume.State.Migrating.equals(vol.getState())) { |
| 1204 | + VolumeVO destVolume = _volsDao.findByLastIdAndState(vol.getId(), Volume.State.Creating); |
| 1205 | + if (destVolume != null && destVolume.getPath() == null) { |
| 1206 | + cleanupVolume(destVolume.getId()); |
| 1207 | + } else if (Arrays.asList(ImageFormat.RAW, ImageFormat.QCOW2).contains(vol.getFormat()) |
| 1208 | + && ReconcileCommandService.ReconcileCommandsEnabled.value()) { |
| 1209 | + logger.debug("Skipping cleaning up Migrating volume: " + vol); |
| 1210 | + return true; |
| 1211 | + } else { |
| 1212 | + destVolume = _volsDao.findByLastIdAndState(vol.getId(), Volume.State.Migrating); |
| 1213 | + if (destVolume != null) { |
| 1214 | + cleanupVolume(destVolume.getId()); |
| 1215 | + } |
| 1216 | + } |
1206 | 1217 | } |
1207 | 1218 | logger.debug("Cleaning up volume with Id: " + volumeId); |
1208 | 1219 | boolean status = vol.stateTransit(Volume.Event.OperationFailed); |
|
0 commit comments