]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/snap_schedule: add debug log for missing or wrong path
authorMilind Changire <mchangir@redhat.com>
Tue, 29 Nov 2022 07:54:27 +0000 (13:24 +0530)
committerMilind Changire <mchangir@redhat.com>
Thu, 27 Apr 2023 08:53:21 +0000 (14:23 +0530)
Bad paths cause a Traceback to be dumped in the logs and unloads the
module causing denial of service.

Fixes: https://tracker.ceph.com/issues/58095
Signed-off-by: Milind Changire <mchangir@redhat.com>
(cherry picked from commit c689548694a138cfc87c4ad8aa5ea67789da11bb)

Conflicts:
src/pybind/mgr/snap_schedule/fs/schedule_client.py
- included minor code rearrangement to share db connection
  better between try/except/finally clauses

src/pybind/mgr/snap_schedule/fs/schedule_client.py

index e1e5c8237e48cd1e9016a47d79352367fdea350b..319e068d3f86fdb4fa3115613656cba69851f300 100644 (file)
@@ -264,6 +264,7 @@ class SnapSchedClient(CephfsClient):
 
     def create_scheduled_snapshot(self, fs_name, path, retention, start, repeat):
         log.debug(f'Scheduled snapshot of {path} triggered')
+        set_schedule_to_inactive = False
         with self.get_schedule_db(fs_name) as conn_mgr:
             db = conn_mgr.dbinfo.db
             try:
@@ -282,17 +283,22 @@ class SnapSchedClient(CephfsClient):
                     log.info(f'created scheduled snapshot of {path}')
                     log.debug(f'created scheduled snapshot {snap_name}')
                     sched.update_last(time, db)
+                except cephfs.ObjectNotFound:
+                    # maybe path is missing or wrong
+                    self._log_exception('create_scheduled_snapshot')
+                    log.debug(f'path {path} is probably missing or wrong; '
+                              'remember to strip off the mount point path '
+                              'prefix to provide the correct path')
+                    set_schedule_to_inactive = True
                 except cephfs.Error:
-                    self._log_exception('create_scheduled_snapshot: '
-                                        'unexpected exception; '
-                                        f'deactivating schedule fs:"{fs_name}" '
-                                        f'path:"{path}" repeat:"{repeat}" '
-                                        f'retention:"{retention}"')
-                    sched.set_inactive(db)
+                    self._log_exception('create_scheduled_snapshot')
                 except Exception:
                     # catch all exceptions cause otherwise we'll never know since this
                     # is running in a thread
                     self._log_exception('create_scheduled_snapshot')
+                finally:
+                    if set_schedule_to_inactive:
+                        sched.set_inactive(db)
             finally:
                 self.refresh_snap_timers(fs_name, path, db)
                 self.prune_snapshots(sched, db)