From af33e0d5ab6f173a1c46774b5376a2903ddf84b1 Mon Sep 17 00:00:00 2001 From: James Page Date: Tue, 7 Oct 2014 13:27:23 +0100 Subject: [PATCH] Add support for worker configuration --- config.yaml | 7 +++++++ .../charmhelpers/contrib/openstack/context.py | 19 +++++++++++++++++++ hooks/cinder_utils.py | 3 ++- templates/icehouse/cinder.conf | 1 + 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/config.yaml b/config.yaml index bff32ebd..35522642 100644 --- a/config.yaml +++ b/config.yaml @@ -181,3 +181,10 @@ options: order for this charm to function correctly, the privacy extension must be disabled and a non-temporary address must be configured/available on your network interface. + worker-multiplier: + type: int + default: 2 + description: | + The CPU core multiplier to use when configuring worker processes for + Cinder. By default, the number of workers for each daemon is set to + twice the number of CPU cores a service unit has. diff --git a/hooks/charmhelpers/contrib/openstack/context.py b/hooks/charmhelpers/contrib/openstack/context.py index 173089f4..538dc913 100644 --- a/hooks/charmhelpers/contrib/openstack/context.py +++ b/hooks/charmhelpers/contrib/openstack/context.py @@ -903,3 +903,22 @@ class BindHostContext(OSContextGenerator): return { 'bind_host': '0.0.0.0' } + + +class WorkerConfigContext(OSContextGenerator): + + @property + def num_cpus(self): + try: + from psutil import NUM_CPUS + except ImportError: + apt_install('python-psutil', fatal=True) + from psutil import NUM_CPUS + return NUM_CPUS + + def __call__(self): + multiplier = config('worker-multiplier') or 1 + ctxt = { + "workers": self.num_cpus * multiplier + } + return ctxt diff --git a/hooks/cinder_utils.py b/hooks/cinder_utils.py index 0ba0d01c..336571cf 100644 --- a/hooks/cinder_utils.py +++ b/hooks/cinder_utils.py @@ -131,7 +131,8 @@ CONFIG_FILES = OrderedDict([ cinder_contexts.StorageBackendContext(), cinder_contexts.LoggingConfigContext(), context.IdentityServiceContext(), - context.BindHostContext()], + context.BindHostContext(), + context.WorkerConfigContext()], 'services': ['cinder-api', 'cinder-volume', 'cinder-scheduler', 'haproxy'] }), diff --git a/templates/icehouse/cinder.conf b/templates/icehouse/cinder.conf index a0f39d63..91d1e33d 100644 --- a/templates/icehouse/cinder.conf +++ b/templates/icehouse/cinder.conf @@ -16,6 +16,7 @@ auth_strategy = keystone state_path = /var/lib/cinder lock_path = /var/lock/cinder volumes_dir = /var/lib/cinder/volumes +osapi_volume_workers = {{ workers }} {% include "parts/rabbitmq" %}