Skip to content

Commit d221f53

Browse files
committed
Reconcile: cleanup volumes with empty path in Creating and Migrating state if reconcile is not applicable
1 parent b493d8f commit d221f53

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

framework/jobs/src/main/java/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
import com.cloud.storage.Snapshot;
7474
import com.cloud.storage.Storage.ImageFormat;
7575
import com.cloud.storage.Volume;
76+
import com.cloud.storage.VolumeVO;
7677
import com.cloud.storage.VolumeDetailVO;
7778
import com.cloud.storage.dao.SnapshotDao;
7879
import com.cloud.storage.dao.SnapshotDetailsDao;
@@ -1199,10 +1200,20 @@ private boolean cleanupVolume(final long volumeId) {
11991200
return true;
12001201
}
12011202
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+
}
12061217
}
12071218
logger.debug("Cleaning up volume with Id: " + volumeId);
12081219
boolean status = vol.stateTransit(Volume.Event.OperationFailed);

0 commit comments

Comments
 (0)