From: Patrick Donnelly Date: Wed, 24 Mar 2021 00:53:58 +0000 (-0700) Subject: pybind/mgr/snap_schedule: log database updates for debugging X-Git-Tag: v17.1.0~2320^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6b58fc35da790f6870756b719f9118c6b8122c81;p=ceph.git pybind/mgr/snap_schedule: log database updates for debugging Signed-off-by: Patrick Donnelly --- diff --git a/qa/tasks/cephfs/test_snap_schedules.py b/qa/tasks/cephfs/test_snap_schedules.py index 2a19d06e64c2..f303d71d26c2 100644 --- a/qa/tasks/cephfs/test_snap_schedules.py +++ b/qa/tasks/cephfs/test_snap_schedules.py @@ -63,6 +63,9 @@ class TestSnapSchedules(CephFSTestCase): def _allow_minute_granularity_snapshots(self): self.config_set('mgr', 'mgr/snap_schedule/allow_m_granularity', True) + def _dump_on_update(self): + self.config_set('mgr', 'mgr/snap_schedule/dump_on_update', True) + def setUp(self): super(TestSnapSchedules, self).setUp() self.volname = None @@ -74,6 +77,7 @@ class TestSnapSchedules(CephFSTestCase): self.snapshots = set() self._enable_snap_schedule() self._allow_minute_granularity_snapshots() + self._dump_on_update() def tearDown(self): if self.vol_created: diff --git a/src/pybind/mgr/snap_schedule/fs/schedule_client.py b/src/pybind/mgr/snap_schedule/fs/schedule_client.py index 779bdc9b75a5..b72107a42df4 100644 --- a/src/pybind/mgr/snap_schedule/fs/schedule_client.py +++ b/src/pybind/mgr/snap_schedule/fs/schedule_client.py @@ -122,6 +122,10 @@ class SnapSchedClient(CephfsClient): def allow_minute_snaps(self) -> None: return self.mgr.get_module_option('allow_m_granularity') + @property + def dump_on_update(self) -> None: + return self.mgr.get_module_option('dump_on_update') + def get_schedule_db(self, fs: str) -> sqlite3.Connection: if fs not in self.sqlite_connections: poolid = self.get_metadata_pool(fs) @@ -168,6 +172,10 @@ class SnapSchedClient(CephfsClient): db = self.get_schedule_db(fs) rows = [] with db: + if self.dump_on_update: + dump = [line for line in db.iterdump()] + dump = "\n".join(dump) + log.debug(f"db dump:\n{dump}") cur = db.execute(Schedule.EXEC_QUERY, (path,)) all_rows = cur.fetchall() rows = [r for r in all_rows diff --git a/src/pybind/mgr/snap_schedule/module.py b/src/pybind/mgr/snap_schedule/module.py index 8e39e3b02ddf..84b04c4bb7a2 100644 --- a/src/pybind/mgr/snap_schedule/module.py +++ b/src/pybind/mgr/snap_schedule/module.py @@ -22,6 +22,14 @@ class Module(MgrModule): desc='allow minute scheduled snapshots', runtime=True, ), + Option( + 'dump_on_update', + type='bool', + default=False, + desc='dump database to debug log on update', + runtime=True, + ), + ] def __init__(self, *args: Any, **kwargs: Any) -> None: