diff --git a/cinder/tests/unit/test_volume.py b/cinder/tests/unit/test_volume.py index fd3499deb6e..8f5e1796dac 100644 --- a/cinder/tests/unit/test_volume.py +++ b/cinder/tests/unit/test_volume.py @@ -4567,6 +4567,16 @@ class VolumeTestCase(BaseVolumeTestCase): self.context, snap) + def test_init_host_clears_deleting_snapshots(self): + """Test that init_host will delete a snapshot stuck in deleting.""" + volume = tests_utils.create_volume(self.context, status='deleting', + size=1, host=CONF.host) + snapshot = tests_utils.create_snapshot(self.context, + volume.id, status='deleting') + self.volume.init_host() + self.assertRaises(exception.VolumeNotFound, volume.refresh) + self.assertRaises(exception.SnapshotNotFound, snapshot.refresh) + @ddt.ddt class VolumeMigrationTestCase(BaseVolumeTestCase): diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index a0caee6b146..a23c522b4e1 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -442,10 +442,12 @@ class VolumeManager(manager.SchedulerDependentManager): # threadpool to prevent the main volume service thread # from being blocked. self._add_to_threadpool(self.delete_volume, ctxt, - volume['id'], volume=volume) + volume['id'], volume=volume, + cascade=True) else: # By default, delete volumes sequentially - self.delete_volume(ctxt, volume['id'], volume=volume) + self.delete_volume(ctxt, volume['id'], volume=volume, + cascade=True) LOG.info(_LI("Resume volume delete completed successfully."), resource=volume)