Merge "Ensure we only try to set sysctls outside of a container"
This commit is contained in:
commit
b4a468f9aa
@ -21,6 +21,7 @@ from charmhelpers.fetch import (
|
||||
apt_purge,
|
||||
)
|
||||
from charmhelpers.core.host import (
|
||||
is_container,
|
||||
lsb_release,
|
||||
)
|
||||
from charmhelpers.contrib.hahelpers.cluster import(
|
||||
@ -124,8 +125,11 @@ def config_changed():
|
||||
|
||||
sysctl_settings = config('sysctl')
|
||||
if sysctl_settings:
|
||||
create_sysctl(sysctl_settings,
|
||||
'/etc/sysctl.d/50-quantum-gateway.conf')
|
||||
if is_container():
|
||||
log("Cannot create sysctls inside of a container", level=WARNING)
|
||||
else:
|
||||
create_sysctl(sysctl_settings,
|
||||
'/etc/sysctl.d/50-quantum-gateway.conf')
|
||||
|
||||
if config('vendor-data'):
|
||||
write_vendordata(config('vendor-data'))
|
||||
|
@ -63,6 +63,7 @@ TO_PATCH = [
|
||||
'remove_legacy_nova_metadata',
|
||||
'services',
|
||||
'remove_old_packages',
|
||||
'is_container',
|
||||
]
|
||||
|
||||
|
||||
@ -76,6 +77,7 @@ class TestQuantumHooks(CharmTestCase):
|
||||
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'precise'}
|
||||
# passthrough
|
||||
self.b64decode.side_effect = lambda arg: arg
|
||||
self.is_container.return_value = False
|
||||
hookenv.config.side_effect = self.test_config.get
|
||||
hooks.hooks._config_save = False
|
||||
|
||||
@ -138,6 +140,28 @@ class TestQuantumHooks(CharmTestCase):
|
||||
'{foo : bar}',
|
||||
'/etc/sysctl.d/50-quantum-gateway.conf')
|
||||
|
||||
def test_config_changed_in_container(self):
|
||||
self.disable_nova_metadata.return_value = False
|
||||
|
||||
def mock_relids(rel):
|
||||
return ['relid']
|
||||
self.test_config.set(
|
||||
'sysctl',
|
||||
'{foo : bar}'
|
||||
)
|
||||
self.openstack_upgrade_available.return_value = True
|
||||
self.valid_plugin.return_value = True
|
||||
self.relation_ids.side_effect = mock_relids
|
||||
self.is_container.return_value = True
|
||||
_amqp_joined = self.patch('amqp_joined')
|
||||
_amqp_nova_joined = self.patch('amqp_nova_joined')
|
||||
self._call_hook('config-changed')
|
||||
self.assertTrue(self.do_openstack_upgrade.called)
|
||||
self.assertTrue(self.configure_ovs.called)
|
||||
self.assertTrue(_amqp_joined.called)
|
||||
self.assertTrue(_amqp_nova_joined.called)
|
||||
self.create_sysctl.assert_not_called()
|
||||
|
||||
def test_config_changed_upgrade(self):
|
||||
self.disable_nova_metadata.return_value = False
|
||||
self.openstack_upgrade_available.return_value = True
|
||||
|
Loading…
Reference in New Issue
Block a user