diff --git a/config.yaml b/config.yaml index a265454e..3055e674 100644 --- a/config.yaml +++ b/config.yaml @@ -92,7 +92,7 @@ options: accomodate the packet overhead of using GRE tunnels. enable-l3-agent: type: boolean - default: True + default: True description: | Optional configuration to support use of linux router Note that this is used only for Cisco n1kv plugin. @@ -115,3 +115,9 @@ options: . This network will be used for tenant network traffic in overlay networks. + sysctl: + type: string + default: + description: | + YAML-formatted associative array of sysctl key/value pairs to be set + persistently e.g. '{ kernel.pid_max : 4194303 }'. \ No newline at end of file diff --git a/hooks/quantum_hooks.py b/hooks/quantum_hooks.py index b10c5ab6..9d7a4364 100755 --- a/hooks/quantum_hooks.py +++ b/hooks/quantum_hooks.py @@ -33,6 +33,7 @@ from charmhelpers.contrib.openstack.utils import ( openstack_upgrade_available, ) from charmhelpers.payload.execd import execd_preinstall +from charmhelpers.core.sysctl import create as create_sysctl import sys from quantum_utils import ( @@ -78,6 +79,11 @@ def config_changed(): global CONFIGS if openstack_upgrade_available(get_common_package()): CONFIGS = do_openstack_upgrade() + + sysctl_dict = config('sysctl') + if sysctl_dict: + create_sysctl(sysctl_dict, '/etc/sysctl.d/50-quantum-gateway.conf') + # Re-run joined hooks as config might have changed for r_id in relation_ids('shared-db'): db_joined(relation_id=r_id) diff --git a/unit_tests/test_quantum_hooks.py b/unit_tests/test_quantum_hooks.py index c5f0520f..ee39c1bd 100644 --- a/unit_tests/test_quantum_hooks.py +++ b/unit_tests/test_quantum_hooks.py @@ -40,7 +40,8 @@ TO_PATCH = [ 'lsb_release', 'stop_services', 'b64decode', - 'is_relation_made' + 'is_relation_made', + 'create_sysctl', ] @@ -98,6 +99,7 @@ class TestQuantumHooks(CharmTestCase): def test_config_changed(self): def mock_relids(rel): return ['relid'] + self.test_config.set('sysctl', '{ kernel.max_pid: "1337"}') self.openstack_upgrade_available.return_value = True self.valid_plugin.return_value = True self.relation_ids.side_effect = mock_relids @@ -112,6 +114,7 @@ class TestQuantumHooks(CharmTestCase): self.assertTrue(_pgsql_db_joined.called) self.assertTrue(_amqp_joined.called) self.assertTrue(_amqp_nova_joined.called) + self.create_sysctl.assert_called() def test_config_changed_upgrade(self): self.openstack_upgrade_available.return_value = True