From: Kotresh HR Date: Sun, 21 Jun 2026 17:50:28 +0000 (+0530) Subject: mgr/mirroring: make snapshot mirror metrics cache TTL configurable X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e36faf8bcca5afd6ab4454751fb1d6e84a1bed5f;p=ceph.git mgr/mirroring: make snapshot mirror metrics cache TTL configurable 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 --- diff --git a/src/pybind/mgr/mirroring/fs/snapshot_mirror.py b/src/pybind/mgr/mirroring/fs/snapshot_mirror.py index dc7f45c32c2..12279d6e84f 100644 --- a/src/pybind/mgr/mirroring/fs/snapshot_mirror.py +++ b/src/pybind/mgr/mirroring/fs/snapshot_mirror.py @@ -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. diff --git a/src/pybind/mgr/mirroring/module.py b/src/pybind/mgr/mirroring/module.py index 1321e27f749..37a8cb63747 100644 --- a/src/pybind/mgr/mirroring/module.py +++ b/src/pybind/mgr/mirroring/module.py @@ -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):