]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/mirroring: make snapshot mirror metrics cache optional
authorKotresh HR <khiremat@redhat.com>
Sun, 21 Jun 2026 17:52:29 +0000 (23:22 +0530)
committerKotresh HR <khiremat@redhat.com>
Tue, 23 Jun 2026 15:19:29 +0000 (20:49 +0530)
Add snapshot_mirror_metrics_cache_enabled (default true). When disabled,
metrics_status reads omap directly and skips complete and partial caches.
When enabled, behavior is unchanged.

Fixes: https://tracker.ceph.com/issues/76686
Signed-off-by: Kotresh HR <khiremat@redhat.com>
src/pybind/mgr/mirroring/fs/snapshot_mirror.py
src/pybind/mgr/mirroring/module.py

index 12279d6e84fe63e32e9d2726e48f77bd08517022..0d88613e2d63635772fcf0a0b3ec75d9a10aae3e 100644 (file)
@@ -767,6 +767,9 @@ class FSSnapshotMirror:
         except MirrorException as me:
             return me.args[0], '', me.args[1]
 
+    def _metrics_cache_enabled(self):
+        return self.mgr.get_module_option('snapshot_mirror_metrics_cache_enabled')
+
     @lru_cache_timeout(
         lambda self, *_args, **_kwargs: self.mgr.get_module_option(
             'snapshot_mirror_metrics_cache_ttl'),
@@ -814,6 +817,22 @@ class FSSnapshotMirror:
             fspolicy.policy, fspolicy.get_live_instance_ids())
         return metrics
 
+    def _load_sync_stat_metrics_from_omap(self, filesystem, mirrored_dir_path,
+                                          peer_uuid, peers, fspolicy):
+        ioctx = metrics_load.open_metadata_ioctx(
+            self.rados, self.fs_map, filesystem)
+        if mirrored_dir_path:
+            dir_path = norm_path(mirrored_dir_path)
+            metrics, _, _ = metrics_load.fetch_sync_stat_metrics(
+                ioctx, filesystem, peers, mirrored_dir_path, peer_uuid,
+                fspolicy.policy, fspolicy.get_live_instance_ids())
+            return metrics_for_dir_and_peers(metrics, dir_path, peers)
+        complete_metrics = metrics_load.load_sync_stat_metrics(
+            ioctx, filesystem, None, fspolicy.policy,
+            fspolicy.get_live_instance_ids(), peers)
+        return try_get_from_complete(
+            complete_metrics, mirrored_dir_path, peer_uuid, peers)
+
     def metrics_status(self, filesystem, mirrored_dir_path, peer_uuid):
         """Return persisted mirror directory snapshot metrics as JSON.
 
@@ -848,6 +867,16 @@ class FSSnapshotMirror:
                 else:
                     requested_peers = all_peers
 
+                if not self._metrics_cache_enabled():
+                    log.debug('sync stat metrics for filesystem %s (dir=%s, peer=%s) '
+                              'cache disabled; loading from omap',
+                              filesystem, mirrored_dir_path or '*',
+                              peer_uuid or '*')
+                    metrics = self._load_sync_stat_metrics_from_omap(
+                        filesystem, mirrored_dir_path, peer_uuid,
+                        requested_peers, fspolicy)
+                    return 0, json.dumps({'metrics': metrics}, indent=4), ''
+
                 if mirrored_dir_path:
                     dir_path = norm_path(mirrored_dir_path)
                     # Single-dir query: peek complete cache (key: filesystem
index 37a8cb63747b73b9683d049d811f826080f5ada1..3fbe145864ed1c69ca2944df91ba86e1dbdd9b00 100644 (file)
@@ -9,6 +9,13 @@ from .fs.snapshot_mirror import FSSnapshotMirror
 class Module(MgrModule):
     CLICommand = MirroringCLICommand
     MODULE_OPTIONS: List[Option] = [
+        Option(
+            'snapshot_mirror_metrics_cache_enabled',
+            type='bool',
+            default=True,
+            desc='Cache fs snapshot mirror status omap metrics',
+            runtime=True,
+        ),
         Option(
             'snapshot_mirror_metrics_cache_ttl',
             type='secs',