]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/volumes: allow force removal of incomplete failed clones
authorVenky Shankar <vshankar@redhat.com>
Wed, 15 Jan 2020 03:52:52 +0000 (22:52 -0500)
committerRamana Raja <rraja@redhat.com>
Wed, 12 Feb 2020 10:12:00 +0000 (05:12 -0500)
Signed-off-by: Venky Shankar <vshankar@redhat.com>
(cherry picked from commit 451be112603f970de3cb0ca9048c88a98c034188)

src/pybind/mgr/volumes/fs/operations/subvolume.py
src/pybind/mgr/volumes/fs/volume.py

index bfd9349bb77c4209ad02df7a6491d069b3e3aab4..70e5dbb5f1d0b11084a2bf0e35c2bb36e14f6053 100644 (file)
@@ -45,7 +45,7 @@ def create_clone(fs, vol_spec, group, subvolname, pool, source_volume, source_su
     subvolume = loaded_subvolumes.get_subvolume_object_max(fs, vol_spec, group, subvolname)
     subvolume.create_clone(pool, source_volume, source_subvolume, snapname)
 
-def remove_subvol(fs, vol_spec, group, subvolname):
+def remove_subvol(fs, vol_spec, group, subvolname, force=False):
     """
     remove a subvolume.
 
@@ -53,9 +53,11 @@ def remove_subvol(fs, vol_spec, group, subvolname):
     :param vol_spec: volume specification
     :param group: group object for the subvolume
     :param subvolname: subvolume name
+    :param force: force remove subvolumes
     :return: None
     """
-    with open_subvol(fs, vol_spec, group, subvolname) as subvolume:
+    nc_flag = True if not force else False
+    with open_subvol(fs, vol_spec, group, subvolname, need_complete=nc_flag) as subvolume:
         if subvolume.list_snapshots():
             raise VolumeException(-errno.ENOTEMPTY, "subvolume '{0}' has snapshots".format(subvolname))
         subvolume.remove()
index 21b0dc848c3a2b1e568feb1ff15b543bafe6273b..a10488d12923da3f82e770c9daf8bd677f19380c 100644 (file)
@@ -160,14 +160,17 @@ class VolumeClient(object):
         try:
             with open_volume(self, volname) as fs_handle:
                 with open_group(fs_handle, self.volspec, groupname) as group:
-                    remove_subvol(fs_handle, self.volspec, group, subvolname)
+                    remove_subvol(fs_handle, self.volspec, group, subvolname, force)
                     # kick the purge threads for async removal -- note that this
                     # assumes that the subvolume is moved to trash can.
                     # TODO: make purge queue as singleton so that trash can kicks
                     # the purge threads on dump.
                     self.purge_queue.queue_job(volname)
         except VolumeException as ve:
-            if not (ve.errno == -errno.ENOENT and force):
+            if ve.errno == -errno.EAGAIN:
+                ve = VolumeException(ve.errno, ve.error_str + " (use --force to override)")
+                ret = self.volume_exception_to_retval(ve)
+            elif not (ve.errno == -errno.ENOENT and force):
                 ret = self.volume_exception_to_retval(ve)
         return ret