Skip to content

Commit

Permalink
Enable charm to configure mds cache options.
Browse files Browse the repository at this point in the history
Closes-Bug: #1891409
Func-Test-PR: openstack-charmers/zaza-openstack-tests#774
Change-Id: If2bdd5c0f2afa1843e686cf69570a50901c85875
  • Loading branch information
ethanmye-rs committed Jun 2, 2022
1 parent 721df6e commit 8f31a33
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
11 changes: 11 additions & 0 deletions src/lib/charm/openstack/ceph_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def mds_name(self):
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'):
Expand Down Expand Up @@ -119,6 +123,13 @@ def get_public_addr(self):

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):
Expand Down
3 changes: 3 additions & 0 deletions src/templates/ceph.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
9 changes: 9 additions & 0 deletions unit_tests/test_lib_charm_openstack_ceph_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,12 @@ def test_configuration_class(self):
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})

0 comments on commit 8f31a33

Please sign in to comment.