]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/volumes: handling dangling symlinks gracefully
authorneeraj pratap singh <neerajpratapsingh@li-ff7f0d4c-3462-11b2-a85c-d4004c0fa1a0.ibm.com>
Thu, 29 Feb 2024 09:46:36 +0000 (15:16 +0530)
committerneeraj pratap singh <neerajpratapsingh@li-ff7f0d4c-3462-11b2-a85c-d4004c0fa1a0.ibm.com>
Wed, 4 Dec 2024 09:55:47 +0000 (15:25 +0530)
If we come across situations where we encounter dangling
symlinks for clones due to any reason,like older versions
may have produced dangling clone symlinks which remained
post-upgrade, it needs to be handled gracefully by deleting
it, presence of which may not allow deletion of the snapshot.
We are now cleaning those up in the snapshot info command.

Fixes: https://tracker.ceph.com/issues/58090
Signed-off-by: Neeraj Pratap Singh <neesingh@redhat.com>
src/pybind/mgr/volumes/fs/operations/versions/subvolume_v1.py

index 90f35a4c90b39e6523c9bd816bc8c1d9f7056ddb..05257394a9637cf2c8802fba540ab54a68f0f3a1 100644 (file)
@@ -743,6 +743,20 @@ class SubvolumeV1(SubvolumeBase, SubvolumeTemplate):
                 return False
             raise
 
+    def remove_non_existent_pending_clones(self, path, link_path, track_id):
+        try:
+            self.fs.lstat(link_path)
+        except cephfs.Error as e:
+            if e.args[0] == errno.ENOENT:
+                try:
+                    log.info(f"Cleaning up dangling symlink for the clone: {path}")
+                    self.fs.unlink(path)
+                    self._remove_snap_clone(track_id)
+                except (cephfs.Error, MetadataMgrException) as e:
+                    log.warning(f'Removing of dangling symlink for the clone {path}'
+                                f' failed with the exception:"{e}"')
+                    pass
+    
     def get_pending_clones(self, snapname):
         pending_clones_info: Dict[str, Any] = {"has_pending_clones": "no"}
         pending_track_id_list = []
@@ -768,7 +782,9 @@ class SubvolumeV1(SubvolumeBase, SubvolumeTemplate):
 
         for track_id in pending_track_id_list:
             try:
-                link_path = self.fs.readlink(os.path.join(index_path, track_id), 4096)
+                t_path = os.path.join(index_path, track_id)
+                link_path = self.fs.readlink(t_path, 4096)
+                self.remove_non_existent_pending_clones(t_path, link_path, track_id)
             except cephfs.Error as e:
                 if e.errno != errno.ENOENT:
                     raise VolumeException(-e.args[0], e.args[1])