diff --git a/config.yaml b/config.yaml index 9ddc54a7..59e634ec 100644 --- a/config.yaml +++ b/config.yaml @@ -211,3 +211,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 + Keystone. 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/keystone_utils.py b/hooks/keystone_utils.py index 54aa05f0..936cd2f8 100644 --- a/hooks/keystone_utils.py +++ b/hooks/keystone_utils.py @@ -115,7 +115,8 @@ BASE_RESOURCE_MAP = OrderedDict([ context.PostgresqlDBContext(), context.SyslogContext(), keystone_context.HAProxyContext(), - context.BindHostContext()], + context.BindHostContext(), + context.WorkerConfigContext()], }), (HAPROXY_CONF, { 'contexts': [context.HAProxyContext(), diff --git a/templates/icehouse/keystone.conf b/templates/icehouse/keystone.conf index 3a4ff9f0..6c545ee3 100644 --- a/templates/icehouse/keystone.conf +++ b/templates/icehouse/keystone.conf @@ -14,6 +14,8 @@ verbose = {{ verbose }} public_endpoint = {{ public_endpoint }} admin_endpoint = {{ admin_endpoint }} bind_host = {{ bind_host }} +public_workers = {{ workers }} +admin_workers = {{ workers }} [database] {% if database_host -%}