sysctl: skip application when running in container
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
This commit is contained in:
parent
9b094b8ef8
commit
e7ed38fcc8
@ -39,6 +39,10 @@ from charmhelpers.core.hookenv import (
|
||||
|
||||
from charmhelpers.core.sysctl import create as create_sysctl
|
||||
|
||||
from charmhelpers.core.host import (
|
||||
is_container,
|
||||
)
|
||||
|
||||
from neutron_ovs_utils import (
|
||||
DHCP_PACKAGES,
|
||||
DVR_PACKAGES,
|
||||
@ -120,7 +124,7 @@ def config_changed():
|
||||
request_nova_compute_restart = True
|
||||
|
||||
sysctl_settings = config('sysctl')
|
||||
if sysctl_settings:
|
||||
if not is_container() and sysctl_settings:
|
||||
create_sysctl(sysctl_settings,
|
||||
'/etc/sysctl.d/50-openvswitch.conf')
|
||||
|
||||
|
@ -51,6 +51,7 @@ TO_PATCH = [
|
||||
'install_tmpfilesd',
|
||||
'purge_packages',
|
||||
'determine_purge_packages',
|
||||
'is_container',
|
||||
]
|
||||
NEUTRON_CONF_DIR = "/etc/neutron"
|
||||
|
||||
@ -63,6 +64,7 @@ class NeutronOVSHooksTests(CharmTestCase):
|
||||
super(NeutronOVSHooksTests, self).setUp(hooks, TO_PATCH)
|
||||
|
||||
self.config.side_effect = self.test_config.get
|
||||
self.is_container.return_value = False
|
||||
hooks.hooks._config_save = False
|
||||
|
||||
def _call_hook(self, hookname):
|
||||
@ -122,6 +124,15 @@ class NeutronOVSHooksTests(CharmTestCase):
|
||||
'{foo : bar}',
|
||||
'/etc/sysctl.d/50-openvswitch.conf')
|
||||
|
||||
def test_config_changed_sysctl_container(self):
|
||||
self.test_config.set(
|
||||
'sysctl',
|
||||
'{foo : bar}'
|
||||
)
|
||||
self.is_container.return_value = True
|
||||
self._call_hook('config-changed')
|
||||
self.create_sysctl.assert_not_called()
|
||||
|
||||
@patch.object(hooks, 'neutron_plugin_joined')
|
||||
def test_config_changed_rocky_upgrade(self, _plugin_joined):
|
||||
self.determine_purge_packages.return_value = ['python-neutron']
|
||||
|
Loading…
Reference in New Issue
Block a user