Currently you have to destroy the consistency group if you want to
delete these volumes. In the Kilo release, we'll have the ability to
remove a volume from a consistency group, which then can be deleted.
Closes-Bug: #
1413427
Change-Id: Ice8ab88a89e447a08c3ce71c7698dd5fcf02d1e9
'host': 'fake_host',
'project_id': 'fake_project',
'migration_status': None,
+ 'consistencygroup_id': None,
'encryption_key_id': None},
detached_vol_id: {'id': detached_vol_id,
'status': 'available',
'host': 'fake_host',
'project_id': 'fake_project',
'migration_status': None,
+ 'consistencygroup_id': None,
'encryption_key_id': None},
attached_vol_id: {'id': attached_vol_id,
'status': 'available',
'host': 'fake_host',
'project_id': 'fake_project',
'migration_status': None,
+ 'consistencygroup_id': None,
'encryption_key_id': None}
}
self.volume.delete_snapshot(self.context, snapshot_id)
self.volume.delete_volume(self.context, volume['id'])
+ def test_delete_volume_in_consistency_group(self):
+ """Test deleting a volume that's tied to a consistency group fails."""
+ volume_api = cinder.volume.api.API()
+ volume = tests_utils.create_volume(self.context, **self.volume_params)
+ consistencygroup_id = '12345678-1234-5678-1234-567812345678'
+ volume = db.volume_update(self.context, volume['id'],
+ {'status': 'available',
+ 'consistencygroup_id': consistencygroup_id})
+ self.assertRaises(exception.InvalidVolume,
+ volume_api.delete, self.context, volume)
+
def test_can_delete_errored_snapshot(self):
"""Test snapshot can be created and deleted."""
volume = tests_utils.create_volume(self.context, **self.volume_params)
msg = _("Volume cannot be deleted while migrating")
raise exception.InvalidVolume(reason=msg)
+ if volume['consistencygroup_id'] is not None:
+ msg = _("Volume cannot be deleted while in a consistency group.")
+ raise exception.InvalidVolume(reason=msg)
+
snapshots = self.db.snapshot_get_all_for_volume(context, volume_id)
if len(snapshots):
msg = _("Volume still has %d dependent snapshots") % len(snapshots)