File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -1544,6 +1544,9 @@ public void destroyVolume(long volumeId) {
15441544 // mark volume entry in volumes table as destroy state
15451545 VolumeInfo vol = volFactory .getVolume (volumeId );
15461546 vol .stateTransit (Volume .Event .DestroyRequested );
1547+ if (Volume .Type .ROOT == vol .getVolumeType ()) {
1548+ updateDestroyedVolumeToDatadisk (volumeId );
1549+ }
15471550 snapshotMgr .deletePoliciesForVolume (volumeId );
15481551 annotationDao .removeByEntityType (AnnotationService .EntityType .VOLUME .name (), vol .getUuid ());
15491552
@@ -1556,6 +1559,17 @@ public void destroyVolume(long volumeId) {
15561559 }
15571560 }
15581561
1562+ /**
1563+ * Prevent VM deletion if underlying issues cause the storage cleanup task to not work properly
1564+ */
1565+ private void updateDestroyedVolumeToDatadisk (long volumeId ) {
1566+ VolumeVO volume = _volumeDao .findById (volumeId );
1567+ if (volume != null ) {
1568+ volume .setVolumeType (Volume .Type .DATADISK );
1569+ _volumeDao .update (volumeId , volume );
1570+ }
1571+ }
1572+
15591573 @ Override
15601574 public AsyncCallFuture <VolumeApiResult > createVolumeFromSnapshot (VolumeInfo volume , DataStore store , SnapshotInfo snapshot ) {
15611575 AsyncCallFuture <VolumeApiResult > future = new AsyncCallFuture <VolumeApiResult >();
You can’t perform that action at this time.
0 commit comments