mirror of
https://github.com/ceph/ceph
synced 2025-01-20 01:51:34 +00:00
Merge PR #32696 into master
* refs/pull/32696/head: mgr/volumes: fail removing subvolume with snapshots Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
This commit is contained in:
commit
721c959ab3
@ -1234,3 +1234,31 @@ class TestVolumes(CephFSTestCase):
|
||||
|
||||
# remove group
|
||||
self._fs_cmd("subvolumegroup", "rm", self.volname, group)
|
||||
|
||||
def test_subvolume_rm_with_snapshots(self):
|
||||
subvolume = self._generate_random_subvolume_name()
|
||||
snapshot = self._generate_random_snapshot_name()
|
||||
|
||||
# create subvolume
|
||||
self._fs_cmd("subvolume", "create", self.volname, subvolume)
|
||||
|
||||
# snapshot subvolume
|
||||
self._fs_cmd("subvolume", "snapshot", "create", self.volname, subvolume, snapshot)
|
||||
|
||||
# remove subvolume -- should fail with ENOTEMPTY since it has snapshots
|
||||
try:
|
||||
self._fs_cmd("subvolume", "rm", self.volname, subvolume)
|
||||
except CommandFailedError as ce:
|
||||
if ce.exitstatus != errno.ENOTEMPTY:
|
||||
raise RuntimeError("invalid error code returned when deleting subvolume with snapshots")
|
||||
else:
|
||||
raise RuntimeError("expected subvolume deletion to fail")
|
||||
|
||||
# remove snapshot
|
||||
self._fs_cmd("subvolume", "snapshot", "rm", self.volname, subvolume, snapshot)
|
||||
|
||||
# remove subvolume
|
||||
self._fs_cmd("subvolume", "rm", self.volname, subvolume)
|
||||
|
||||
# verify trash dir is clean
|
||||
self._wait_for_trash_empty()
|
||||
|
@ -39,6 +39,8 @@ def remove_subvol(fs, vol_spec, group, subvolname):
|
||||
:return: None
|
||||
"""
|
||||
with open_subvol(fs, vol_spec, group, subvolname) as subvolume:
|
||||
if subvolume.list_snapshots():
|
||||
raise VolumeException(-errno.ENOTEMPTY, "subvolume '{0}' has snapshots".format(subvolname))
|
||||
subvolume.remove()
|
||||
|
||||
@contextmanager
|
||||
|
Loading…
Reference in New Issue
Block a user