]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/mirroring: make snapshot mirror metrics cache TTL configurable
authorKotresh HR <khiremat@redhat.com>
Sun, 21 Jun 2026 17:50:28 +0000 (23:20 +0530)
committerKotresh HR <khiremat@redhat.com>
Tue, 23 Jun 2026 15:19:29 +0000 (20:49 +0530)
Add snapshot_mirror_metrics_cache_ttl as a runtime mgr/mirroring module
option (default 15 seconds) instead of a hard-coded CACHE_TTL_SECS.
Both complete and partial lru_cache_timeout wrappers read the value
when caching omap metrics so operators can tune cache freshness without
code changes.

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 dc7f45c32c2b0cfa4ba3aaf006823c41d1aaff96..12279d6e84fe63e32e9d2726e48f77bd08517022 100644 (file)
@@ -22,7 +22,7 @@ from .utils import INSTANCE_ID_PREFIX, MIRROR_OBJECT_NAME, Finisher, \
     AsyncOpTracker, get_metadata_pool, norm_path, connect_to_filesystem, \
     disconnect_from_filesystem
 from .metrics.cache import (
-    CACHE_TTL_SECS, COMPLETE_CACHE_MAX, lru_cache_timeout, PARTIAL_CACHE_MAX,
+    COMPLETE_CACHE_MAX, lru_cache_timeout, PARTIAL_CACHE_MAX,
     metrics_for_dir_and_peers, try_get_from_complete)
 from .metrics import load as metrics_load
 from .exception import MirrorException
@@ -768,7 +768,8 @@ class FSSnapshotMirror:
             return me.args[0], '', me.args[1]
 
     @lru_cache_timeout(
-        lambda self, *_args, **_kwargs: CACHE_TTL_SECS,
+        lambda self, *_args, **_kwargs: self.mgr.get_module_option(
+            'snapshot_mirror_metrics_cache_ttl'),
         COMPLETE_CACHE_MAX)
     def sync_stat_complete_cache(self, filesystem):
         """Load all directories and all peers for a filesystem from omap.
@@ -790,7 +791,8 @@ class FSSnapshotMirror:
             self.get_filesystem_peers(filesystem))
 
     @lru_cache_timeout(
-        lambda self, *_args, **_kwargs: CACHE_TTL_SECS,
+        lambda self, *_args, **_kwargs: self.mgr.get_module_option(
+            'snapshot_mirror_metrics_cache_ttl'),
         PARTIAL_CACHE_MAX)
     def sync_stat_partial_cache(self, filesystem, dir_path, peer_ids):
         """Load sync-stat omap keys for one directory and a peer set.
index 1321e27f74924f872b6a8226e0b446e24e2b8f5c..37a8cb63747b73b9683d049d811f826080f5ada1 100644 (file)
@@ -8,7 +8,15 @@ from .fs.snapshot_mirror import FSSnapshotMirror
 
 class Module(MgrModule):
     CLICommand = MirroringCLICommand
-    MODULE_OPTIONS: List[Option] = []
+    MODULE_OPTIONS: List[Option] = [
+        Option(
+            'snapshot_mirror_metrics_cache_ttl',
+            type='secs',
+            default=15,
+            desc='TTL for cached fs snapshot mirror status omap metrics',
+            runtime=True,
+        ),
+    ]
     NOTIFY_TYPES = [NotifyType.fs_map]
 
     def __init__(self, *args, **kwargs):