[hopem,r=gnuoy] Add support for configuring rbd client cache.

Closes-Bug: 1412856
This commit is contained in:
Liam Young 2015-09-28 08:56:16 +01:00
commit d8208e7e34
4 changed files with 34 additions and 1 deletions

View File

@ -1,4 +1,4 @@
branch: lp:charm-helpers
branch: lp:~hopem/charm-helpers/add-rbd-cache-config-support
destination: hooks/charmhelpers
include:
- core

View File

@ -225,6 +225,14 @@ options:
description: |
RBD pool to use with Nova libvirt RBDImageBackend. Only required when you
have libvirt-image-backend set to 'rbd'.
rbd-client-cache:
type: string
default:
description: |
Enable/disable rbd client cache. Leaving this value unset will result in
default Ceph rbd client settings being used (rbd cache is enabled by
default for Ceph >= Giant). Supported values here are "enabled" or
"disabled".
ceph-osd-replication-count:
type: int
default: 3

View File

@ -13,3 +13,9 @@ log to syslog = {{ use_syslog }}
err to syslog = {{ use_syslog }}
clog to syslog = {{ use_syslog }}
[client]
{% if rbd_client_cache_settings -%}
{% for key, value in rbd_client_cache_settings.iteritems() -%}
{{ key }} = {{ value }}
{% endfor -%}
{%- endif %}

View File

@ -1,5 +1,7 @@
import uuid
import os
import platform
from charmhelpers.contrib.openstack import context
from charmhelpers.core.host import service_running, service_start
from charmhelpers.fetch import apt_install, filter_installed_packages
@ -181,6 +183,23 @@ class NovaComputeCephContext(context.CephContext):
elif config('libvirt-image-backend') == 'lvm':
ctxt['libvirt_images_type'] = 'lvm'
rbd_cache = config('rbd-client-cache') or ""
if rbd_cache.lower() == "enabled":
# We use write-though only to be safe for migration
ctxt['rbd_client_cache_settings'] = \
{'rbd cache': 'true',
'rbd cache size': '64 MiB',
'rbd cache max dirty': '0 MiB',
'rbd cache writethrough until flush': 'true',
'admin socket': '/var/run/ceph/rbd-client-$pid.asok'}
asok_path = '/var/run/ceph/'
if not os.path.isdir(asok_path):
os.mkdir(asok_path)
elif rbd_cache.lower() == "disabled":
ctxt['rbd_client_cache_settings'] = {'rbd cache': 'false'}
return ctxt