[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,
|
||||
REQUIRED_INTERFACES,
|
||||
check_optional_relations,
|
||||
get_hugepage_number,
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.network.ip import (
|
||||
@ -149,6 +150,9 @@ def config_changed():
|
||||
for rid in relation_ids('zeromq-configuration'):
|
||||
zeromq_configuration_relation_joined(rid)
|
||||
|
||||
for rid in relation_ids('neutron-plugin'):
|
||||
neutron_plugin_joined(rid)
|
||||
|
||||
if is_relation_made("nrpe-external-master"):
|
||||
update_nrpe_config()
|
||||
|
||||
@ -377,6 +381,12 @@ def update_nrpe_config():
|
||||
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')
|
||||
@restart_on_change(restart_map())
|
||||
def neutron_plugin_changed():
|
||||
|
@ -802,27 +802,32 @@ def git_post_install(projects_yaml):
|
||||
apt_install(LATE_GIT_PACKAGES, fatal=True)
|
||||
|
||||
|
||||
def get_hugepage_number():
|
||||
# TODO: defaults to 2M - this should probably be configurable
|
||||
# and support multiple pool sizes - e.g. 2M and 1G.
|
||||
hugepage_size = 2048
|
||||
hugepage_config = config('hugepages')
|
||||
if hugepage_config.endswith('%'):
|
||||
import psutil
|
||||
mem = psutil.virtual_memory()
|
||||
hugepage_config_pct = hugepage_config.strip('%')
|
||||
hugepage_multiplier = float(hugepage_config_pct) / 100
|
||||
hugepages = int((mem.total * hugepage_multiplier) / hugepage_size)
|
||||
else:
|
||||
hugepages = int(hugepage_config)
|
||||
return hugepages
|
||||
|
||||
|
||||
def install_hugepages():
|
||||
""" Configure hugepages """
|
||||
hugepage_config = config('hugepages')
|
||||
if hugepage_config:
|
||||
# TODO: defaults to 2M - this should probably be configurable
|
||||
# and support multiple pool sizes - e.g. 2M and 1G.
|
||||
hugepage_size = 2048
|
||||
if hugepage_config.endswith('%'):
|
||||
import psutil
|
||||
mem = psutil.virtual_memory()
|
||||
hugepage_config_pct = hugepage_config.strip('%')
|
||||
hugepage_multiplier = float(hugepage_config_pct) / 100
|
||||
hugepages = int((mem.total * hugepage_multiplier) / hugepage_size)
|
||||
else:
|
||||
hugepages = int(hugepage_config)
|
||||
mnt_point = '/run/hugepages/kvm'
|
||||
hugepage_support(
|
||||
'nova',
|
||||
mnt_point=mnt_point,
|
||||
group='root',
|
||||
nr_hugepages=hugepages,
|
||||
nr_hugepages=get_hugepage_number(),
|
||||
mount=False,
|
||||
set_shmmax=True,
|
||||
)
|
||||
|
@ -124,8 +124,10 @@ class NovaComputeRelationsTests(CharmTestCase):
|
||||
hooks.config_changed()
|
||||
self.assertFalse(self.do_openstack_upgrade.called)
|
||||
|
||||
@patch.object(hooks, 'neutron_plugin_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.migration_enabled.return_value = True
|
||||
_zmq_joined = self.patch('zeromq_configuration_relation_joined')
|
||||
@ -143,8 +145,10 @@ class NovaComputeRelationsTests(CharmTestCase):
|
||||
self.assertTrue(self.initialize_ssh_keys.called)
|
||||
self.assertTrue(_zmq_joined.called)
|
||||
|
||||
@patch.object(hooks, 'neutron_plugin_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.test_config.set('enable-resize', True)
|
||||
_zmq_joined = self.patch('zeromq_configuration_relation_joined')
|
||||
@ -162,8 +166,10 @@ class NovaComputeRelationsTests(CharmTestCase):
|
||||
self.enable_shell.assert_called_with(user='nova')
|
||||
self.assertTrue(_zmq_joined.called)
|
||||
|
||||
@patch.object(hooks, 'neutron_plugin_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.test_config.set('enable-resize', False)
|
||||
_zmq_joined = self.patch('zeromq_configuration_relation_joined')
|
||||
|
Loading…
x
Reference in New Issue
Block a user