summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Page <james.page@ubuntu.com>2019-03-26 09:49:34 +0000
committerJames Page <james.page@ubuntu.com>2019-03-26 09:49:34 +0000
commite7ed38fcc862d2aa4fae0d53e082ba68e09d7217 (patch)
tree74269f7b5eee6233f7373c2767194f630f0bb7a4
parent9b094b8ef8855638696689d02a1b3d4c0822997c (diff)
sysctl: skip application when running in containerHEADmaster
This charm is used in containers when deploying Octavia; sysctl can't be updated from within a LXD container, so skip the call to apply sysctl configuration if the unit is running in a container of any sort. Change-Id: If3c40fa6c8b6e5448293caf726088d152f6eeee8
Notes
Notes (review): Verified+1: Canonical CI <uosci-testing-bot@ubuntu.com> Code-Review+2: Frode Nordahl <frode.nordahl@canonical.com> Workflow+1: Frode Nordahl <frode.nordahl@canonical.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 26 Mar 2019 11:04:18 +0000 Reviewed-on: https://review.openstack.org/647697 Project: openstack/charm-neutron-openvswitch Branch: refs/heads/master
-rwxr-xr-xhooks/neutron_ovs_hooks.py6
-rw-r--r--unit_tests/test_neutron_ovs_hooks.py11
2 files changed, 16 insertions, 1 deletions
diff --git a/hooks/neutron_ovs_hooks.py b/hooks/neutron_ovs_hooks.py
index 4fa7690..e5e2793 100755
--- a/hooks/neutron_ovs_hooks.py
+++ b/hooks/neutron_ovs_hooks.py
@@ -39,6 +39,10 @@ from charmhelpers.core.hookenv import (
39 39
40from charmhelpers.core.sysctl import create as create_sysctl 40from charmhelpers.core.sysctl import create as create_sysctl
41 41
42from charmhelpers.core.host import (
43 is_container,
44)
45
42from neutron_ovs_utils import ( 46from neutron_ovs_utils import (
43 DHCP_PACKAGES, 47 DHCP_PACKAGES,
44 DVR_PACKAGES, 48 DVR_PACKAGES,
@@ -120,7 +124,7 @@ def config_changed():
120 request_nova_compute_restart = True 124 request_nova_compute_restart = True
121 125
122 sysctl_settings = config('sysctl') 126 sysctl_settings = config('sysctl')
123 if sysctl_settings: 127 if not is_container() and sysctl_settings:
124 create_sysctl(sysctl_settings, 128 create_sysctl(sysctl_settings,
125 '/etc/sysctl.d/50-openvswitch.conf') 129 '/etc/sysctl.d/50-openvswitch.conf')
126 130
diff --git a/unit_tests/test_neutron_ovs_hooks.py b/unit_tests/test_neutron_ovs_hooks.py
index a8c9766..27691ab 100644
--- a/unit_tests/test_neutron_ovs_hooks.py
+++ b/unit_tests/test_neutron_ovs_hooks.py
@@ -51,6 +51,7 @@ TO_PATCH = [
51 'install_tmpfilesd', 51 'install_tmpfilesd',
52 'purge_packages', 52 'purge_packages',
53 'determine_purge_packages', 53 'determine_purge_packages',
54 'is_container',
54] 55]
55NEUTRON_CONF_DIR = "/etc/neutron" 56NEUTRON_CONF_DIR = "/etc/neutron"
56 57
@@ -63,6 +64,7 @@ class NeutronOVSHooksTests(CharmTestCase):
63 super(NeutronOVSHooksTests, self).setUp(hooks, TO_PATCH) 64 super(NeutronOVSHooksTests, self).setUp(hooks, TO_PATCH)
64 65
65 self.config.side_effect = self.test_config.get 66 self.config.side_effect = self.test_config.get
67 self.is_container.return_value = False
66 hooks.hooks._config_save = False 68 hooks.hooks._config_save = False
67 69
68 def _call_hook(self, hookname): 70 def _call_hook(self, hookname):
@@ -122,6 +124,15 @@ class NeutronOVSHooksTests(CharmTestCase):
122 '{foo : bar}', 124 '{foo : bar}',
123 '/etc/sysctl.d/50-openvswitch.conf') 125 '/etc/sysctl.d/50-openvswitch.conf')
124 126
127 def test_config_changed_sysctl_container(self):
128 self.test_config.set(
129 'sysctl',
130 '{foo : bar}'
131 )
132 self.is_container.return_value = True
133 self._call_hook('config-changed')
134 self.create_sysctl.assert_not_called()
135
125 @patch.object(hooks, 'neutron_plugin_joined') 136 @patch.object(hooks, 'neutron_plugin_joined')
126 def test_config_changed_rocky_upgrade(self, _plugin_joined): 137 def test_config_changed_rocky_upgrade(self, _plugin_joined):
127 self.determine_purge_packages.return_value = ['python-neutron'] 138 self.determine_purge_packages.return_value = ['python-neutron']