Skip to content

Commit 677b522

Browse files
committed
Merge PR ceph#53651 into main
* refs/pull/53651/head: qa: add test_subvolume_group_rm_when_its_not_empty mgr/volumes: fix `subvolume group rm` error message Reviewed-by: Kotresh Hiremath Ravishankar <[email protected]> Reviewed-by: Venky Shankar <[email protected]>
2 parents 8400e77 + 1245e5c commit 677b522

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

qa/tasks/cephfs/test_volumes.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,32 @@ def test_subvolume_group_exists_without_subvolumegroup_and_with_subvolume(self):
18711871
ret = self._fs_cmd("subvolumegroup", "exist", self.volname)
18721872
self.assertEqual(ret.strip('\n'), "no subvolumegroup exists")
18731873

1874+
def test_subvolume_group_rm_when_its_not_empty(self):
1875+
group = self._generate_random_group_name()
1876+
subvolume = self._generate_random_subvolume_name()
1877+
1878+
# create subvolumegroup
1879+
self._fs_cmd("subvolumegroup", "create", self.volname, group)
1880+
# create subvolume in group
1881+
self._fs_cmd("subvolume", "create", self.volname, subvolume, "--group_name", group)
1882+
# try, remove subvolume group
1883+
try:
1884+
self._fs_cmd("subvolumegroup", "rm", self.volname, group)
1885+
except CommandFailedError as ce:
1886+
self.assertEqual(ce.exitstatus, errno.ENOTEMPTY, "invalid error code on deleting "
1887+
"subvolumegroup when it is not empty")
1888+
else:
1889+
self.fail("expected the 'fs subvolumegroup rm' command to fail")
1890+
1891+
# delete subvolume
1892+
self._fs_cmd("subvolume", "rm", self.volname, subvolume, "--group_name", group)
1893+
1894+
# delete subvolumegroup
1895+
self._fs_cmd("subvolumegroup", "rm", self.volname, group)
1896+
1897+
# verify trash dir is clean
1898+
self._wait_for_trash_empty()
1899+
18741900

18751901
class TestSubvolumes(TestVolumesHelper):
18761902
"""Tests for FS subvolume operations, except snapshot and snapshot clone."""

src/pybind/mgr/volumes/fs/operations/group.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ def remove_group(fs, vol_spec, groupname):
269269
except cephfs.Error as e:
270270
if e.args[0] == errno.ENOENT:
271271
raise VolumeException(-errno.ENOENT, "subvolume group '{0}' does not exist".format(groupname))
272+
elif e.args[0] == errno.ENOTEMPTY:
273+
raise VolumeException(-errno.ENOTEMPTY, f"subvolume group {groupname} contains subvolume(s) "
274+
"or retained snapshots of deleted subvolume(s)")
272275
raise VolumeException(-e.args[0], e.args[1])
273276

274277

0 commit comments

Comments
 (0)