[gnuoy, r=james-page] This change sets the requests hugepage value down the relation with the neutron plugin subordinate charm. The reason for this is so that the subordinate can react to a change in that value and restart any services. This is a feature that was requested by cisco for the cisco-vpp charm
This commit is contained in:
commit
ac3ea9ef1f
@ -70,6 +70,7 @@ from nova_compute_utils import (
|
|||||||
install_hugepages,
|
install_hugepages,
|
||||||
REQUIRED_INTERFACES,
|
REQUIRED_INTERFACES,
|
||||||
check_optional_relations,
|
check_optional_relations,
|
||||||
|
get_hugepage_number,
|
||||||
)
|
)
|
||||||
|
|
||||||
from charmhelpers.contrib.network.ip import (
|
from charmhelpers.contrib.network.ip import (
|
||||||
@ -149,6 +150,9 @@ def config_changed():
|
|||||||
for rid in relation_ids('zeromq-configuration'):
|
for rid in relation_ids('zeromq-configuration'):
|
||||||
zeromq_configuration_relation_joined(rid)
|
zeromq_configuration_relation_joined(rid)
|
||||||
|
|
||||||
|
for rid in relation_ids('neutron-plugin'):
|
||||||
|
neutron_plugin_joined(rid)
|
||||||
|
|
||||||
if is_relation_made("nrpe-external-master"):
|
if is_relation_made("nrpe-external-master"):
|
||||||
update_nrpe_config()
|
update_nrpe_config()
|
||||||
|
|
||||||
@ -377,6 +381,12 @@ def update_nrpe_config():
|
|||||||
nrpe_setup.write()
|
nrpe_setup.write()
|
||||||
|
|
||||||
|
|
||||||
|
@hooks.hook('neutron-plugin-relation-joined')
|
||||||
|
def neutron_plugin_joined(relid=None):
|
||||||
|
relation_set(relation_id=relid,
|
||||||
|
hugepage_number=get_hugepage_number())
|
||||||
|
|
||||||
|
|
||||||
@hooks.hook('neutron-plugin-relation-changed')
|
@hooks.hook('neutron-plugin-relation-changed')
|
||||||
@restart_on_change(restart_map())
|
@restart_on_change(restart_map())
|
||||||
def neutron_plugin_changed():
|
def neutron_plugin_changed():
|
||||||
|
@ -802,13 +802,11 @@ def git_post_install(projects_yaml):
|
|||||||
apt_install(LATE_GIT_PACKAGES, fatal=True)
|
apt_install(LATE_GIT_PACKAGES, fatal=True)
|
||||||
|
|
||||||
|
|
||||||
def install_hugepages():
|
def get_hugepage_number():
|
||||||
""" Configure hugepages """
|
|
||||||
hugepage_config = config('hugepages')
|
|
||||||
if hugepage_config:
|
|
||||||
# TODO: defaults to 2M - this should probably be configurable
|
# TODO: defaults to 2M - this should probably be configurable
|
||||||
# and support multiple pool sizes - e.g. 2M and 1G.
|
# and support multiple pool sizes - e.g. 2M and 1G.
|
||||||
hugepage_size = 2048
|
hugepage_size = 2048
|
||||||
|
hugepage_config = config('hugepages')
|
||||||
if hugepage_config.endswith('%'):
|
if hugepage_config.endswith('%'):
|
||||||
import psutil
|
import psutil
|
||||||
mem = psutil.virtual_memory()
|
mem = psutil.virtual_memory()
|
||||||
@ -817,12 +815,19 @@ def install_hugepages():
|
|||||||
hugepages = int((mem.total * hugepage_multiplier) / hugepage_size)
|
hugepages = int((mem.total * hugepage_multiplier) / hugepage_size)
|
||||||
else:
|
else:
|
||||||
hugepages = int(hugepage_config)
|
hugepages = int(hugepage_config)
|
||||||
|
return hugepages
|
||||||
|
|
||||||
|
|
||||||
|
def install_hugepages():
|
||||||
|
""" Configure hugepages """
|
||||||
|
hugepage_config = config('hugepages')
|
||||||
|
if hugepage_config:
|
||||||
mnt_point = '/run/hugepages/kvm'
|
mnt_point = '/run/hugepages/kvm'
|
||||||
hugepage_support(
|
hugepage_support(
|
||||||
'nova',
|
'nova',
|
||||||
mnt_point=mnt_point,
|
mnt_point=mnt_point,
|
||||||
group='root',
|
group='root',
|
||||||
nr_hugepages=hugepages,
|
nr_hugepages=get_hugepage_number(),
|
||||||
mount=False,
|
mount=False,
|
||||||
set_shmmax=True,
|
set_shmmax=True,
|
||||||
)
|
)
|
||||||
|
@ -124,8 +124,10 @@ class NovaComputeRelationsTests(CharmTestCase):
|
|||||||
hooks.config_changed()
|
hooks.config_changed()
|
||||||
self.assertFalse(self.do_openstack_upgrade.called)
|
self.assertFalse(self.do_openstack_upgrade.called)
|
||||||
|
|
||||||
|
@patch.object(hooks, 'neutron_plugin_joined')
|
||||||
@patch.object(hooks, 'compute_joined')
|
@patch.object(hooks, 'compute_joined')
|
||||||
def test_config_changed_with_migration(self, compute_joined):
|
def test_config_changed_with_migration(self, compute_joined,
|
||||||
|
neutron_plugin_joined):
|
||||||
self.git_install_requested.return_value = False
|
self.git_install_requested.return_value = False
|
||||||
self.migration_enabled.return_value = True
|
self.migration_enabled.return_value = True
|
||||||
_zmq_joined = self.patch('zeromq_configuration_relation_joined')
|
_zmq_joined = self.patch('zeromq_configuration_relation_joined')
|
||||||
@ -143,8 +145,10 @@ class NovaComputeRelationsTests(CharmTestCase):
|
|||||||
self.assertTrue(self.initialize_ssh_keys.called)
|
self.assertTrue(self.initialize_ssh_keys.called)
|
||||||
self.assertTrue(_zmq_joined.called)
|
self.assertTrue(_zmq_joined.called)
|
||||||
|
|
||||||
|
@patch.object(hooks, 'neutron_plugin_joined')
|
||||||
@patch.object(hooks, 'compute_joined')
|
@patch.object(hooks, 'compute_joined')
|
||||||
def test_config_changed_with_resize(self, compute_joined):
|
def test_config_changed_with_resize(self, compute_joined,
|
||||||
|
neutron_plugin_joined):
|
||||||
self.git_install_requested.return_value = False
|
self.git_install_requested.return_value = False
|
||||||
self.test_config.set('enable-resize', True)
|
self.test_config.set('enable-resize', True)
|
||||||
_zmq_joined = self.patch('zeromq_configuration_relation_joined')
|
_zmq_joined = self.patch('zeromq_configuration_relation_joined')
|
||||||
@ -162,8 +166,10 @@ class NovaComputeRelationsTests(CharmTestCase):
|
|||||||
self.enable_shell.assert_called_with(user='nova')
|
self.enable_shell.assert_called_with(user='nova')
|
||||||
self.assertTrue(_zmq_joined.called)
|
self.assertTrue(_zmq_joined.called)
|
||||||
|
|
||||||
|
@patch.object(hooks, 'neutron_plugin_joined')
|
||||||
@patch.object(hooks, 'compute_joined')
|
@patch.object(hooks, 'compute_joined')
|
||||||
def test_config_changed_without_resize(self, compute_joined):
|
def test_config_changed_without_resize(self, compute_joined,
|
||||||
|
neutron_plugin_joined):
|
||||||
self.git_install_requested.return_value = False
|
self.git_install_requested.return_value = False
|
||||||
self.test_config.set('enable-resize', False)
|
self.test_config.set('enable-resize', False)
|
||||||
_zmq_joined = self.patch('zeromq_configuration_relation_joined')
|
_zmq_joined = self.patch('zeromq_configuration_relation_joined')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user