diff --git a/src/config.yaml b/src/config.yaml index 3c4fa28..f2af93a 100644 --- a/src/config.yaml +++ b/src/config.yaml @@ -258,3 +258,24 @@ options: description: | Value of bluestore compression max blob size for solid state media on pools requested by this charm. + mds-cache-memory-limit: + type: string + default: 4Gi + description: | + Set the maximum size of Metadata Server (MDS) cache, in bytes. The MDS + will try to stay under this value by (1 - mds_cache_reservation) as a + percent. This is not a hard limit. + mds-cache-reservation: + type: float + default: 0.05 + description: | + The cache reservation for the MDS cache to maintain. The MDS will try + to stay under this value as a percent by (1 - mds_cache_reservation) + as a percent. + mds-health-cache-threshold: + type: float + default: 1.5 + description: | + If the MDS exceeds the cache size specified in mds-cache-memory-limit, + this parameter sets the memory limit, as a percentage of + mds_cache_reservation, that triggers a health warning. diff --git a/src/lib/charm/openstack/ceph_fs.py b/src/lib/charm/openstack/ceph_fs.py index a9433c4..99e891f 100644 --- a/src/lib/charm/openstack/ceph_fs.py +++ b/src/lib/charm/openstack/ceph_fs.py @@ -53,6 +53,10 @@ class CephFSCharmConfigurationAdapter( def networks(self): return self.charm_instance.get_networks('ceph-public-network') + @property + def mds_cache(self): + return self.charm_instance.get_mds_cache() + @property def public_addr(self): if ch_core.hookenv.config('prefer-ipv6'): @@ -119,6 +123,13 @@ class BaseCephFSCharm(charms_openstack.plugins.CephCharm): return self.get_host_ip() + def get_mds_cache(self): + return {'mds-cache-memory-limit': config('mds-cache-memory-limit'), + 'mds-cache-reservation': config('mds-cache-reservation'), + 'mds-health-cache-threshold': + config('mds-health-cache-threshold') + } + @cached @staticmethod def get_host_ip(hostname=None): diff --git a/src/templates/ceph.conf b/src/templates/ceph.conf index d064e44..cd2725c 100644 --- a/src/templates/ceph.conf +++ b/src/templates/ceph.conf @@ -26,6 +26,9 @@ log file = /var/log/ceph.log [mds] keyring = /var/lib/ceph/mds/$cluster-$id/keyring +mds cache memory limit = {{ options.mds_cache_memory_limit }} +mds cache reservation = {{ options.mds_cache_reservation }} +mds health cache threshold = {{ options.mds_health_cache_threshold }} [mds.{{ options.mds_name }}] host = {{ options.hostname }} diff --git a/unit_tests/test_lib_charm_openstack_ceph_fs.py b/unit_tests/test_lib_charm_openstack_ceph_fs.py index 8cf4faf..6873aae 100644 --- a/unit_tests/test_lib_charm_openstack_ceph_fs.py +++ b/unit_tests/test_lib_charm_openstack_ceph_fs.py @@ -80,3 +80,12 @@ class TestCephFsCharm(test_utils.PatchHelper): self.assertEquals( self.target.options.public_addr, '2001:db8::fake') + self.patch_target('get_mds_cache') + self.get_mds_cache.return_value = { + 'mds-cache-memory-limit': '4Gi', + 'mds-cache-reservation': 0.05, + 'mds-health-cache-threshold': 1.5} + self.assertEquals(self.target.options.mds_cache, { + 'mds-cache-memory-limit': '4Gi', + 'mds-cache-reservation': 0.05, + 'mds-health-cache-threshold': 1.5})