Change worker-multiplier to float

Change the worker-multiplier to a floating point config option type
instead of integer. This allows users to specify workers to be less
than the number of CPUs, which is useful in deployments with multiple
services deployed into containers on top of bare metal.

The fix is to simply change the config option type and to sync in
the necessary update from lp:charm-helpers.

Partial-Bug: #1602444

Change-Id: I2c846832d24f709a3d019b766f5f23c28c4371f4
Signed-off-by: Billy Olsen <billy.olsen@gmail.com>
This commit is contained in:
Billy Olsen 2016-07-12 17:05:20 -07:00
parent 01148cc7a9
commit 8d35070586
6 changed files with 20 additions and 10 deletions

View File

@ -335,8 +335,8 @@ options:
default: default:
description: SSL key to use with certificate specified as console-ssl-cert. description: SSL key to use with certificate specified as console-ssl-cert.
worker-multiplier: worker-multiplier:
type: int type: float
default: 2 default: 2.0
description: | description: |
The CPU core multiplier to use when configuring worker processes for The CPU core multiplier to use when configuring worker processes for
Nova and Neutron. By default, the number of workers for each daemon Nova and Neutron. By default, the number of workers for each daemon

View File

@ -71,7 +71,7 @@ class OpenStackAmuletDeployment(AmuletDeployment):
base_charms = { base_charms = {
'mysql': ['precise', 'trusty'], 'mysql': ['precise', 'trusty'],
'mongodb': ['precise', 'trusty'], 'mongodb': ['precise', 'trusty'],
'nrpe': ['precise', 'trusty'], 'nrpe': ['precise', 'trusty', 'wily', 'xenial'],
} }
for svc in other_services: for svc in other_services:
@ -112,7 +112,7 @@ class OpenStackAmuletDeployment(AmuletDeployment):
# Charms which should use the source config option # Charms which should use the source config option
use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph', use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph',
'ceph-osd', 'ceph-radosgw', 'ceph-mon'] 'ceph-osd', 'ceph-radosgw', 'ceph-mon', 'ceph-proxy']
# Charms which can not use openstack-origin, ie. many subordinates # Charms which can not use openstack-origin, ie. many subordinates
no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe', no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe',

View File

@ -57,6 +57,7 @@ from charmhelpers.core.host import (
mkdir, mkdir,
write_file, write_file,
pwgen, pwgen,
lsb_release,
) )
from charmhelpers.contrib.hahelpers.cluster import ( from charmhelpers.contrib.hahelpers.cluster import (
determine_apache_port, determine_apache_port,
@ -1195,7 +1196,10 @@ class WorkerConfigContext(OSContextGenerator):
def __call__(self): def __call__(self):
multiplier = config('worker-multiplier') or 0 multiplier = config('worker-multiplier') or 0
ctxt = {"workers": self.num_cpus * multiplier} count = int(self.num_cpus * multiplier)
if multiplier > 0 and count == 0:
count = 1
ctxt = {"workers": count}
return ctxt return ctxt
@ -1436,7 +1440,8 @@ class AppArmorContext(OSContextGenerator):
:return ctxt: Dictionary of the apparmor profile or None :return ctxt: Dictionary of the apparmor profile or None
""" """
if config('aa-profile-mode') in ['disable', 'enforce', 'complain']: if config('aa-profile-mode') in ['disable', 'enforce', 'complain']:
ctxt = {'aa_profile_mode': config('aa-profile-mode')} ctxt = {'aa_profile_mode': config('aa-profile-mode'),
'ubuntu_release': lsb_release()['DISTRIB_RELEASE']}
else: else:
ctxt = None ctxt = None
return ctxt return ctxt

View File

@ -174,7 +174,7 @@ def init_is_systemd():
def adduser(username, password=None, shell='/bin/bash', system_user=False, def adduser(username, password=None, shell='/bin/bash', system_user=False,
primary_group=None, secondary_groups=None, uid=None): primary_group=None, secondary_groups=None, uid=None, home_dir=None):
"""Add a user to the system. """Add a user to the system.
Will log but otherwise succeed if the user already exists. Will log but otherwise succeed if the user already exists.
@ -186,6 +186,7 @@ def adduser(username, password=None, shell='/bin/bash', system_user=False,
:param str primary_group: Primary group for user; defaults to username :param str primary_group: Primary group for user; defaults to username
:param list secondary_groups: Optional list of additional groups :param list secondary_groups: Optional list of additional groups
:param int uid: UID for user being created :param int uid: UID for user being created
:param str home_dir: Home directory for user
:returns: The password database entry struct, as returned by `pwd.getpwnam` :returns: The password database entry struct, as returned by `pwd.getpwnam`
""" """
@ -200,6 +201,8 @@ def adduser(username, password=None, shell='/bin/bash', system_user=False,
cmd = ['useradd'] cmd = ['useradd']
if uid: if uid:
cmd.extend(['--uid', str(uid)]) cmd.extend(['--uid', str(uid)])
if home_dir:
cmd.extend(['--home', str(home_dir)])
if system_user or password is None: if system_user or password is None:
cmd.append('--system') cmd.append('--system')
else: else:

View File

@ -71,7 +71,7 @@ class OpenStackAmuletDeployment(AmuletDeployment):
base_charms = { base_charms = {
'mysql': ['precise', 'trusty'], 'mysql': ['precise', 'trusty'],
'mongodb': ['precise', 'trusty'], 'mongodb': ['precise', 'trusty'],
'nrpe': ['precise', 'trusty'], 'nrpe': ['precise', 'trusty', 'wily', 'xenial'],
} }
for svc in other_services: for svc in other_services:
@ -112,7 +112,7 @@ class OpenStackAmuletDeployment(AmuletDeployment):
# Charms which should use the source config option # Charms which should use the source config option
use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph', use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph',
'ceph-osd', 'ceph-radosgw', 'ceph-mon'] 'ceph-osd', 'ceph-radosgw', 'ceph-mon', 'ceph-proxy']
# Charms which can not use openstack-origin, ie. many subordinates # Charms which can not use openstack-origin, ie. many subordinates
no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe', no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe',

View File

@ -293,8 +293,10 @@ class NovaComputeContextTests(CharmTestCase):
'https://10.5.0.1:6082/spice_auto.html') 'https://10.5.0.1:6082/spice_auto.html')
@mock.patch('charmhelpers.core.hookenv.local_unit') @mock.patch('charmhelpers.core.hookenv.local_unit')
def test_nova_config_context(self, local_unit): @mock.patch('charmhelpers.contrib.openstack.context.config')
def test_nova_config_context(self, mock_config, local_unit):
local_unit.return_value = 'nova-cloud-controller/0' local_unit.return_value = 'nova-cloud-controller/0'
mock_config.side_effect = self.test_config.get
ctxt = context.NovaConfigContext()() ctxt = context.NovaConfigContext()()
self.assertEqual(ctxt['scheduler_default_filters'], self.assertEqual(ctxt['scheduler_default_filters'],
self.config('scheduler-default-filters')) self.config('scheduler-default-filters'))